attr_proto_util.h#

Attribute construction helpers for ONNX nodes, including onnx::MakeAttribute() overloads and onnx::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_NAMESPACE

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.