Package ai.onnxruntime
Class OrtEnvironment.ThreadingOptions
java.lang.Object
ai.onnxruntime.OrtEnvironment.ThreadingOptions
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- OrtEnvironment
Controls the global thread pools in the environment. Only used if the session is constructed
using an options with
OrtSession.SessionOptions.disablePerSessionThreads() set.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the threading options.voidWhen this is set it causes intra-op and inter-op thread pools to flush denormal values to zero.voidsetGlobalInterOpNumThreads(int numThreads) Sets the number of threads available for inter-op parallelism (i.e.voidsetGlobalIntraOpNumThreads(int numThreads) Sets the number of threads available for intra-op parallelism (i.e.voidsetGlobalSpinControl(boolean allowSpinning) Allows spinning of thread pools when their queues are empty.
-
Constructor Details
-
ThreadingOptions
public ThreadingOptions()Create an empty threading options.
-
-
Method Details
-
close
public void close()Closes the threading options.- Specified by:
closein interfaceAutoCloseable
-
setGlobalInterOpNumThreads
Sets the number of threads available for inter-op parallelism (i.e. running multiple ops in parallel).Setting it to 0 will allow ORT to choose the number of threads, setting it to 1 will cause the main thread to be used (i.e., no thread pools will be used).
- Parameters:
numThreads- The number of threads.- Throws:
OrtException- If there was an error in native code.
-
setGlobalIntraOpNumThreads
Sets the number of threads available for intra-op parallelism (i.e. within a single op).Setting it to 0 will allow ORT to choose the number of threads, setting it to 1 will cause the main thread to be used (i.e., no thread pools will be used).
- Parameters:
numThreads- The number of threads.- Throws:
OrtException- If there was an error in native code.
-
setGlobalSpinControl
Allows spinning of thread pools when their queues are empty. This call sets the value for both inter-op and intra-op thread pools.If the CPU usage is very high then do not enable this.
- Parameters:
allowSpinning- If true allow the thread pools to spin.- Throws:
OrtException- If there was an error in native code.
-
setGlobalDenormalAsZero
When this is set it causes intra-op and inter-op thread pools to flush denormal values to zero.- Throws:
OrtException- If there was an error in native code.
-