---
title: GetData
description: "获取Tensor的数据地址。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00198.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00198.html
indexId: 7c69df13a38f778537558b6587751c5cec2be791ee78e3f0eaf7fe58fd91c61978
---
# GetData

#### 函数功能

获取Tensor的数据地址。


#### 函数原型

```
template<class T>  const T *GetData() const
template<class T>  auto GetData() -> T*
```


#### 参数说明

| 参数 | 输入/输出 | 说明 |
| --- | --- | --- |
| T | 输入 | 数据类型。 |


#### 返回值说明

数据地址。


#### 约束说明

无。


#### 调用示例

```
Tensor tensor{{{8, 3, 224, 224}, {16, 3, 224, 224}},       // shape                
              {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}},  // format                              
              kFollowing,                                  // placement                
              ge::DT_FLOAT16,                              //dt                
              nullptr};
auto addr = tensor.GetData<int64_t>(); // reinterpret_cast<int64_t *>(&tensor + 1)
```
