Package ai.onnxruntime
Class OrtSession.Result
- java.lang.Object
-
- ai.onnxruntime.OrtSession.Result
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.lang.Iterable<java.util.Map.Entry<java.lang.String,OnnxValue>>
- Enclosing class:
- OrtSession
public static class OrtSession.Result extends java.lang.Object implements java.lang.AutoCloseable, java.lang.Iterable<java.util.Map.Entry<java.lang.String,OnnxValue>>
AnAutoCloseablewrapper around aMapcontainingOnnxValues.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 anIllegalStateExceptionupon access.OnnxValues which are supplied as pinned outputs to aruncall are not closed by theclose()method. Ownership of each output can be checked withisResultOwner(int).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()OnnxValueget(int index)Gets the value from the container at the specified index.java.util.Optional<OnnxValue>get(java.lang.String key)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.java.util.Iterator<java.util.Map.Entry<java.lang.String,OnnxValue>>iterator()intsize()Returns the number of outputs in this Result.
-
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
iterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,OnnxValue>> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.util.Map.Entry<java.lang.String,OnnxValue>>
-
get
public OnnxValue get(int index)
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
public java.util.Optional<OnnxValue> get(java.lang.String key)
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.
-
-