SetAttr
产品支持情况
头文件和库文件
- 头文件:#include <graph/operator.h>
- 库文件:libgraph.so
功能说明
设置算子属性的属性值。
算子可以包括多个属性,初次设置值后,算子属性值的类型固定,算子属性值的类型包括:
-
整型:接受int64_t、uint32_t、int32_t类型的整型值
使用SetAttr(const string& name, int64_t attrValue)设置属性值,以GetAttr(const string& name, int32_t& attrValue) 、GetAttr(const string& name, uint32_t& attrValue) 取值时,用户需保证整型数据没有截断,同理针对int32_t和uint32_t混用时需要保证不被截断。
-
整型列表:接受std::vector<int64_t>、std::vector<int32_t>、std::vector<uint32_t>、std::initializer_list<int64_t>&&表示的整型列表数据
-
浮点数:float
-
浮点数列表:std::vector<float>
-
字符串:string
-
字符串列表:std::vectorstd::string\
-
布尔:bool
-
布尔列表:std::vector<bool>
-
Tensor:Tensor
-
Tensor列表:std::vector<Tensor>
-
Bytes:字节数组,SetAttr接受通过OpBytes(即vector<uint8_t>),和(const uint8_t* data, size_t size)表示的字节数组
-
AttrValue类型
-
整型二维列表类型:std::vector<std::vector<int64_t>>
-
DataType列表类型:std::vectorge::DataType\
-
DataType类型:ge::DataType
-
NamedAttrs类型: ge::NamedAttrs
-
NamedAttrs列表类型:std::vectorge::NamedAttrs\
函数原型
说明
数据类型为string的接口后续版本会废弃,建议使用数据类型为非string的接口。
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)
参数说明
返回值说明
Operator对象本身。
异常处理
无。
约束说明
无。