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 class
AStreamingTranslator.StreamOutput
represents a streamable output type (either iterative or asynchronous).static enum
What types ofStreamingTranslator.StreamOutput
s are supported by aStreamingTranslator
. -
Method Summary
Modifier and TypeMethodDescriptionReturns what kind ofStreamingTranslator.StreamOutput
thisStreamingTranslator
supports.processStreamOutput
(TranslatorContext ctx, Stream<NDList> list) Processes the output NDList to the corresponding output object.default boolean
Returns whether theStreamingTranslator
supports iterative output.default boolean
Returns whether theStreamingTranslator
supports iterative output.Methods inherited from interface ai.djl.translate.PostProcessor
processOutput
Methods inherited from interface ai.djl.translate.PreProcessor
processInput
Methods 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.StreamOutput
thisStreamingTranslator
supports.- Returns:
- what kind of
StreamingTranslator.StreamOutput
thisStreamingTranslator
supports
-
supportsIterative
default boolean supportsIterative()Returns whether theStreamingTranslator
supports iterative output.- Returns:
- whether the
StreamingTranslator
supports iterative output - See Also:
-
supportsAsync
default boolean supportsAsync()Returns whether theStreamingTranslator
supports iterative output.- Returns:
- whether the
StreamingTranslator
supports iterative output - See Also:
-