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 newPredictorContextinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.lang.ObjectgetAttachment(java.lang.String key)Returns value of attached key-value pair to context.BlockgetBlock()Returns the block from theTranslatorContext.MetricsgetMetrics()Returns the Metric tool to do benchmark.ModelgetModel()Returns theModelobject to understand the input/output.NDManagergetNDManager()NDManagergetPredictorManager()Returns the Predictor'sNDManager.voidsetAttachment(java.lang.String key, java.lang.Object value)Set a key-value pair of attachments.
-
-
-
Method Detail
-
getModel
public Model getModel()
Returns theModelobject to understand the input/output.- Specified by:
getModelin interfaceTranslatorContext- Returns:
- the
Model
-
getNDManager
public NDManager getNDManager()
- Specified by:
getNDManagerin interfaceTranslatorContext- Returns:
- the
NDManager
-
getPredictorManager
public NDManager getPredictorManager()
Returns the Predictor'sNDManager.- Specified by:
getPredictorManagerin interfaceTranslatorContext- Returns:
- the Predictor's
NDManager
-
getBlock
public Block getBlock()
Returns the block from theTranslatorContext.- Specified by:
getBlockin interfaceTranslatorContext- Returns:
- the block from the
TranslatorContext
-
getMetrics
public Metrics getMetrics()
Returns the Metric tool to do benchmark.- Specified by:
getMetricsin interfaceTranslatorContext- Returns:
- the
Metrics
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceTranslatorContext
-
getAttachment
public java.lang.Object getAttachment(java.lang.String key)
Returns value of attached key-value pair to context.- Specified by:
getAttachmentin 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:
setAttachmentin interfaceTranslatorContext- Parameters:
key- key of attached valuevalue- value assosicated with key
-
-