Class InferResult
- Author:
- sachachoumiloff
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an InferResult instance that wraps a ModelInferResponse from the Triton server. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]asDoubleArray(String name) float[]asFloatArray(String name) int[]asIntArray(String name) long[]asLongArray(String name) String[]asStringArray(String name) Retrieves the InferOutputTensor protobuf message for a specific output by name.getOutputAsArray(String name) Retrieves the output tensor data as a native Java array.Retrieves the complete ModelInferResponse protobuf message.
-
Constructor Details
-
InferResult
Constructs an InferResult instance that wraps a ModelInferResponse from the Triton server.This constructor takes the protobuf response message returned by the Triton Inference Server and provides convenient methods to access and deserialize the inference output tensors.
- Parameters:
result- the ModelInferResponse returned by the Triton Inference Server, must not be null- Throws:
NullPointerException- if result is null
-
-
Method Details
-
getRequestId
-
getModelName
-
getModelVersion
-
getOutputNames
-
asFloatArray
-
asDoubleArray
-
asIntArray
-
asLongArray
-
asStringArray
-
getOutputAsArray
Retrieves the output tensor data as a native Java array.This method deserializes the inference output tensor identified by the given name into the appropriate Java primitive array type based on the Triton datatype. The method first attempts to deserialize from raw binary content for efficiency; if not available, it falls back to the contents field.
The returned array type depends on the tensor's datatype:
- BOOL →
boolean[] - INT8 →
byte[] - INT16 →
short[] - INT32 →
int[] - INT64 →
long[] - UINT8 →
short[] - UINT16 →
int[] - UINT32 →
long[] - UINT64 →
long[] - FP32 →
float[] - FP64 →
double[] - FP16, BF16 →
float[] - BYTES →
String[]
- Parameters:
name- the name of the output tensor to retrieve; must match the tensor name returned by the model- Returns:
- a native array containing the deserialized tensor data
- Throws:
TritonDataNotFoundException- if no output tensor with the specified name is found in the responseTritonDataTypeException- if the tensor's datatype is not supported or invalidTritonInferException- if the tensor is found but contains no data
- BOOL →
-
getOutput
Retrieves the InferOutputTensor protobuf message for a specific output by name.This method provides direct access to the raw protobuf message representing the output tensor. It allows fine-grained control over the tensor data and metadata, including access to the tensor shape, datatype, and both raw and structured content representations.
For most use cases,
getOutputAsArray(String)is more convenient as it automatically deserializes the tensor into a native Java array. Use this method when you need direct access to the protobuf message or need to manually handle the tensor data.- Parameters:
name- the name of the output tensor to retrieve- Returns:
- the InferOutputTensor protobuf message with the specified name,
or
nullif no tensor with that name exists in the response
-
getResponse
Retrieves the complete ModelInferResponse protobuf message.This method provides access to the entire response message from the Triton Inference Server, including all output tensors, model metadata, and any additional response information. This is useful when you need to access multiple outputs or inspect the complete response structure.
- Returns:
- the underlying ModelInferResponse protobuf message; never null
-