Package ai.djl.inference.streaming
Interface StreamingTranslator<I,O>
- Type Parameters:
I- the input typeO- the output type
- All Superinterfaces:
PostProcessor<O>,PreProcessor<I>,Translator<I,O>
- All Known Subinterfaces:
ServingTranslator
An expansion of the
Translator with postProcessing for the StreamingBlock (used
by Predictor.streamingPredict(Object).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAStreamingTranslator.StreamOutputrepresents a streamable output type (either iterative or asynchronous).static enumWhat types ofStreamingTranslator.StreamOutputs are supported by aStreamingTranslator. -
Method Summary
Modifier and TypeMethodDescriptionReturns what kind ofStreamingTranslator.StreamOutputthisStreamingTranslatorsupports.processStreamOutput(TranslatorContext ctx, Stream<NDList> list) Processes the output NDList to the corresponding output object.default booleanReturns whether theStreamingTranslatorsupports iterative output.default booleanReturns whether theStreamingTranslatorsupports iterative output.Methods inherited from interface ai.djl.translate.PostProcessor
processOutputMethods inherited from interface ai.djl.translate.PreProcessor
processInputMethods inherited from interface ai.djl.translate.Translator
batchProcessInput, batchProcessOutput, getBatchifier, getExpansions, prepare
-
Method Details
-
processStreamOutput
StreamingTranslator.StreamOutput<O> processStreamOutput(TranslatorContext ctx, Stream<NDList> list) throws Exception Processes the output NDList to the corresponding output object.- Parameters:
ctx- the toolkit used for post-processinglist- the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774- Returns:
- the output object of expected type
- Throws:
Exception- if an error occurs during processing output
-
getSupport
StreamingTranslator.Support getSupport()Returns what kind ofStreamingTranslator.StreamOutputthisStreamingTranslatorsupports.- Returns:
- what kind of
StreamingTranslator.StreamOutputthisStreamingTranslatorsupports
-
supportsIterative
default boolean supportsIterative()Returns whether theStreamingTranslatorsupports iterative output.- Returns:
- whether the
StreamingTranslatorsupports iterative output - See Also:
-
supportsAsync
default boolean supportsAsync()Returns whether theStreamingTranslatorsupports iterative output.- Returns:
- whether the
StreamingTranslatorsupports iterative output - See Also:
-