aclCreateScalar
Description
Creates an aclScalar object as the input parameter for single-operator API calls.
aclScalar is a built-in structure for managing and storing scalar data. You can use it without knowing how it works inside.
Prototype
aclScalar *aclCreateScalar(void *value, aclDataType dataType)
Parameter Description
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
value |
Input |
Scalar pointer on the host. Its value will be used as the scalar. |
|
dataType |
Input |
Data type of a scalar. |
Returns
Created aclScalar on success; otherwise, nullptr.
Constraints
- This API must be used together with aclDestroyScalar. They are used to create and destroy the aclScalar, respectively.
- To create multiple aclScalar objects, call aclCreateScalarList to store the scalar list.
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 aclScalar. float alphaValue = 1.2f; aclScalar* alpha = aclCreateScalar(&alphaValue, aclDataType::ACL_FLOAT); ... // Use the aclScalar as the input parameter for single-operator API calls. auto ret = aclxxXxxGetWorkspaceSize(srcTensor, alpha, ..., outTensor, ..., &workspaceSize, &executor); ret = aclxxXxx(...); ... // Destroy the aclScalar. ret = aclDestroyScalar(alpha); |
Parent topic: Common APIs
