---
title: 简介
description: "Shape结构体用于描述一个tensor的shape，包含两个信息："
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00150.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00150.html
indexId: 77b497577a71604350a3497854654b25c11cba634ccb9d0ceb2cf121068631c378
---
# 简介

Shape结构体用于描述一个tensor的shape，包含两个信息：

```
size_t dim_num_;
int64_t dims_[kMaxDimNum];
```

其中，dim_num_表示shape的维数，dims_数组表示tensor具体的shape。

```
size_t kMaxDimNum = 25;
```

kMaxDimNum表示能支持的最大维度数（此数值为最大可支持规格，具体支持情况以实际算子为准）。

#### 需要包含的头文件

```
#include <shape.h>
```


#### Public成员函数

```
Shape
() : dim_num_(0), dims_{0}
Shape
(const std::initializer_list<int64_t> &args) :
Shape
()
Shape
(const
Shape
&other)
Shape
&
operator=
(const
Shape
&other)
bool
operator==
(const
Shape
&rht) const
bool
operator!=
(const
Shape
&rht) const
const int64_t &
operator[]
(const size_t idx) const
int64_t &
operator[]
(const size_t idx)
int64_t
GetShapeSize
() const
bool
IsScalar
() const
void
SetScalar
()
size_t
GetDimNum
() const
void
SetDimNum
(const size_t dim_num)
int64_t
GetDim
(const size_t idx) const
void
SetDim
(size_t idx, const int64_t dim_value)
Shape
&
AppendDim
(const int64_t value)
```
