Package ai.onnxruntime
Interface OnnxValue
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
OnnxMap,OnnxSequence,OnnxSparseTensor,OnnxTensor,OnnxTensorLike
Top interface for input and output values from ONNX models. Currently implemented by
OnnxTensor, OnnxSparseTensor, OnnxSequence and OnnxMap. Will be sealed
to these types one day.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe type of theOnnxValue, mirroring the id in the C API. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the OnnxValue, freeing its native memory.static voidCalls close on each element of the iterable.static voidCalls close on eachOnnxValuein the map.getInfo()Gets the type info object associated with this OnnxValue.getType()Gets the type of this OnnxValue.getValue()Returns the value as a Java object copying it out of the native heap.booleanisClosed()Checks if this value is closed (i.e., the native object has been released).
-
Method Details
-
getType
OnnxValue.OnnxValueType getType()Gets the type of this OnnxValue.- Returns:
- The value type.
-
getValue
Returns the value as a Java object copying it out of the native heap. This operation can be quite slow for high dimensional tensors, where you should preferOnnxTensor.getByteBuffer()etc.Overridden by the subclasses with a more specific type if available.
- Returns:
- The value.
- Throws:
OrtException- If an error occurred reading the value.
-
getInfo
ValueInfo getInfo()Gets the type info object associated with this OnnxValue.- Returns:
- The type information.
-
isClosed
boolean isClosed()Checks if this value is closed (i.e., the native object has been released).- Returns:
- True if the value is closed and the native object has been released.
-
close
void close()Closes the OnnxValue, freeing its native memory.- Specified by:
closein interfaceAutoCloseable
-
close
Calls close on each element of the iterable.- Parameters:
itr- An iterable of closeable OnnxValues.
-
close
Calls close on eachOnnxValuein the map.- Parameters:
map- A map ofOnnxValues.
-