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

#### 产品支持情况

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


#### 功能说明

设置张量格式。


#### 函数原型

```
set_format(format: Format) -> Tensor
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| format | 输入 | 要设置的格式。详细格式请参见Format。 |


#### 返回值说明

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


#### 约束说明

- 如果format不是Format类型，抛出TypeError。
- 如果设置失败，抛出RuntimeError。
