Class RunOptions

java.lang.Object
smile.onnx.RunOptions
All Implemented Interfaces:
AutoCloseable

public class RunOptions extends Object implements AutoCloseable
Per-run configuration options passed to InferenceSession.run(Map, String[], RunOptions).

Instances must be closed after the run completes.

try (var runOpts = new RunOptions()) {
    runOpts.setLogTag("my-run").setLogSeverityLevel(LoggingLevel.WARNING);
    OrtValue[] outputs = session.run(inputMap, outputNames, runOpts);
}
  • Constructor Details

    • RunOptions

      public RunOptions()
      Creates a new RunOptions with default settings.
  • Method Details

    • setLogTag

      public RunOptions setLogTag(String tag)
      Sets the log tag for this run.
      Parameters:
      tag - a short string to identify this run in log messages.
      Returns:
      this object for chaining.
    • setLogVerbosityLevel

      public RunOptions setLogVerbosityLevel(int level)
      Sets the log verbosity level for this run.
      Parameters:
      level - verbosity level (higher = more verbose).
      Returns:
      this object for chaining.
    • setLogSeverityLevel

      public RunOptions setLogSeverityLevel(LoggingLevel level)
      Sets the minimum log severity for this run.
      Parameters:
      level - the minimum severity level.
      Returns:
      this object for chaining.
    • setTerminate

      public RunOptions setTerminate()
      Requests termination of the current run. This can be called from another thread to cancel a running inference.
      Returns:
      this object for chaining.
    • unsetTerminate

      public RunOptions unsetTerminate()
      Clears the termination flag set by setTerminate().
      Returns:
      this object for chaining.
    • addConfigEntry

      public RunOptions addConfigEntry(String key, String value)
      Adds a run-level configuration entry.
      Parameters:
      key - the configuration key.
      value - the configuration value.
      Returns:
      this object for chaining.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable