---
title: SetInputAttr
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0660.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0660.html
indexId: c300d1c912d980744ac0bc66926f04371b8cdcc616df9800a4e4ddbefb54b0ef72
---
# SetInputAttr

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 头文件和库文件

- 头文件：#include <graph/operator.h>
- 库文件：libgraph.so


#### 功能说明

设置算子输入Tensor属性的属性值。

算子可以包括多个属性，初次设置值后，算子属性值的类型固定，算子属性值的类型包括：

- 整型：接受int64_t、uint32_t、int32_t类型的整型值
  以int64_t为例，使用:

  SetInputAttr(const char_t *dst_name, const char_t *name, int64_t attr_value);

  SetInputAttr(const int32_t index, const char_t *name, int64_t attr_value);

  设置属性值，以:

  GetInputAttr(const int32_t index, const char_t *name, int64_t &attr_value) const;

  GetInputAttr(const char_t *dst_name, const char_t *name, int64_t &attr_value) const

  取值时，用户需保证整型数据没有截断，同理针对int32_t和uint32_t混用时需要保证不被截断。

- 整型列表：接受std::vector<int64_t>、std::vector<int32_t>、std::vector<uint32_t>、std::initializer_list<int64_t>&&表示的整型列表数据
- 浮点数：float32_t
- 浮点数列表：std::vector<float32_t>
- 字符串：string
- 布尔：bool
- 布尔列表：std::vector<bool>


#### 函数原型

```
Operator &SetInputAttr(const int32_t index, const char_t *name, const char_t *attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const char_t *attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const AscendString &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const AscendString &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, int64_t attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, int64_t attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, int32_t attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, int32_t attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, uint32_t attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, uint32_t attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, bool attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, bool attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, float32_t attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, float32_t attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<AscendString> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<AscendString> &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<int64_t> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<int64_t> &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<int32_t> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<int32_t> &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<uint32_t> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<uint32_t> &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<bool> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<bool> &attr_value)
Operator &SetInputAttr(const int32_t index, const char_t *name, const std::vector<float32_t> &attr_value)
Operator &SetInputAttr(const char_t *dst_name, const char_t *name, const std::vector<float32_t> &attr_value)
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| name | 输入 | 属性名称。 |
| index | 输入 | 输入索引。 |
| dst\_name | 输入 | 输入边名称。 |
| attr\_value | 输入 | 需设置的int64\_t表示的整型类型属性值。 |
| attr\_value | 输入 | 需设置的int32\_t表示的整型类型属性值。 |
| attr\_value | 输入 | 需设置的uint32\_t表示的整型类型属性值。 |
| attr\_value | 输入 | 需设置的vector<int64\_t>表示的整型列表类型属性值。 |
| attr\_value | 输入 | 需设置的vector<int32\_t>表示的整型列表类型属性值。 |
| attr\_value | 输入 | 需设置的vector<uint32\_t>表示的整型列表类型属性值。 |
| attr\_value | 输入 | 需设置的浮点类型的属性值。 |
| attr\_value | 输入 | 需设置的浮点列表类型的属性值。 |
| attr\_value | 输入 | 需设置的布尔类型的属性值。 |
| attr\_value | 输入 | 需设置的布尔列表类型的属性值。 |
| attr\_value | 输入 | 需设置的字符串类型的属性值。 |
| attr\_value | 输入 | 需设置的字符串列表类型的属性值。 |


#### 返回值说明

Operator对象本身。


#### 异常处理

无。


#### 约束说明

无。
