SetAttr

Applicability

Product

Supported or Not

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Header File/Library File

  • Header file: #include <graph/gnode.h>
  • Library file: libgraph.so

Function Usage

Sets attribute values of a node.

A node may have multiple attributes. After an attribute value is set for the first time, the data type of the attribute is fixed. The following data types are supported:

  • Integer: int64_t, uint32_t, and int32_t

    Use SetAttr(const AscendString& name, int64_t &attrValue) to set the attribute value, and use GetAttr(const AscendString& name, int32_t& attrValue) or GetAttr(const AscendString& name, uint32_t& attrValue) to obtain the value. Ensure that the integer data is not truncated. It is the same for the types int32_t and uint32_t.

  • Integer list: std::vector<int64_t>, std::vector<int32_t>, and std::vector<uint32_t>
  • Floating-point number: float
  • Floating-point number list: std::vector<float>
  • String: AscendString
  • String list: std::vector<AscendString>
  • Bool: bool
  • Bool list: std::vector<bool>
  • Tensor: Tensor
  • Tensor list: std::vector<Tensor>
  • OpBytes: vector<uint8_t>
  • AttrValue: AttrValue
  • 2D list of integers: std::vector<std::vector<int64_t>
  • List of DataTypes: vector<ge::DataType>
  • DataType: DataType

Prototype

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
graphStatus SetAttr(const AscendString &name, int64_t &attr_value) const
graphStatus SetAttr(const AscendString &name, int32_t &attr_value) const
graphStatus SetAttr(const AscendString &name, uint32_t &attr_value) const
graphStatus SetAttr(const AscendString &name, float32_t &attr_value) const
graphStatus SetAttr(const AscendString &name, AscendString &attr_value) const
graphStatus SetAttr(const AscendString &name, bool &attr_value) const
graphStatus SetAttr(const AscendString &name, Tensor &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<int64_t> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<int32_t> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<uint32_t> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<float32_t> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const
graphStatus SetAttr(const AscendString &name, std::vector<bool> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<Tensor> &attr_value) const
graphStatus SetAttr(const AscendString &name, OpBytes &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const
graphStatus SetAttr(const AscendString &name, std::vector<ge::DataType> &attr_value) const
graphStatus SetAttr(const AscendString &name, ge::DataType &attr_value) const
graphStatus SetAttr(const AscendString &name, AttrValue &attr_value) const

Parameters

Parameter

Input/Output

Description

name

Input

Attribute name. For details about the attribute names that can be set, see Attribute Name List.

attr_value

Input

Attribute value of type int64_t.

attr_value

Input

Attribute value of type int32_t.

attr_value

Input

Attribute value of type uint32_t.

attr_value

Input

Attribute value of type float.

attr_value

Input

Attribute value of type AscendString.

attr_value

Input

Attribute value of type bool.

attr_value

Input

Attribute value of type Tensor.

attr_value

Input

Attribute value of type vector<int64_t>.

attr_value

Input

Attribute value of type vector<int32_t>.

attr_value

Input

Attribute value of type vector<uint32_t>.

attr_value

Input

Attribute value of type vector<float>.

attr_value

Input

Attribute value of type vector<ge::AscendString>.

attr_value

Input

Attribute value of type vector<bool>.

attr_value

Input

Attribute value of type vector<Tensor>.

attr_value

Input

Bytes attribute value of type OpBytes, or vector<uint8_t>.

attr_value

Input

Attribute value of type vector<vector<int64_t>>.

attr_value

Input

Attribute value of type vector<ge::DataType> for DataType.

attr_value

Input

Attribute value of type DataType.

attr_value

Input

Attribute value of type AttrValue.

Returns

Parameter

Type

Description

-

graphStatus

GRAPH_SUCCESS(0): success.

Other values: failure.

Constraints

None

Examples

1
2
gNode node;
node.SetAttr(_op_exec_never_timeout,true);