runtime_context.h#
Per-invocation runtime state shared across the nodes of a graph evaluated through :cpp:func:RunNode / :cpp:func:RunNodes.
-
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_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_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 fromonnx.-
namespace onnx_kernels
Typedefs
-
using TensorMap = std::unordered_map<std::string, Tensor>#
Name-keyed map of tensors carrying both the graph inputs/initializers and the intermediate values produced by previously executed nodes. Owned by :cpp:class:
RuntimeContext; the dispatcher reads a node’s inputs from this map by name (matchingnode.input(i)) and inserts every produced output under the name declared bynode.output(i).
-
using SequenceMap = std::unordered_map<std::string, Sequence>#
Name-keyed map of sequences carrying the sequence-typed graph values produced or consumed by sequence operators (
SequenceConstruct,SequenceEmpty,SequenceInsert,SequenceErase,SequenceAt,SequenceLength,ConcatFromSequence,SplitToSequence,SequenceMap).Sequences are stored separately from tensors because their runtime representation (:cpp:struct:
Sequence) is a list of tensors and not a single tensor: the dispatcher therefore keeps a sibling map of sequence-typed edges, looked up by the sameNodeProto::input/NodeProto::outputnames.
-
using OnnxMapMap = std::unordered_map<std::string, Map>#
Name-keyed map of maps carrying the map-typed graph values produced or consumed by map operators (
CastMap,DictVectorizer,ZipMap).Maps are stored separately from tensors because their runtime representation (:cpp:struct:
Map) is a keys+values tensor pair and not a single tensor: the dispatcher therefore keeps a sibling map of map-typed edges, looked up by the sameNodeProto::input/NodeProto::outputnames.
-
using FunctionMap = std::unordered_map<std::string, const FunctionProto*>#
Name-keyed map of model-local :cpp:type:
FunctionProtodefinitions known to the runtime. Populated by :cpp:func:RunModelfromModelProto::functions()so the dispatcher in :cpp:func:RunNodecan transparently invoke :cpp:func:RunFunctionwhenever a node references a model-local function instead of a built-in kernel.Keys are the canonical
"<domain>:<op_type>:<overload>"triple (the default ONNX domain — the emptyNodeProto::domain()— is normalised to"ai.onnx"and the overload defaults to the empty string). Values are non-owning pointers into the caller-ownedModelProto; the entries are valid only as long as the model outlives the runtime context.
-
using CustomKernelFn = std::function<void(const NodeProto&, class RuntimeContext&)>#
Signature of a user-provided custom kernel callback. Mirrors :cpp:type:
onnx_kernels::NodeKernelFn: implementations read their inputs fromrt.tensors()(orrt.sequences()) by name and insert produced outputs under the names declared bynode.output(i).Custom kernels are looked up by the canonical
"<domain>:<op_type>"key (the default ONNX domain — the emptyNodeProto::domain()— is normalised to"ai.onnx").
-
using CustomKernelMap = std::unordered_map<std::string, CustomKernelFn>#
Name-keyed map of user-provided custom kernels consulted by :cpp:func:
RunNodebefore the built-in :cpp:func:KernelDispatchTable. Allows callers to extend the runtime with operators implemented either in C++ (any callable compatible with :cpp:type:CustomKernelFn) or in Python (through theRuntimeContext.register_custom_kernelbinding) without touching the static dispatch table. Keys are"<domain>:<op_type>"; a custom registration overrides any built-in entry with the same key.
-
using RuntimeEventLog = std::vector<RuntimeEvent>#
Append-only log of tensor map mutations recorded by :cpp:class:
RuntimeContext.
Enums
-
enum class RuntimeEventAction : int32_t#
Kind of tensor map mutation recorded in the :cpp:class:
RuntimeContextevent log.kAdd— a new entry was inserted (e.g. via :cpp:func:RuntimeContext::Setor :cpp:func:RuntimeContext::Puton a previously absent name).kReplace— an existing entry was overwritten via :cpp:func:RuntimeContext::Put.kRemove— an entry was erased via :cpp:func:RuntimeContext::Remove.kRunNode— a kernel was dispatched for a single :cpp:class:NodeProto. The event records the node’sop_domain/op_type, the list ofinputsit consumed, and the wall-clockduration_nsof the dispatch (start time stored intimestamp_ns). Does not mutate the tensor map by itself.
Values:
-
enumerator kAdd#
-
enumerator kReplace#
-
enumerator kRemove#
-
enumerator kRunNode#
-
enum class RuntimeEventKind : int32_t#
Role of the tensor at the moment the event was recorded. Set by the call site that performs the mutation; not derived from the tensor map itself.
kUnknown— origin not specified.kInitializer— a graph initializer seeded by :cpp:func:RunGraph.kInput— a graph / function / subgraph input binding, or a value injected by the caller before running.kIntermediate— an intermediate value produced by a node kernel.kOutput— a subgraph / function output propagated back to the caller’s tensor map.
Values:
-
enumerator kUnknown#
-
enumerator kInitializer#
-
enumerator kInput#
-
enumerator kIntermediate#
-
enumerator kOutput#
Functions
-
const char *RuntimeEventActionName(RuntimeEventAction action) noexcept#
Returns a short lowercase label for
action("add","replace","remove","run_node"). Useful for human-readable rendering of the event log.
-
const char *RuntimeEventKindName(RuntimeEventKind kind) noexcept#
Returns a short lowercase label for
kind("unknown","initializer","input","intermediate","output").
Variables
-
constexpr int64_t kRuntimeEventValueLimit = 8#
Maximum number of element values captured inline by :cpp:class:
RuntimeEvent. The event always carries a fixed-size buffer ofkRuntimeEventValueLimitentries; for tensors with more elements the buffer holds only the firstkRuntimeEventValueLimitvalues (the remainder is truncated). When the element count exceeds the limit the event’sdata_typeis also set to-1to signal the truncation, andshapeis left empty so the log stays bounded for large activations.
-
class ExecutionPlan#
- #include <runtime_context.h>
Precomputed per-graph release schedule used by :cpp:func:
RunGraph/ :cpp:func:RunFunction/ :cpp:func:RunNodeswhen :cpp:func:RuntimeContext::release_intermediatesis enabled.An :cpp:class:
ExecutionPlancaptures two complementary pieces of information for a given node sequence:keep— the structural set of names that must never be released by the per-node release loop. For a :cpp:class:GraphProtothis is the union of declared inputs, initializers, and declared outputs; for a :cpp:class:FunctionProtoit is the union of declared inputs and outputs.releasable[i]— the list of names whose last reference (per :cpp:func:RuntimeContext::CollectNodeInputs) falls at nodeiand that are not inkeep— i.e. the intermediates that may be removed from the tensor / sequence map right after nodeifinishes.
The analysis depends only on the graph topology and not on any runtime value, so a single plan can be reused across every invocation of the same model. :cpp:func:
RuntimeContext::GetExecutionPlanbuilds and caches one plan per graph / function for that reason.Public Functions
-
ExecutionPlan() = default#
-
explicit ExecutionPlan(const GraphProto &graph)#
Builds the plan for
graph.keepis seeded with the graph’s declared inputs, initializers and declared outputs;releasableis computed by :cpp:func:RuntimeContext::ComputeReleasableInputs.
-
explicit ExecutionPlan(const FunctionProto &func)#
Builds the plan for
func.keepis seeded with the function’s declared inputs and outputs.
-
ExecutionPlan(const utils::RepeatedProtoField<NodeProto> &nodes, std::unordered_set<std::string> keep)#
Builds the plan for a free-standing node range.
keepis the user-supplied set of names that must never be released (typically the names already populated in the runtime context at run start plus any graph / function outputs).
-
inline const std::unordered_set<std::string> &keep() const noexcept#
Structural set of names that must never be released. See the class-level documentation for the exact contents.
-
inline const std::vector<std::vector<std::string>> &releasable() const noexcept#
For each node
iin the underlying node range, the list of names whose last reference falls atiand that are not in :cpp:func:keep.
-
inline size_t num_nodes() const noexcept#
Number of nodes covered by this plan (
releasable().size()).
-
void ReleaseAfter(const NodeProto &node, RuntimeContext &rt) const#
Releases from
rtevery name in thereleasable()slot associated withnode.nodemust be one of the :cpp:class:NodeProtoinstances the plan was built from (lookup is by address); if it is not, this is a no-op. Each removal is performed on both the tensor map and the sequence map: :cpp:func:RuntimeContext::Removeis a no-op if the name is absent and emits a :cpp:enumerator:RuntimeEventAction::kRemoveevent when event logging is on; sequence removals do not emit events (sequence values live outside the tensor event stream).
-
class RuntimeContext#
- #include <runtime_context.h>
Per-invocation runtime state passed to :cpp:func:
RunNode/ :cpp:func:RunNodes.Bundles together everything a chain of nodes needs to execute:
a :cpp:type:
TensorMapcarrying the graph inputs / initializers and every intermediate value produced by previously executed nodes (accessed through :cpp:func:tensors);the construction-time :cpp:class:
kernel::KernelContext(opset and any future construction-time inputs) used to instantiate each per-operator kernel (accessed through :cpp:func:kernel_ctx).
Grouping them in a single object keeps the dispatcher signatures stable as more per-invocation state (allocators, device descriptors, profiling hooks, …) is added in the future without forcing every trampoline or call site to take an extra argument.
Convenience accessors (:cpp:func:
Set, :cpp:func:Get, :cpp:func:Has, :cpp:func:Remove) wrap the underlying map so callers do not have to reach forrt.tensors()[name]directly.Public Functions
-
RuntimeContext() = default#
-
inline explicit RuntimeContext(kernel::KernelContext kernel_ctx)#
-
inline RuntimeContext(kernel::KernelContext kernel_ctx, TensorMap tensors)#
-
inline void set_events_enabled(bool enabled) noexcept#
Enables or disables event logging. When disabled (the default), :cpp:func:
Set, :cpp:func:Put, :cpp:func:Removeand :cpp:func:RunNodeskip all event construction, clock reads, and value decoding — eliminating the profiling overhead from the hot path. Callset_events_enabled(true)before running if per-node profiling is required.
-
inline bool events_enabled() const noexcept#
-
inline void set_verbose(int verbose) noexcept#
Verbosity level used by :cpp:func:
RunNodeto print execution progress tostdoutwhile the graph is running.0disables printing.
-
inline int verbose() const noexcept#
-
inline void set_current_subgraph(int64_t node_index, const std::string &attr_name)#
Index of the control-flow node in the parent graph currently being executed. Set before running a subgraph so that events recorded inside carry :cpp:var:
RuntimeEvent::subgraph_node_indexand :cpp:var:RuntimeEvent::subgraph_attr_name.-1for the top-level graph. Use :cpp:func:set_current_subgraphto update both the index and the attribute name atomically.
-
inline int64_t current_subgraph_node_index() const noexcept#
-
inline void set_current_node_index(int64_t index) noexcept#
Index of the node currently being executed, used to tag the :cpp:var:
RuntimeEvent::node_indexof intermediate / output tensors produced during its dispatch. Set by :cpp:func:RunNodesbefore each :cpp:func:RunNodecall and-1when no node is executing.
-
inline int64_t current_node_index() const noexcept#
-
inline kernel::KernelContext &kernel_ctx() noexcept#
Kernel construction context (opset).
-
inline const kernel::KernelContext &kernel_ctx() const noexcept#
-
inline FunctionMap &functions() noexcept#
Model-local function registry consulted by :cpp:func:
RunNodebefore falling back to the built-in kernel dispatch table.
-
inline const FunctionMap &functions() const noexcept#
-
inline CustomKernelMap &custom_kernels() noexcept#
User-provided custom kernel registry consulted by :cpp:func:
RunNodebefore the built-in :cpp:func:KernelDispatchTable. Keys are the canonical"<domain>:<op_type>"pair (the default ONNX domain — the emptyNodeProto::domain()— is normalised to"ai.onnx"). A custom registration overrides any built-in entry with the same key, but model-local functions and the built-in control-flow operators (If,Loop,Scan,SequenceMap) still take precedence.
-
inline const CustomKernelMap &custom_kernels() const noexcept#
-
inline void RegisterCustomKernel(const std::string &domain, const std::string &op_type, CustomKernelFn fn)#
Registers or replaces a custom kernel for
(domain, op_type). The empty domain is normalized to"ai.onnx".
-
inline bool UnregisterCustomKernel(const std::string &domain, const std::string &op_type)#
Removes the custom kernel registered for
(domain, op_type). The empty domain is normalised to"ai.onnx". Returnstruewhen an entry was removed,falseotherwise.
-
inline void ClearCustomKernels()#
Removes every registered custom kernel.
-
inline bool Has(const std::string &name) const#
Returns
trueif a tensor namednameis currently held.
-
bool Remove(const std::string &name)#
Removes the tensor stored under
nameif present. Returnstrueif an entry was erased,falseotherwise. When an entry is erased a :cpp:class:RuntimeEventwith action :cpp:enumerator:RuntimeEventAction::kRemoveis appended to the event log; nothing is logged whennameis not present.
-
void Set(const std::string &name, Tensor tensor, RuntimeEventKind kind = RuntimeEventKind::kInput)#
Inserts the tensor under
name. The name must not already be present in the map; use :cpp:func:Put(ortensors()directly) to overwrite. A :cpp:class:RuntimeEventwith action :cpp:enumerator:RuntimeEventAction::kAddand the suppliedkindis appended to the event log on successful insertion.kinddefaults to :cpp:enumerator:RuntimeEventKind::kInput, which is the typical role of values seeded by the caller before running.
-
void Put(const std::string &name, Tensor tensor, RuntimeEventKind kind = RuntimeEventKind::kIntermediate)#
Inserts or overwrites the tensor stored under
name. Appends a :cpp:class:RuntimeEventdescribing the new state with action :cpp:enumerator:RuntimeEventAction::kAddwhennamewas absent and :cpp:enumerator:RuntimeEventAction::kReplacewhen an existing entry was overwritten.kinddefaults to :cpp:enumerator:RuntimeEventKind::kIntermediate, the typical role of values written by node kernels through :cpp:func:SetOutput.
-
const Tensor &Get(const std::string &name) const#
Returns the tensor stored under
name.- Throws:
std::out_of_range – if
nameis not in the map.
-
inline const RuntimeEventLog &events() const noexcept#
Append-only log of every tensor map mutation performed through :cpp:func:
Set, :cpp:func:Putand :cpp:func:Remove. See :cpp:class:RuntimeEventfor the captured fields.
-
inline RuntimeEventLog &events() noexcept#
-
inline void ClearEvents() noexcept#
Empties the event log without otherwise touching the tensor map.
-
inline void Clear() noexcept#
Resets the per-invocation state so the context can be reused for a fresh run: clears the tensor map, the sequence map and the event log, and resets :cpp:func:
current_node_indexto-1. The kernel context, registered model-local functions and custom kernels, the cached :cpp:class:ExecutionPlaninstances and the :cpp:func:events_enabled/ :cpp:func:release_intermediatessettings are intentionally preserved, so the execution-plan cache is amortised across repeated runs of the same model.
-
void AppendRunNodeEvent(const std::string &op_domain, const std::string &op_type, std::vector<std::string> inputs, int64_t start_time_ns, int64_t duration_ns)#
Appends a :cpp:class:
RuntimeEventwith action :cpp:enumerator:RuntimeEventAction::kRunNodesummarising the dispatch of a singleNodeProto.timestamp_nsis set to the wall-clock time at which the dispatch started andduration_nsto its measured wall-clock duration in nanoseconds. Inserted by :cpp:func:RunNodefor every kernel call so callers can profile per-node execution from the event log alongside the tensor add/replace/remove records.
-
const ExecutionPlan &GetExecutionPlan(const GraphProto &graph)#
Returns the cached :cpp:class:
ExecutionPlanforgraph, building it on first use. The plan precomputes, for every node ingraph, the list of input names whose last reference falls at that node and that are not declared inputs / initializers / outputs ofgraph— i.e. the intermediates that may be removed from this context as soon as the node has finished executing. The plan is keyed by the address ofgraphand reused across subsequent runs of the same model, so the analysis is paid only once for the lifetime of this :cpp:class:RuntimeContext.
-
const ExecutionPlan &GetExecutionPlan(const FunctionProto &func)#
Returns the cached :cpp:class:
ExecutionPlanforfunc, building it on first use. Same caching semantics as the :cpp:class:GraphProtooverload — the structural keep set consists of the function’s declared inputs and outputs.
-
void ClearExecutionPlans() noexcept#
Clears every cached :cpp:class:
ExecutionPlan. Useful when the owning model has been mutated in place (rare).
-
inline void set_release_intermediates(bool enabled) noexcept#
Enables or disables the per-node release of unused intermediates performed by :cpp:func:
RunNodes/ :cpp:func:RunGraph/ :cpp:func:RunFunction/ :cpp:func:RunModel. When enabled, a name whose last reference (declared input of a node, or captured input of a subgraph attribute) appears at nodeiis removed from :cpp:func:tensors(and :cpp:func:sequences) right after nodeifinishes — emitting a :cpp:enumerator:RuntimeEventAction::kRemoveevent when event logging is on. Graph / function outputs are always preserved. Disabled by default to keep intermediate values observable after the run (e.g. so callers can fetch any node output by name).
-
inline bool release_intermediates() const noexcept#
-
inline SequenceMap &sequences() noexcept#
In/out sequence map shared across every node in a chain. Only sequence-typed graph edges are stored here; tensor-typed edges live in :cpp:func:
tensors.
-
inline const SequenceMap &sequences() const noexcept#
-
inline bool HasSequence(const std::string &name) const#
Returns
trueif a sequence namednameis currently held.
-
inline void PutSequence(const std::string &name, Sequence sequence)#
Inserts or overwrites the sequence stored under
name. The stored sequence’snamefield is updated toname. No event is appended to the event log: sequence values are intentionally outside the tensor event stream.
-
inline bool RemoveSequence(const std::string &name)#
Removes the sequence stored under
nameif present. Returnstrueif an entry was erased,falseotherwise.
-
inline const Sequence &GetSequence(const std::string &name) const#
Returns the sequence stored under
name.- Throws:
std::out_of_range – if
nameis not in the sequence map.
-
inline OnnxMapMap &maps() noexcept#
In/out map store shared across every node in a chain. Only map-typed graph edges are stored here; tensor-typed edges live in :cpp:func:
tensors.
-
inline const OnnxMapMap &maps() const noexcept#
-
inline bool HasMap(const std::string &name) const#
Returns
trueif a map namednameis currently held.
Public Static Functions
-
static std::vector<std::string> CollectExternalInputs(const utils::RepeatedProtoField<NodeProto> &nodes)#
Returns the list of input names referenced by
nodesthat are not produced as outputs by any node in the same list — i.e. the external dependencies of the node set.Subgraph attributes (
GRAPH/GRAPHS) are inspected recursively: for every subgraph, names read by the subgraph’s nodes that are neither produced inside the subgraph (formal inputs, initializers, intermediate node outputs) nor produced by the outernodesare appended to the result, mirroring the captured-value semantics of ONNX control-flow operators.The returned list preserves the order in which each external name is first encountered and contains no duplicates. Empty input names (optional inputs left unbound) are skipped.
-
static std::vector<std::string> CollectExternalInputs(const std::vector<NodeProto> &nodes)#
std::vector-overload of :cpp:func:CollectExternalInputs.
-
static std::vector<std::string> CollectNodeInputs(const NodeProto &node)#
Returns the full list of tensor / sequence names a single
nodedepends on at runtime.The result is the union of:
the names referenced by
node.input()(skipping empty optional-input slots), andevery external input of the subgraph attributes (
GRAPH/GRAPHS) attached tonode— i.e. the captured names a subgraph reads from the enclosing scope, as computed recursively by :cpp:func:CollectExternalInputs.
The returned list preserves the order in which each name is first encountered and contains no duplicates.
-
static std::vector<std::vector<std::string>> ComputeReleasableInputs(const utils::RepeatedProtoField<NodeProto> &nodes, const std::unordered_set<std::string> &keep)#
Returns, for each node in
nodes, the list of input names that become unused once that node has finished executing — i.e. names whose last reference (per :cpp:func:CollectNodeInputs) appears at that node and that do not appear inkeep.Empty names (optional inputs left unbound) are skipped. The returned vector has exactly
nodes.size()entries; each inner vector preserves the order in which the corresponding names were first encountered in the input list of the producing/consuming node.
Private Members
-
kernel::KernelContext kernel_ctx_#
-
FunctionMap functions_#
-
CustomKernelMap custom_kernels_#
-
RuntimeEventLog events_#
-
SequenceMap sequences_#
-
OnnxMapMap maps_#
-
bool events_enabled_ = false#
-
int verbose_ = 0#
-
bool release_intermediates_ = false#
-
int64_t current_node_index_ = -1#
-
int64_t current_subgraph_node_index_ = -1#
Index of the control-flow node in the parent graph currently being executed (see :cpp:func:
set_current_subgraph).-1for the top-level graph.
-
std::string current_subgraph_attr_name_#
Attribute name of the subgraph currently being executed (see :cpp:func:
set_current_subgraph). Empty for the top-level graph; set to"body","then_branch","else_branch", etc. when running a control-flow body subgraph.
-
std::unordered_map<const void*, ExecutionPlan> execution_plans_#
Lazily-populated cache of :cpp:class:
ExecutionPlaninstances keyed by the address of the :cpp:class:GraphProto/ :cpp:class:FunctionProtothey describe. Built on first use by :cpp:func:GetExecutionPlanand reused across subsequent runs of the same model.
-
struct RuntimeEvent#
- #include <runtime_context.h>
Single entry of the :cpp:class:
RuntimeContextevent log.Each mutation of the underlying
TensorMapperformed through :cpp:func:RuntimeContext::Set, :cpp:func:RuntimeContext::Putor :cpp:func:RuntimeContext::Removeproduces oneRuntimeEventcapturing the action, the role (kind), the name of the tensor, the wall-clock timestamp (nanoseconds since the Unix epoch), and a snapshot of the tensor’s type and shape.The element values are captured into a fixed-size buffer of :cpp:var:
kRuntimeEventValueLimitentries (valuesfor numeric dtypes,string_valuesforDataType::STRING);value_countrecords how many slots are populated (min(element_count, kRuntimeEventValueLimit)). When the tensor has more than :cpp:var:kRuntimeEventValueLimitelements the buffer holds only the firstkRuntimeEventValueLimitvalues (the remainder is truncated),data_typeis set to-1to signal the truncation andshapeis left empty.kRemoveevents always setdata_type = DataType::UNDEFINED,value_count = 0, leaveshapeempty and do not populatevalues/string_values; they only record the name, kind and timestamp of the removal.Public Members
-
RuntimeEventAction action = RuntimeEventAction::kAdd#
Kind of mutation recorded by this entry.
-
RuntimeEventKind kind = RuntimeEventKind::kUnknown#
Role of the tensor at the moment of the event (see :cpp:enum:
RuntimeEventKind).
-
int64_t timestamp_ns = 0#
Wall-clock timestamp of the event, in nanoseconds since the Unix epoch (
std::chrono::system_clock).
-
std::string name#
Name under which the tensor is (or was) stored in the :cpp:class:
RuntimeContexttensor map.
-
int32_t data_type = 0#
Element data type of the tensor at the moment of the event, encoded as a
TensorProto::DataTypeinteger value. Set toDataType::UNDEFINEDforkRemoveevents, and to-1forkAdd/kReplaceevents whose tensor has more than :cpp:var:kRuntimeEventValueLimitelements (the values buffer is then truncated to the firstkRuntimeEventValueLimitentries andshapeis left empty).
-
std::vector<int64_t> shape#
Tensor shape at the moment of the event. Empty for
kRemove, for scalar tensors (element_count == 1), and forkAdd/kReplaceevents whose tensor exceeds :cpp:var:kRuntimeEventValueLimitelements (truncated payload).
-
int32_t value_count = 0#
Number of populated entries in
values/string_values(min(element_count, kRuntimeEventValueLimit)). Zero forkRemoveevents.
-
std::array<double, kRuntimeEventValueLimit> values = {}#
Fixed-size buffer holding the first
value_countnumeric values of the tensor (coerced todouble). Boolean values are recorded as0.0/1.0. Unused slots are zero-initialised. Always empty forDataType::STRINGandkRemoveevents.
-
std::array<std::string, kRuntimeEventValueLimit> string_values = {}#
Fixed-size buffer holding the first
value_countstring values of the tensor whendata_typeisDataType::STRING. Unused slots are empty strings.
-
std::string op_domain#
For
kRunNodeevents: ONNX op domain of the node that was dispatched, normalised so the default domain is reported as"ai.onnx". Empty for all other event actions.
-
std::string op_type#
For
kRunNodeevents: ONNXop_typeof the node that was dispatched. Empty for all other event actions.
-
std::vector<std::string> inputs#
For
kRunNodeevents: ordered list of input names consumed by the node, matchingNodeProto::input. Empty for all other event actions.
-
int64_t duration_ns = 0#
For
kRunNodeevents: wall-clock duration of the kernel dispatch in nanoseconds (std::chrono::steady_clock). Zero for all other event actions.
-
int64_t node_index = -1#
Index of the node this event is associated with. For :cpp:enumerator:
RuntimeEventKind::kInputvalues it is-1and for :cpp:enumerator:RuntimeEventKind::kInitializervalues it is-2. For intermediate / output tensors and forkRunNodeevents it is the position (>= 0) of the producing / dispatched node in its graph (or function / subgraph) node list.-1when no producing node is known.
-
int32_t device = -1#
Device the tensor lives on at the moment of the event:
-1for the CPU and0–8192for a GPU device index. The CPU reference runtime always reports-1.
-
int64_t subgraph_node_index = -1#
Index of the control-flow node in the parent graph whose attribute subgraph produced this event.
-1for events from the top-level graph. Combined with :cpp:var:subgraph_attr_namethis uniquely identifies which operator and which attribute subgraph an event originated from.
-
RuntimeEventAction action = RuntimeEventAction::kAdd#
-
using TensorMap = std::unordered_map<std::string, Tensor>#
-
namespace onnx_kernels