aclCreateFloatArray

Description

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

aclFloatArray is a built-in array for managing and storing floating-point data. You can use it without knowing how it works inside.

Prototype

aclFloatArray *aclCreateFloatArray(const float *value, uint64_t size)

Parameter Description

Parameter

Input/Output

Description

value

Input

Float pointer on the host. Its value will be copied to the aclFloatArray.

size

Input

Length of a floating-point array. The value is a positive integer.

Return Value

Created aclFloatArray on success; otherwise, nullptr.

Constraints

  • This API must be used together with aclDestroyFloatArray. They are used to create and destroy the aclFloatArray, respectively.
  • The size of the aclFloatArray can be obtained by calling aclGetFloatArraySize.

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
//Create an aclFloatArray.
std::vector<float> scalesData = {1.0, 1.0, 2.0, 2.0};
aclFloatArray *scales = aclCreateFloatArray(scalesData.data(),scalesData.size());
...
// Use the aclFloatArray as the input parameter for single-operator API calls.
auto ret = aclxxXxxGetWorkspaceSize(srcTensor, scales, ..., outTensor, ..., &workspaceSize, &executor);
ret = aclxxXxx(...);
...
// Destroy the aclFloatArray.
ret = aclDestroyFloatArray(scales);