Package ai.djl.translate
Interface TranslatorContext
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
Predictor.PredictorContext
The
TranslatorContext interface provides a toolkit for pre-processing and postprocessing
functionality.
You can use this in Translator to get Model information and create an NDArray
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getAttachment(String key) Returns value of attached key-value pair to context.getBlock()Returns the block from theTranslatorContext.Returns the Metric tool to do benchmark.getModel()Returns theModelobject to understand the input/output.Returns the Predictor'sNDManager.voidsetAttachment(String key, Object value) Set a key-value pair of attachments.
-
Method Details
-
getModel
Model getModel()Returns theModelobject to understand the input/output.- Returns:
- the
Model
-
getNDManager
NDManager getNDManager()- Returns:
- the
NDManager
-
getPredictorManager
NDManager getPredictorManager()Returns the Predictor'sNDManager.- Returns:
- the Predictor's
NDManager
-
getBlock
Block getBlock()Returns the block from theTranslatorContext.- Returns:
- the block from the
TranslatorContext
-
getMetrics
Metrics getMetrics()Returns the Metric tool to do benchmark.- Returns:
- the
Metrics
-
getAttachment
Returns value of attached key-value pair to context.- Parameters:
key- key of attached value- Returns:
- the object stored in relevant map
-
setAttachment
Set a key-value pair of attachments.- Parameters:
key- key of attached valuevalue- value assosicated with key
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-