SetAttr
产品支持情况
头文件/库文件
- 头文件:#include <graph/gnode.h>
- 库文件:libgraph.so
功能说明
设置Node属性的属性值。
Node可以包括多个属性,初次设置值后,算子属性值的类型固定,算子属性值的类型包括:
-
整型:接受int64_t、uint32_t、int32_t类型的整型值
使用SetAttr(const AscendString& name, int64_t &attrValue)设置属性值,以GetAttr(const AscendString& name, int32_t &attrValue) 、GetAttr(const AscendString& name, uint32_t &attrValue)取值时,用户需保证整型数据没有截断,同理针对int32_t和uint32_t混用时需要保证不被截断。
-
整型列表:接受std::vector<int64_t>、std::vector<int32_t>、std::vector<uint32_t>表示的整型列表数据
-
浮点数:float
-
浮点数列表:std::vector<float>
-
字符串:AscendString
-
字符串列表:std::vector<AscendString>
-
布尔:bool
-
布尔列表:std::vector<bool>
-
Tensor:Tensor
-
Tensor列表:std::vector<Tensor>
-
OpBytes:字节数组,vector<uint8_t>
-
AttrValue类型
-
整型二维列表类型:std::vector<std::vector<int64_t>
-
DataType列表类型:vectorge::DataType\
-
DataType类型:DataType
函数原型
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
参数说明
属性名称。可设置的属性名请参见属性名列表。 |
||
返回值说明
约束说明
无
调用示例
gNode node;
node.SetAttr(_op_exec_never_timeout,true);