Package ai.djl.inference
Class Predictor.PredictorContext
java.lang.Object
ai.djl.inference.Predictor.PredictorContext
- All Implemented Interfaces:
TranslatorContext
,AutoCloseable
An implementation of
TranslatorContext
.-
Constructor Summary
ConstructorsConstructorDescriptionPredictorContext
(Model model, NDManager predictorManager, Metrics metrics) Constructs a newPredictorContext
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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 theModel
object to understand the input/output.Returns the Predictor'sNDManager
.void
setAttachment
(String key, Object value) Set a key-value pair of attachments.
-
Constructor Details
-
PredictorContext
Constructs a newPredictorContext
instance.
-
-
Method Details
-
getModel
Returns theModel
object to understand the input/output.- Specified by:
getModel
in interfaceTranslatorContext
- Returns:
- the
Model
-
getNDManager
- Specified by:
getNDManager
in interfaceTranslatorContext
- Returns:
- the
NDManager
-
getPredictorManager
Returns the Predictor'sNDManager
.- Specified by:
getPredictorManager
in interfaceTranslatorContext
- Returns:
- the Predictor's
NDManager
-
getBlock
Returns the block from theTranslatorContext
.- Specified by:
getBlock
in interfaceTranslatorContext
- Returns:
- the block from the
TranslatorContext
-
getMetrics
Returns the Metric tool to do benchmark.- Specified by:
getMetrics
in interfaceTranslatorContext
- Returns:
- the
Metrics
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceTranslatorContext
-
getAttachment
Returns value of attached key-value pair to context.- Specified by:
getAttachment
in interfaceTranslatorContext
- Parameters:
key
- key of attached value- Returns:
- the object stored in relevant map
-
setAttachment
Set a key-value pair of attachments.- Specified by:
setAttachment
in interfaceTranslatorContext
- Parameters:
key
- key of attached valuevalue
- value assosicated with key
-