attr_proto_util.h#
Attribute construction helpers for ONNX nodes, including
onnx_light::MakeAttribute() overloads and
onnx_light::MakeRefAttribute() helpers for function-body references.
Declares helpers to construct ONNX AttributeProto instances.
This header provides overloads for building typed attributes and helper utilities to create reference attributes used in function-body nodes.
-
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.Functions
-
AttributeProto MakeAttribute(std::string attr_name, float value)#
Creates a FLOAT attribute with the provided value.
- Parameters:
attr_name – The name of the attribute.
value – The floating-point value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, int64_t value)#
Creates an INT attribute with a 64-bit integer value.
- Parameters:
attr_name – The name of the attribute.
value – The 64-bit integer value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, int value)#
Creates an INT attribute with a 32-bit integer value (converted to int64_t).
- Parameters:
attr_name – The name of the attribute.
value – The 32-bit integer value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::string value)#
Creates a STRING attribute with the provided UTF-8 text value.
- Parameters:
attr_name – The name of the attribute.
value – The string value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, TensorProto value)#
Creates a TENSOR attribute with an inline tensor value.
- Parameters:
attr_name – The name of the attribute.
value – The tensor value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, GraphProto value)#
Creates a GRAPH attribute with a subgraph value.
- Parameters:
attr_name – The name of the attribute.
value – The graph value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, TypeProto value)#
Creates a TYPE_PROTO attribute with a type description value.
- Parameters:
attr_name – The name of the attribute.
value – The type-proto value assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<float> values)#
Creates a FLOATS attribute from a list of floating-point values.
- Parameters:
attr_name – The name of the attribute.
values – The list of floating-point values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<int64_t> values)#
Creates an INTS attribute from a list of 64-bit integers.
- Parameters:
attr_name – The name of the attribute.
values – The list of 64-bit integer values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<std::string> values)#
Creates a STRINGS attribute from a list of string values.
- Parameters:
attr_name – The name of the attribute.
values – The list of string values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<TensorProto> values)#
Creates a TENSORS attribute from a list of tensor values.
- Parameters:
attr_name – The name of the attribute.
values – The list of tensor values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<GraphProto> values)#
Creates a GRAPHS attribute from a list of graph values.
- Parameters:
attr_name – The name of the attribute.
values – The list of graph values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, std::vector<TypeProto> values)#
Creates a TYPE_PROTOS attribute from a list of type description values.
- Parameters:
attr_name – The name of the attribute.
values – The list of type-proto values assigned to the attribute.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeRefAttribute(const std::string &attr_name, AttributeProto::AttributeType type)#
Creates a reference attribute for a node in a function body.
- Parameters:
attr_name – The attribute name used by both function and function-body nodes.
type – The declared ONNX attribute kind for the reference.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeRefAttribute(const std::string &attr_name, const std::string &referred_attr_name, AttributeProto::AttributeType type)#
Creates a reference attribute for a node in a function body.
- Parameters:
attr_name – The attribute name used by the function-body node.
referred_attr_name – The attribute name on the surrounding function node to reference.
type – The declared ONNX attribute kind for the reference.
- Returns:
The constructed AttributeProto instance.
-
AttributeProto MakeAttribute(std::string attr_name, float value)#