---
title: 函数：set_tensor_origin_format
description: "| C函数原型 | aclError aclSetTensorOriginFormat(aclTensorDesc \*desc, aclFormat format) |"
url: https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/latest/Application%20Development%20Guide/aadgp/aclpythondevg_01_0037.html
sourcePath: /source/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application Development Guide/aadgp/aclpythondevg_01_0037.html
indexId: dc4838c189ad5c8bc169c47778026b9b4a95b0bc79dbd0b481df68e931eaa145108
---
# 函数：set_tensor_origin_format

| C函数原型 | aclError aclSetTensorOriginFormat(aclTensorDesc \*desc, aclFormat format) |
| --- | --- |
| Python函数 | ret = acl.set\_tensor\_origin\_format(desc, format) |
| 函数功能 | 调用acl.create\_tensor\_desc接口创建Tensor描述信息后，可通过acl.set\_tensor\_origin\_format设置Tensor的原始Format信息，当前主要用于PyTorch场景下，同步接口。 说明： 例如，某算子的原始Format为NHWC（原始Shape为4维）或者NDHWC（原始Shape为5维），为了提高数据访问效率，在进行模型转换或者在线构建网络时会自动转换Format，将原始数据Format转化为昇腾AI处理器内部计算数据时用的Format（NC1HWC0或者NDC1HWC0），同时进行推导Shape用于内部计算。 |
| 输入说明 | desc：int，Tensor描述数据的指针地址。 format：int， 指定Tensor描述的格式。 |
| 返回值说明 | ret：int，错误码。 返回0表示成功。 返回其它值表示失败。 |
| 约束说明 | 无 |
