Package ai.djl.translate
Interface TranslatorContext
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
Predictor.PredictorContext
public interface TranslatorContext extends java.lang.AutoCloseableTheTranslatorContextinterface provides a toolkit for pre-processing and postprocessing functionality.You can use this in
Translatorto get Model information and create an NDArray
-
-
Method Summary
All Methods Instance Methods Abstract 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
Model getModel()
Returns theModelobject to understand the input/output.- Returns:
- the
Model
-
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
-
getAttachment
java.lang.Object getAttachment(java.lang.String key)
Returns value of attached key-value pair to context.- Parameters:
key- key of attached value- Returns:
- the object stored in relevant map
-
setAttachment
void setAttachment(java.lang.String key, java.lang.Object value)Set a key-value pair of attachments.- Parameters:
key- key of attached valuevalue- value assosicated with key
-
close
void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-