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

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| 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 异构组件。


#### 函数功能

构造Tensor。


#### 函数原型

```
__init__(data, tensor_desc: TensorDesc = None)
```


#### 参数说明

| 参数名 | 数据类型 | 取值说明 |
| --- | --- | --- |
| data | Union[np.ndarray, Tensor] | 表示Tensor的数据。 |
| tensor\_desc | TensorDesc | 表示Tensor的描述信息。 |


#### 调用示例

```
from llm_datadist import Tensor
tensor = Tensor(numpy.array([1]))
```


#### 返回值

正确情况下返回Tensor的实例。

传入data信息和tensor_desc信息不匹配时，会抛出RuntimeError。


#### 约束说明

无
