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.RunOptions
Used to control logging and termination of a call to
run(java.util.Map<java.lang.String, ai.onnxruntime.OnnxTensor>) . |
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.lang.String |
endProfiling()
Ends the profiling session and returns the output of the profiler.
|
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.
|
OnnxModelMetadata |
getMetadata()
Gets the metadata for the currently loaded model.
|
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,
OrtSession.RunOptions runOptions)
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.
|
OrtSession.Result |
run(java.util.Map<java.lang.String,OnnxTensor> inputs,
java.util.Set<java.lang.String> requestedOutputs,
OrtSession.RunOptions runOptions)
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, OrtSession.RunOptions runOptions) throws OrtException
The outputs are sorted based on their id number.
inputs
- The inputs to score.runOptions
- The RunOptions to control this run.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 traversal 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 OrtSession.Result run(java.util.Map<java.lang.String,OnnxTensor> inputs, java.util.Set<java.lang.String> requestedOutputs, OrtSession.RunOptions runOptions) throws OrtException
The outputs are sorted based on the supplied set traveral order.
inputs
- The inputs to score.requestedOutputs
- The requested outputs.runOptions
- The RunOptions to control this run.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 OnnxModelMetadata getMetadata() throws OrtException
OrtException
- If the native call failed.public java.lang.String endProfiling() throws OrtException
Profiling should be enabled in the OrtSession.SessionOptions
used to construct this Session
.
OrtException
- If the native call failed.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.