目录

SetAttr

Function Description

Sets the value of an operator attribute.

An operator may have multiple attributes. Once the value of an attribute is initially set, the data type of the attribute is fixed. The following data types are supported:

Function Prototype

APIs taking string arguments will be deprecated in future releases. Use APIs taking non-string arguments instead.

Operator &SetAttr(const std::string &name, int64_t attr_value);
Operator &SetAttr(const std::string &name, int32_t attr_value);
Operator &SetAttr(const std::string &name, uint32_t attr_value);
Operator &SetAttr(const std::string &name, const std::vector<int64_t> &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<int32_t> &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<uint32_t> &attr_value);
Operator &SetAttr(const std::string &name, std::initializer_list<int64_t> &&attr_value);
Operator &SetAttr(const std::string &name, float32_t attr_value);
Operator &SetAttr(const std::string &name, const std::vector<float32_t> &attr_value);
Operator &SetAttr(const std::string &name, AttrValue &&attr_value);
Operator &SetAttr(const std::string &name, const std::string &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<std::string> &attr_value);
Operator &SetAttr(const std::string &name, bool attr_value);
Operator &SetAttr(const std::string &name, const std::vector<bool> &attr_value);
Operator &SetAttr(const std::string &name, const Tensor &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<Tensor> &attr_value);
Operator &SetAttr(const std::string &name, const OpBytes &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<std::vector<int64_t>> &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<ge::DataType> &attr_value);
Operator &SetAttr(const std::string &name, const ge::DataType &attr_value);
Operator &SetAttr(const std::string &name, const ge::NamedAttrs &attr_value);
Operator &SetAttr(const std::string &name, const std::vector<ge::NamedAttrs> &attr_value);
Operator &SetAttr(const char_t *name, int64_t attr_value);
Operator &SetAttr(const char_t *name, int32_t attr_value);
Operator &SetAttr(const char_t *name, uint32_t attr_value);
Operator &SetAttr(const char_t *name, const std::vector<int64_t> &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<int32_t> &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<uint32_t> &attr_value);
Operator &SetAttr(const char_t *name, std::initializer_list<int64_t> &&attr_value);
Operator &SetAttr(const char_t *name, float32_t attr_value);
Operator &SetAttr(const char_t *name, const std::vector<float32_t> &attr_value);
Operator &SetAttr(const char_t *name, AttrValue &&attr_value);
Operator &SetAttr(const char_t *name, const char_t *attr_value);
Operator &SetAttr(const char_t *name, const AscendString &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<AscendString> &attr_values);
Operator &SetAttr(const char_t *name, bool attr_value);
Operator &SetAttr(const char_t *name, const std::vector<bool> &attr_value);
Operator &SetAttr(const char_t *name, const Tensor &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<Tensor> &attr_value);
Operator &SetAttr(const char_t *name, const OpBytes &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<std::vector<int64_t>> &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<ge::DataType> &attr_value);
Operator &SetAttr(const char_t *name, const ge::DataType &attr_value);
Operator &SetAttr(const char_t *name, const ge::NamedAttrs &attr_value);
Operator &SetAttr(const char_t *name, const std::vector<ge::NamedAttrs> &attr_value);

Parameters

Parameter Input/Output Description
name Input Attribute name.
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 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 std::initializer_list[/topic/body/section/table/tgroup/tbody/row/entry/b/int64_t {""}) && (int64_t].
attr_value Input Attribute value of the floating-point type.
attr_value Input Attribute value of the floating-point list type.
attr_value Input Attribute value of the bool type.
attr_value Input Attribute value of the bool list type.
attr_value Input Attribute value of type AttrValue.
attr_value Input Attribute value of the string type.
attr_value Input Attribute value of the string list type.
attr_value Input Attribute value of type Tensor.
attr_value Input Attribute value of the tensor list type.
attr_value Input Attribute value of type OpBytes, or vector[/topic/body/section/table/tgroup/tbody/row/entry/b/uint8_t {""}) (uint8_t].
attr_value Input Attribute value of the quantized data type.
attr_value Input Attribute value of type vector<vector[/topic/body/section/table/tgroup/tbody/row/entry/b/int64_t {""}) > (int64_t].
attr_value Input Attribute value of type vectorge::DataType.
attr_value Input Attribute value of type DataType.
attr_value Input Attribute value of type NamedAttrs.
attr_value Input Attribute value of type vectorge::NamedAttrs.

Return Value

Type Description
Operator& Object itself.

Exception Handling

None

Restrictions

None