# OnnxValue (onnxruntime 1.15.0 API)

Package ai.onnxruntime

## Interface OnnxValue

All Superinterfaces:
  `java.lang.AutoCloseable`

All Known Implementing Classes:
  `OnnxMap`, `OnnxSequence`, `OnnxSparseTensor`, `OnnxTensor`, `OnnxTensorLike`

    public interface OnnxValue
    extends java.lang.AutoCloseable

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 Classes
`static class` `OnnxValue.OnnxValueType` The type of the `OnnxValue`, mirroring the id in the C API.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods
`void` `close()` Closes the OnnxValue, freeing it's native memory.
`static void` `close​(java.lang.Iterable<? extends OnnxValue> itr)` Calls close on each element of the iterable.
`static void` `close​(java.util.Map<java.lang.String,​? extends OnnxValue> map)` Calls close on each `OnnxValue` in the map.
`ValueInfo` `getInfo()` Gets the type info object associated with this OnnxValue.
`OnnxValue.OnnxValueType` `getType()` Gets the type of this OnnxValue.
`java.lang.Object` `getValue()` Returns the value as a Java object copying it out of the native heap.

### Method Detail

#### getType

    OnnxValue.OnnxValueType getType()

Gets the type of this OnnxValue.

Returns:
  The value type.

#### getValue

    java.lang.Object getValue()
                       throws OrtException

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 prefer `OnnxTensor.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.

#### close

    void close()

Closes the OnnxValue, freeing it's native memory.

Specified by:
  `close` in interface `java.lang.AutoCloseable`

#### close

    static void close​(java.lang.Iterable<? extends OnnxValue> itr)

Calls close on each element of the iterable.

Parameters:
  `itr` - An iterable of closeable OnnxValues.

#### close

    static void close​(java.util.Map<java.lang.String,​? extends OnnxValue> map)

Calls close on each `OnnxValue` in the map.

Parameters:
  `map` - A map of `OnnxValue`s.