runtime_parameters.h#

Tunable, model-independent knobs controlling how a graph is evaluated through :cpp:func:RunNode / :cpp:class:RuntimeSession.

namespace onnx_light

Alias that makes onnx-light headers compatible with code that references ONNX_LIGHT_NAMESPACE (the macro used in the standard onnx package).

Set to ONNX_LIGHT_NAMESPACE so both names resolve to the same namespace.

Symbol-visibility attribute for the public onnx-light C++ API.

Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when lib_onnx_proto uses hidden visibility by default.

Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal onnx namespace — rather than the ONNX_NAMESPACE macro — resolves to the onnx-light namespace. The standard onnx package lives in namespace onnx; onnx-light uses onnx_light (via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs from onnx.

namespace core
namespace runtime
struct RuntimeParameters#
#include <runtime_parameters.h>

Bundles the model-independent execution settings shared across the nodes of a graph evaluated through :cpp:func:RunNode / :cpp:class:RuntimeSession.

Today the only knob is :cpp:var:num_threads, the requested degree of parallelism. Grouping it in a dedicated struct keeps the :cpp:class:RuntimeContext interface stable as more tuning knobs (for example a thread-pool handle or a device descriptor) are added later without forcing every call site to take an extra argument.

Public Functions

RuntimeParameters() = default#
inline explicit RuntimeParameters(int32_t num_threads_)#
int32_t EffectiveNumThreads() const noexcept#

Returns the concrete number of threads to use, resolving the special num_threads values to an actual count.

0 and any negative value resolve to the detected physical-core count, falling back to the logical-core count, then std::thread::hardware_concurrency(), and finally 1. Every other value is returned unchanged. The result is always >= 1.

Returns: The effective number of threads, always at least 1.

inline bool is_parallel() const noexcept#

Returns true when the graph should be executed with more than one thread, i.e. when :cpp:func:EffectiveNumThreads is greater than 1.

Returns: true when parallel execution is enabled, false otherwise.

Public Members

int32_t num_threads = 0#

Number of threads used to parallelize the execution of a graph.

  • 0 (default): use one thread per detected physical CPU core.

  • 1: no parallelization, everything runs on the calling thread.

  • > 1: use exactly this many worker threads.

  • < 0: treated the same as 0 (use the number of CPU cores).