OnnxRuntimeSessionOptions

Inheritance: java.lang.Object

public class OnnxRuntimeSessionOptions

Configuration options for creating ONNX InferenceSession. We recommend keeping the optimized defaults unless you are absolutely certain about the modifications. For technical details, refer to ONNX Runtime documentation.

Constructors

ConstructorDescription
OnnxRuntimeSessionOptions()

Fields

FieldDescription
enableCpuMemArenaEnables or disables the CPU memory arena allocator used by ONNX Runtime.
enableMemoryPatternEnables or disables memory pattern optimization for input tensors.
executionModeExecution mode for the session.
graphOptimizationLevelGraph optimization level for the session.
interOpNumThreadsNumber of threads for running multiple operations in parallel.
intraOpNumThreadsNumber of threads for a single operation.

OnnxRuntimeSessionOptions()

public OnnxRuntimeSessionOptions()

enableCpuMemArena

public static boolean enableCpuMemArena

Enables or disables the CPU memory arena allocator used by ONNX Runtime. When enabled, memory is pooled and reused for better performance, but may lead to increased memory consumption in multi-threaded scenarios. Disable to reduce peak memory usage at the cost of performance.

enableMemoryPattern

public static boolean enableMemoryPattern

Enables or disables memory pattern optimization for input tensors. When enabled, ONNX Runtime caches memory allocation patterns for faster execution, but may increase memory usage for dynamic input shapes. Disable if inputs vary significantly or to reduce memory footprint.

executionMode

public static ExecutionModeOnnx executionMode

Execution mode for the session. By default, operators are executed concurrently, whenever possible.

graphOptimizationLevel

public static GraphOptimizationLevelOnnx graphOptimizationLevel

Graph optimization level for the session. By default, all available optimizations are enabled for maximum performance.

interOpNumThreads

public static int interOpNumThreads

Number of threads for running multiple operations in parallel. If sequential execution is enabled, this value is ignored.

intraOpNumThreads

public static int intraOpNumThreads

Number of threads for a single operation.