AllocTensorList

Function Usage

Allocates an aclTensorList and specifies the aclTensors contained in it.

Prototype

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

Parameters

Parameter

Input/Output

Description

tensors

Input

Source data, which is used to initialize aclTensorList.

size

Input

Number of elements in the source data.

Returns

Success: allocated aclTensorList object. Failure: nullptr.

Constraints

The input parameter pointer must not be null.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Initialize five aclTensors and encapsulate them into an 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());
}