aclCreateTensorList

Description

Creates an aclTensorList object as the input parameter for single-operator API calls.

aclTensorList is a built-in list structure for managing and storing multiple tensors. You can use it without knowing how it works inside.

Prototype

aclTensorList *aclCreateTensorList(const aclTensor *const *value, uint64_t size)

Parameter Description

Parameter

Input/Output

Description

value

Input

Pointer array of the aclTensor type. Its value will be assigned to the TensorList.

size

Input

Length of the tensor list. The value is a positive integer.

Return Value

Created aclTensorList on success; otherwise, nullptr.

Constraints

Example

The following sample code is for reference only. Do not copy and run it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Create aclTensors: input1 and input2.
std::vector<int64_t> shape = {1, 2, 3};
aclTensor *input1 = aclCreateTensor(shape.data(), shape.size(), aclDataType::ACL_FLOAT,
nullptr, 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), nullptr);
aclTensor *input2 = aclCreateTensor(shape.data(), shape.size(), aclDataType::ACL_FLOAT,
nullptr, 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), nullptr);
// Create an aclTensorList.
std::vector<aclTensor *> tmp{input1, input2};
aclTensorList* tensorList = aclCreateTensorList(tmp.data(), tmp.size());
// Use the aclTensorList as the input parameter for single-operator API calls.
auto ret = aclxxXxxGetWorkspaceSize(srcTensor, tensorList, ..., outTensor, ..., &workspaceSize, &executor);
ret = aclxxXxx(...);
...
// Destroy the aclTensorList.
ret = aclDestroyTensorList(tensorList);