---
title: GetDataType
description: "获取CompileTimeTensorDesc所描述的Tensor的数据类型。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00012.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00012.html
indexId: 962c0dbfbe5ff226d6eab334e2c41a63585fc48013e0af9df1f7a762f905790878
---
# GetDataType

#### 函数功能

获取CompileTimeTensorDesc所描述的Tensor的数据类型。


#### 函数原型

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


#### 参数说明

无。


#### 返回值说明

返回Tensor的数据类型。

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


#### 约束说明

无。


#### 调用示例

```
auto dtype_ = ge::DataType::DT_INT32;
StorageFormat fmt_(ge::Format::FORMAT_NC, ge::FORMAT_NCHW, {});
ExpandDimsType type_("1001");
gert::CompileTimeTensorDesc td;
td.SetDataType(dtype_);
auto dtype = td.GetDataType(); // ge::DataType::DT_INT32;
td.SetStorageFormat(fmt_.GetStorageFormat());
auto storage_fmt = td.GetStorageFormat(); // ge::FORMAT_NCHW
td.SetOriginFormat(fmt_.GetOriginFormat());
auto origin_fmt = td.GetOriginFormat(); // ge::Format::FORMAT_NC
td.SetExpandDimsType(type_);
auto type = td.GetExpandDimsType(); // type_("1001")
```
