public class OrtSession
extends java.lang.Object
implements java.lang.AutoCloseable
Allows the inspection of the model's input and output nodes.
Produced by an OrtEnvironment
.
Most instance methods throw IllegalStateException
if the
session is closed and the methods are called.
Modifier and Type | Class and Description |
---|---|
static class |
OrtSession.Result
|
static class |
OrtSession.SessionOptions
Represents the options used to construct this session.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the session, releasing it's resources.
|
java.util.Map<java.lang.String,NodeInfo> |
getInputInfo()
Returns the info objects for the inputs, including their names and types.
|
java.util.Set<java.lang.String> |
getInputNames()
Returns the input names.
|
long |
getNumInputs()
Returns the number of inputs this model expects.
|
long |
getNumOutputs()
Returns the number of outputs this model expects.
|
java.util.Map<java.lang.String,NodeInfo> |
getOutputInfo()
Returns the info objects for the outputs, including their names and types.
|
java.util.Set<java.lang.String> |
getOutputNames()
Returns the output names.
|
OrtSession.Result |
run(java.util.Map<java.lang.String,OnnxTensor> inputs)
Scores an input feed dict, returning the map of all inferred outputs.
|
OrtSession.Result |
run(java.util.Map<java.lang.String,OnnxTensor> inputs,
java.util.Set<java.lang.String> requestedOutputs)
Scores an input feed dict, returning the map of requested inferred outputs.
|
java.lang.String |
toString() |
public long getNumInputs()
public long getNumOutputs()
public java.util.Set<java.lang.String> getInputNames()
public java.util.Set<java.lang.String> getOutputNames()
public java.util.Map<java.lang.String,NodeInfo> getInputInfo() throws OrtException
OrtException
- If there was an error in native code.public java.util.Map<java.lang.String,NodeInfo> getOutputInfo() throws OrtException
OrtException
- If there was an error in native code.public OrtSession.Result run(java.util.Map<java.lang.String,OnnxTensor> inputs) throws OrtException
The outputs are sorted based on their id number.
inputs
- The inputs to score.OrtException
- If there was an error in native code, the input names are invalid, or if there are zero or too many inputs.public OrtSession.Result run(java.util.Map<java.lang.String,OnnxTensor> inputs, java.util.Set<java.lang.String> requestedOutputs) throws OrtException
The outputs are sorted based on the supplied set traveral order.
inputs
- The inputs to score.requestedOutputs
- The requested outputs.OrtException
- If there was an error in native code, the input or output names are invalid, or if there are zero or too many inputs or outputs.public java.lang.String toString()
toString
in class java.lang.Object
public void close() throws OrtException
close
in interface java.lang.AutoCloseable
OrtException
- If it failed to close.