node_helpers.h#

Small helpers shared by the dispatcher (run_nodes.cc) and the kernel dispatch table (kernel_dispatch_table.cc).

The helpers normalise the default ONNX domain, validate input/output arity declared on a NodeProto, look up tensors by name in a RuntimeContext and read the most common attribute types (INT, INTS, FLOAT, STRING). Their definitions live in node_helpers.cc (part of lib_onnx_core).

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

Functions

const Tensor &GetInput(const NodeProto &node, int index, const TensorMap &tensors)#
const Tensor *GetOptionalInput(const NodeProto &node, int index, const TensorMap &tensors)#
void SetOutput(const NodeProto &node, int index, Tensor result, TensorMap &tensors)#
void SetOutput(const NodeProto &node, int index, Tensor result, RuntimeContext &rt)#
const Sequence &GetInputSequence(const NodeProto &node, int index, const RuntimeContext &rt)#
void SetOutputSequence(const NodeProto &node, int index, Sequence result, RuntimeContext &rt)#
void RequireInputCount(const NodeProto &node, int expected)#
void RequireMinInputCount(const NodeProto &node, int min_expected)#
void RequireOutputCount(const NodeProto &node, int expected)#
const AttributeProto *FindAttribute(const NodeProto &node, std::string_view name)#
const GraphProto &GetRequiredGraphAttribute(const NodeProto &node, std::string_view name)#
int64_t GetAttributeIntOrDefault(const NodeProto &node, const std::string &name, int64_t fallback)#
ParamInts GetAttributeIntsOrDefault(const NodeProto &node, const std::string &name, const std::vector<int64_t> &fallback)#
Shape GetAttributeShapeOrDefault(const NodeProto &node, const std::string &name, const Shape &fallback)#

Reads the repeated INTS attribute name of node and returns it as a Shape. When the attribute is absent, fallback is returned unchanged. Throws when the attribute exists but has a type other than INTS.

ParamFloats GetAttributeFloatsOrDefault(const NodeProto &node, const std::string &name, const std::vector<float> &fallback)#
ParamStrings GetAttributeStringsOrDefault(const NodeProto &node, const std::string &name, const std::vector<std::string> &fallback)#
float GetAttributeFloatOrDefault(const NodeProto &node, const std::string &name, float fallback)#
std::string GetAttributeStringOrDefault(const NodeProto &node, const std::string &name, const std::string &fallback)#
std::string GetRequiredAttributeString(const NodeProto &node, const std::string &name)#
int64_t GetRequiredAttributeInt(const NodeProto &node, const std::string &name)#
class ParamFloats : public std::vector<float>#
#include <node_helpers.h>

Vector-like wrapper for the value returned by :func:GetAttributeFloatsOrDefault.

Public Functions

ParamFloats() = default#
inline ParamFloats(const std::vector<float> &values)#
inline ParamFloats(std::vector<float> &&values)#
class ParamInts : public std::vector<int64_t>#
#include <node_helpers.h>

Vector-like wrapper for the value returned by :func:GetAttributeIntsOrDefault.

Public Functions

ParamInts() = default#
inline ParamInts(const std::vector<int64_t> &values)#
inline ParamInts(std::vector<int64_t> &&values)#
class ParamStrings : public std::vector<std::string>#
#include <node_helpers.h>

Vector-like wrapper for the value returned by :func:GetAttributeStringsOrDefault.

Public Functions

ParamStrings() = default#
inline ParamStrings(const std::vector<std::string> &values)#
inline ParamStrings(std::vector<std::string> &&values)#