Package ai.djl.inference
Class Predictor.PredictorContext
- java.lang.Object
-
- ai.djl.inference.Predictor.PredictorContext
-
- All Implemented Interfaces:
TranslatorContext
,java.lang.AutoCloseable
protected class Predictor.PredictorContext extends java.lang.Object implements TranslatorContext
-
-
Constructor Summary
Constructors Constructor Description PredictorContext()
Constructs a newPredictorContext
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.Object
getAttachment(java.lang.String key)
Returns value of attached key-value pair to context.Block
getBlock()
Returns the block from theTranslatorContext
.Metrics
getMetrics()
Returns the Metric tool to do benchmark.Model
getModel()
Returns theModel
object to understand the input/output.NDManager
getNDManager()
NDManager
getPredictorManager()
Returns the Predictor'sNDManager
.void
setAttachment(java.lang.String key, java.lang.Object value)
Set a key-value pair of attachments.
-
-
-
Method Detail
-
getModel
public Model getModel()
Returns theModel
object to understand the input/output.- Specified by:
getModel
in interfaceTranslatorContext
- Returns:
- the
Model
-
getNDManager
public NDManager getNDManager()
- Specified by:
getNDManager
in interfaceTranslatorContext
- Returns:
- the
NDManager
-
getPredictorManager
public NDManager getPredictorManager()
Returns the Predictor'sNDManager
.- Specified by:
getPredictorManager
in interfaceTranslatorContext
- Returns:
- the Predictor's
NDManager
-
getBlock
public Block getBlock()
Returns the block from theTranslatorContext
.- Specified by:
getBlock
in interfaceTranslatorContext
- Returns:
- the block from the
TranslatorContext
-
getMetrics
public Metrics getMetrics()
Returns the Metric tool to do benchmark.- Specified by:
getMetrics
in interfaceTranslatorContext
- Returns:
- the
Metrics
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceTranslatorContext
-
getAttachment
public java.lang.Object getAttachment(java.lang.String key)
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
public void setAttachment(java.lang.String key, java.lang.Object value)
Set a key-value pair of attachments.- Specified by:
setAttachment
in interfaceTranslatorContext
- Parameters:
key
- key of attached valuevalue
- value assosicated with key
-
-