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

#### 产品支持情况

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


#### 头文件/库文件

- 头文件：#include <ge/ge_api.h>
- 库文件：libge_runner.so


#### 功能说明

变量查询接口，获取Session内所有variable算子或指定variable算子的Tensor内容。


#### 函数原型

数据类型为string的接口后续版本会废弃，建议使用数据类型为非string的接口。


```
Status GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values)
Status GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| var\_names | 输入 | variable算子的名字，为空时返回所有variable类型算子的值。 |
| var\_values | 输出 | variable算子的值，按照tensor格式返回；与var\_names保持一致序列。 |


#### 返回值说明

| 参数名 | 类型 | 说明 |
| --- | --- | --- |
| \- | Status | SUCCESS：成功 其他：不存在该name的variable算子；variable未执行初始化等场景。 |


#### 约束说明

无
