---
title: 函数：set_tensor_origin_shape
description: "| C函数原型 | aclError aclSetTensorOriginShape(aclTensorDesc \\*desc, int numDims, const int64\\_t \\*dims) |"
url: "https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application%20Development%20Guide/aadgp/aclpythondevg_01_0036.html"
---

# 函数：set_tensor_origin_shape

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