---
title: GetShape
description: "获取Tensor的Shape，包含运行时和原始Shape。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00751.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00751.html
indexId: e63fc0062ca27f438ada03c2ba08ee2e99d540863ffba0df7892c0475d98b92a78
---
# GetShape

#### 函数功能

获取Tensor的Shape，包含运行时和原始Shape。


#### 函数原型

```
const StorageShape &GetShape() const
StorageShape &GetShape()
```


#### 参数说明

无。


#### 返回值说明

- const StorageShape &GetShape() const：返回只读的Shape引用。
- StorageShape &GetShape()：返回Shape引用。
- 关于StorageShape类型的定义，请参见  StorageShape
。


#### 约束说明

无。


#### 调用示例

```
StorageShape sh({1, 2, 3}, {2, 1, 3});
TensorV2 t = {sh, {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}}, kOnHost, ge::DT_FLOAT, nullptr};
auto shape = t.GetShape(); // sh
```
