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

#### 产品支持情况

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


#### 功能说明

创建变量张量。


#### 函数原型

```
create_variable(index: int, name: str) -> TensorHolder
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| index | 输入 | 变量索引。 |
| name | 输入 | 变量名称。 |


#### 返回值说明

(TensorHolder)表示变量的张量持有者。


#### 约束说明

- 如果参数类型不正确，抛出TypeError。
- 如果变量创建失败，抛出RuntimeError。
