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

#### 函数功能

获取Tensor的数据类型。


#### 函数原型

ge::DataType GetDataType() const


#### 参数说明

无。


#### 返回值说明

返回Tensor中的数据类型。

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


#### 约束说明

无。


#### 调用示例

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