public static class OrtSession.SessionOptions
extends java.lang.Object
implements java.lang.AutoCloseable
Used to set the number of threads, optimisation level, computation backend and other options.
Modifying this after the session has been constructed will have no effect.
Modifier and Type | Class and Description |
---|---|
static class |
OrtSession.SessionOptions.ExecutionMode
The execution mode to use.
|
static class |
OrtSession.SessionOptions.OptLevel
The optimisation level to use.
|
Constructor and Description |
---|
SessionOptions()
Create an empty session options.
|
Modifier and Type | Method and Description |
---|---|
void |
addCPU(boolean useArena)
Adds the CPU as an execution backend, using the arena allocator if desired.
|
void |
addCUDA()
Add CUDA as an execution backend, using device 0.
|
void |
addCUDA(int deviceNum)
Add CUDA as an execution backend, using the specified CUDA device id.
|
void |
addDnnl(boolean useArena)
Adds Intel's Deep Neural Network Library as an execution backend.
|
void |
addNGraph(java.lang.String ngBackendType)
Adds NGraph as an execution backend.
|
void |
addNnapi()
Adds Android's NNAPI as an execution backend.
|
void |
addNuphar(boolean allowUnalignedBuffers,
java.lang.String settings)
Adds Nuphar as an execution backend.
|
void |
addOpenVINO(java.lang.String deviceId)
Adds OpenVINO as an execution backend.
|
void |
addTensorrt(int deviceNum)
Adds Nvidia's TensorRT as an execution backend.
|
void |
close()
Closes the session options, releasing any memory acquired.
|
void |
setExecutionMode(OrtSession.SessionOptions.ExecutionMode mode)
Sets the execution mode of this options object, overriding the old setting.
|
void |
setInterOpNumThreads(int numThreads)
Sets the size of the CPU thread pool used for executing multiple request concurrently, if executing on a CPU.
|
void |
setIntraOpNumThreads(int numThreads)
Sets the size of the CPU thread pool used for executing a single graph, if executing on a CPU.
|
void |
setOptimizationLevel(OrtSession.SessionOptions.OptLevel level)
Sets the optimization level of this options object, overriding the old setting.
|
void |
setOptimizedModelFilePath(java.lang.String outputPath)
Sets the output path for the optimized model.
|
public void close()
close
in interface java.lang.AutoCloseable
public void setExecutionMode(OrtSession.SessionOptions.ExecutionMode mode) throws OrtException
mode
- The execution mode to use.OrtException
- If there was an error in native code.public void setOptimizationLevel(OrtSession.SessionOptions.OptLevel level) throws OrtException
level
- The optimization level to use.OrtException
- If there was an error in native code.public void setInterOpNumThreads(int numThreads) throws OrtException
numThreads
- The number of threads to use.OrtException
- If there was an error in native code.public void setIntraOpNumThreads(int numThreads) throws OrtException
numThreads
- The number of threads to use.OrtException
- If there was an error in native code.public void setOptimizedModelFilePath(java.lang.String outputPath) throws OrtException
outputPath
- The output path to write the model to.OrtException
- If there was an error in native code.public void addCUDA() throws OrtException
OrtException
- If there was an error in native code.public void addCUDA(int deviceNum) throws OrtException
deviceNum
- The CUDA device id.OrtException
- If there was an error in native code.public void addCPU(boolean useArena) throws OrtException
By default this backend is used, but if other backends are requested, it should be requested last.
useArena
- If true use the arena memory allocator.OrtException
- If there was an error in native code.public void addDnnl(boolean useArena) throws OrtException
useArena
- If true use the arena memory allocator.OrtException
- If there was an error in native code.public void addNGraph(java.lang.String ngBackendType) throws OrtException
See the documentation for the supported backend types.
ngBackendType
- The NGraph backend type.OrtException
- If there was an error in native code.public void addOpenVINO(java.lang.String deviceId) throws OrtException
deviceId
- The id of the OpenVINO execution device.OrtException
- If there was an error in native code.public void addTensorrt(int deviceNum) throws OrtException
deviceNum
- The id of the CUDA device.OrtException
- If there was an error in native code.public void addNnapi() throws OrtException
OrtException
- If there was an error in native code.public void addNuphar(boolean allowUnalignedBuffers, java.lang.String settings) throws OrtException
allowUnalignedBuffers
- Allow unaligned memory buffers.settings
- See the documentation for valid settings strings.OrtException
- If there was an error in native code.