---
title: TensorDesc构造函数
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/others/llmdatadistdev/llmpr_42_0137.html
sourcePath: /source/zh/canncommercial/900/others/llmdatadistdev/llmpr_42_0137.html
indexId: ea0455948affb08b22bef6857e573dcbae5ada8e193d0fcd9260a03fe8a2ca6970
---
# TensorDesc构造函数

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | x |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | x |
| Atlas 推理系列产品 | x |
| Atlas 训练系列产品 | x |


说明：针对 Atlas A2 训练系列产品 / Atlas A2 推理系列产品 ，仅支持Atlas 800I A2 推理服务器、A200I A2 Box 异构组件。


#### 函数功能

构造TensorDesc。


#### 函数原型

```
__init__(dtype: DataType, shape: Union[List[int], Tuple[int]])
```


#### 参数说明

| 参数名 | 数据类型 | 取值说明 |
| --- | --- | --- |
| dtype | DataType | 表示Tensor数据类型。 |
| shape | Union[List[int], Tuple[int]] | 表示Tensor的shape的描述。 |


#### 返回值

正常情况下返回TensorDesc的实例。

传入数据类型错误情况下会抛出TypeError或ValueError异常。


#### 调用示例

```
from llm_datadist import TensorDesc, DataType
tensor_desc = TensorDesc(DataType.DT_FLOAT, [1,2])
```


#### 约束说明

无
