---
title: GetDataType
description: "获取Tensor的数据类型。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00744.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00744.html
indexId: a64dfbb226e83077b934f75bc2a13f9b59062cf8751181f8d2af855bbec02a6578
---
# GetDataType

#### 函数功能

获取Tensor的数据类型。


#### 函数原型

```
ge::DataType GetDataType() const
```


#### 参数说明

无。


#### 返回值说明

返回Tensor中的数据类型。

关于ge::DataType的定义，请参见DataType。


#### 约束说明

无。


#### 调用示例

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