---
title: GetShape接口
description: "获取张量对象shape。"
url: https://www.hiascend.com/document/detail/zh/mindie/latest/mindiellm/llmdev/mindie_llm0105.html
sourcePath: /source/zh/mindie/310/mindiellm/llmdev/mindie_llm0105.html
indexId: 0ac4381b31b71b766f58da4c10575db1102b17bd6e3b59878ca9ecb152ef71e858
---
# GetShape接口

#### 接口功能

获取张量对象shape。


#### 接口格式

```
const std::vector<int64_t> &GetShape() const
```


#### 接口参数

无。


#### 使用样例

构造一个名为"INPUT_IDS"，数据类型为INT64，数据维度为{1，2}的Tensor对象，然后获取shape信息。

```
std::string name = "INPUT_IDS";
mindie_llm::InferDataType dataType = mindie_llm::InferDataType::TYPE_INT64;
std::vector<int64_t> dataShape = {1, 2};
auto inputsTensor = std::make_shared<mindie_llm::InferTensor>(name, dataType, dataShape);
std::vector<int64_t> shape = inputsTensor->GetShape();
```


#### 返回值

tensor的数据维度，类型为vector<int64_t>。
