---
title: AllocTensorList
description: "申请一个aclTensorList，并指定其内部包含的aclTensor。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/aolapi/atlasascendc_api_07_1125.html
sourcePath: /source/zh/canncommercial/900/API/aolapi/atlasascendc_api_07_1125.html
indexId: 8fa84bc30fa91ee11934acc4e9239f11f1b4e0068dbb298ba35c74530448662f70
---
# AllocTensorList

#### 功能说明

申请一个aclTensorList，并指定其内部包含的aclTensor。


#### 函数原型

```
aclTensorList *AllocTensorList(const aclTensor *const *tensors, uint64_t size)
```


#### 参数说明

| 参数 | 输入/输出 | 说明 |
| --- | --- | --- |
| tensors | 输入 | 源数据，用于初始化aclTensorList。 |
| size | 输入 | 源数据的元素个数。 |


#### 返回值说明

返回申请到的aclTensorList对象，申请失败返回nullptr。


#### 约束说明

入参指针不能为空。


#### 调用示例

```
// 初始化5个aclTensor，并将其组装为一个aclTensorList
void Func(aclOpExecutor *executor) {
    gert::Shape newShape;
    for (int64_t i = 1; i <= 5; i++) {
        newShape.AppendDim(i);
    }
    std::vector<aclTensor *> tensors;
    for (int64_t i = 1; i <= 5; i++) {
        aclTensor *tensor = executor->AllocTensor(newShape, DT_INT64, ge::FORMAT_ND);
        tensors.push_back(tensor);
    }
    aclTensorList *tensorList = executor->AllocTensorList(tensors.data(), tensors.size());
}
```
