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

#### 产品支持情况

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


#### 功能说明

设置张量数据类型。


#### 函数原型

```
set_data_type(data_type: DataType) -> TensorHolder
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| data\_type | 输入 | 数据类型枚举。详见DataType。 |


#### 返回值说明

(TensorHolder) 返回自身以支持链式调用。


#### 约束说明

- 如果data_type不是DataType枚举，抛出TypeError。
- 如果操作失败，抛出RuntimeError。
