---
title: Tensor
description: "加速库的Tensor定义，包含每个Tensor的描述符、NPU内存地址、CPU内存地址和内存大小等。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0011.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0011.html
indexId: f3d62d5b33027c5a547caf9de96d54684b87cc8b45d7b94929b9c15e2be9231564
---
# Tensor

#### 功能说明

加速库的Tensor定义，包含每个Tensor的描述符、NPU内存地址、CPU内存地址和内存大小等。


#### 定义

```
struct Tensor {
    TensorDesc desc;
    void *deviceData = nullptr;
    void *hostData = nullptr;
    uint64_t dataSize = 0;
};
```


#### 参数列表

| 成员名称 | 数据类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| desc | TensorDesc | \- | Tensor描述信息。 |
| deviceData | void \* | nullptr | TensorNPU内存地址。 |
| hostData | void \* | nullptr | TensorCPU内存地址。 |
| dataSize | uint64\_t | 0 | “deviceData”或“hostData”指向内容的内存大小。 |
