acldvppImgToTensor
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
Description
- Description: normalizes images by subtracting the mean value and then dividing the result by the standard deviation, where the mean value is fixed at 0 and the standard deviation is fixed at 255. Therefore, this operator is used only to normalize UINT8 images with range [0, 255] to FLOAT images with range [0.0, 1.0].
- Formula:
Prototype
Each operator has two-phase API calls. First, acldvppImgToTensorGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppImgToTensor is called to perform computation. The two-phase APIs are as follows:
- First-phase API:
1acldvppStatus acldvppImgToTensorGetWorkspaceSize(const aclTensor* self, aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor)
- Second-phase API:
1acldvppStatus acldvppImgToTensor(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream)
acldvppImgToTensorGetWorkspaceSize
- Parameters:
- self: input tensor of the operator. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the input tensor can be UINT8, and the format can be NCHW or NHWC. Discontinuous tensors are not supported, in addition, N can be 1 or empty, and C can be 1 or 3 (1 indicates that the GRAY image is input, and 3 indicates that the RGB image is input).
- out: output tensor of the operator. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the output tensor can be FLOAT, and non-contiguous tensors are not supported. The format and shape must be the same as those of self.
- workspaceSize: size of the workspace to be allocated on the device.
- executor: operator executor, containing the operator computation process.
- Returns:
The status code acldvppStatus is returned. For details, see acldvpp Return Codes.
acldvppImgToTensor
- Parameters:
- workspace: The aclrtMalloc API needs to be called to allocate the device memory. The memory size is workspaceSize. The memory address output by the aclrtMalloc API is passed here.
- workspaceSize: The value must be the same as that obtained by calling acldvppImgToTensorGetWorkspaceSize.
- executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppImgToTensorGetWorkspaceSize API.
- stream: stream for executing the task. You can reuse the created stream to save resources or call aclrtCreateStream to create a stream, and then pass the stream as an input parameter.
- Returns
The status code acldvppStatus is returned. For details, see acldvpp Return Codes.
Constraints
The supported image resolution ranges from 6 x 4 to 4096 x 8192.
Parent topic: Media Data Processing Operator APIs