Package ai.onnxruntime
Class OrtSession.Result
java.lang.Object
ai.onnxruntime.OrtSession.Result
- All Implemented Interfaces:
AutoCloseable,Iterable<Map.Entry<String,OnnxValue>>
- Enclosing class:
- OrtSession
public static class OrtSession.Result
extends Object
implements AutoCloseable, Iterable<Map.Entry<String,OnnxValue>>
An
AutoCloseable wrapper around a Map containing OnnxValues.
When this is closed it closes all the OnnxValues owned by the result object. If you
maintain a reference to a value after this object has been closed it will throw an IllegalStateException upon access.
OnnxValues which are supplied as pinned outputs to a run call are not closed
by the close() method. Ownership of each output can be checked with isResultOwner(int).
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()get(int index) Gets the value from the container at the specified index.Gets the value from the container assuming it's not been closed.booleanisResultOwner(int index) Gets the value from the container at the specified index.iterator()intsize()Returns the number of outputs in this Result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
iterator
-
get
Gets the value from the container at the specified index.Throws
IllegalStateExceptionif the container has been closed, andIndexOutOfBoundsExceptionif the index is invalid.- Parameters:
index- The index to lookup.- Returns:
- The value at the index.
-
isResultOwner
public boolean isResultOwner(int index) Gets the value from the container at the specified index.Throws
IllegalStateExceptionif the container has been closed, andArrayIndexOutOfBoundsExceptionif the index is invalid.- Parameters:
index- The index to lookup.- Returns:
- Is that value owned by this result object?
-
size
public int size()Returns the number of outputs in this Result.- Returns:
- The number of outputs.
-
get
Gets the value from the container assuming it's not been closed.Throws
IllegalStateExceptionif the container has been closed.- Parameters:
key- The key to lookup.- Returns:
- Optional.of the value if it exists.
-