---
title: 函数：set_tensor_origin_shape
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_0037.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_0037.html
indexId: 2dcfb8328688c06db689a6c624a3d5bbf3237e0d3b91d32cdb5d50d1805f630575
---
# 函数：set_tensor_origin_shape

#### 产品支持情况

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


#### 功能说明

调用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用于内部计算。


#### 函数原型

- C函数原型
  1 aclError aclSetTensorOriginShape(aclTensorDesc *desc, int numDims, const int64_t *dims)

- python函数
  1 ret = acl.set_tensor_origin_shape(desc, dims)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| desc | int，Tensor描述数据的指针地址。 需提前调用acl.create\_tensor\_desc接口创建aclTensorDesc类型。 |
| dims | list，待设置的维度。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码。 返回0表示成功。 返回其它值(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0911.html)表示失败。 |
