申请一个aclTensorList,并指定其内部包含的aclTensor。
aclTensorList *AllocTensorList(const aclTensor *const *tensors, uint64_t size)
参数 |
输入/输出 |
说明 |
---|---|---|
tensors |
输入 |
源数据,用于初始化aclTensorList。 |
size |
输入 |
源数据的元素个数。 |
返回申请到的aclTensorList对象,申请失败返回nullptr。
入参指针不能为空。
1 2 3 4 5 6 7 8 9 10 11 12 13 | // 初始化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()); } |