acldvppRotate
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
Description
Description: rotates an image counterclockwise.

Prototype
Each operator has two-phase API calls. First, acldvppRotateGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppRotate is called to perform computation. The two-phase APIs are as follows:
- First-phase API:
1acldvppStatus acldvppRotateGetWorkspaceSize(const aclTensor *self, float angle, uint32_t interpolationMode, bool expand, const aclIntArray *center, uint32_t paddingMode, const aclFloatArray *fill, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)
- Second-phase API:
1acldvppStatus acldvppRotate(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
acldvppRotateWorkspaceSize
- 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 or FLOAT, 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 the input GRAY image, and 3 indicates the input RGB image).
- angle: rotation angle, in degrees. The rotation direction is counterclockwise.
- expand: whether to extend the image. The values are as follows:
- True: extends the image size to accommodate the rotated image. Note that the image is rotated around its center without translation during the extension.
When expand is set to True, the output width and height are calculated as follows:
The coordinates of the four vertices of the image are substituted into the following rotation matrix formula. Then the maximum distances in the horizontal and vertical directions are calculated as the width and height of the output image.

- False: The image size remains unchanged.
- True: extends the image size to accommodate the rotated image. Note that the image is rotated around its center without translation during the extension.
- center: rotation center.
When expand is set to False, if center is set to nullptr, the image is rotated around its center point. If center is set to other values, the image is rotated around the center point set. The coordinates of center are set with the upper left corner of the image as the origin point.
When expand is set to True, the center setting does not take effect, and the image is rotated around its center point.
- interpolationMode: the interpolation algorithm. The values of this parameter are as follows:
- 0: bilinear
- 1: nearest neighbour
- paddingMode: padding mode. The options are as follows:
- 0: CONSTANT, indicating that a constant pad value will be used.
- 1: EDGE, indicating repeating of the last element. For example, aaaaaa|a*****h|hhhhhhh, where * indicates any image element.
- fill: fill is an array whose length is 3 and is used to set the value to be filled in each channel. aclCreateFloatArray needs to be called to create data of the aclFloatArray type. fill is valid only when paddingMode is set to CONSTANT. If C is set to 1 (indicating a GRAY image), set fill[0]. If C is set to 3 (indicating an RGB image), set fill[0] for color red, fill[1] for color green, and fill[2] for color blue.
- out: operator output tensor. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the output tensor can be UINT8 or FLOAT, and the format can be NCHW or NHWC. Discontinuous tensors are not supported, in addition, N can only be 1, and C can be 1 or 3 (1 indicates a GRAY image and 3 indicates an RGB image). The values of dataType and Format 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.
acldvppRotate
- 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 acldvppRotateGetWorkspaceSize.
- executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppRotateGetWorkspaceSize 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 32768 x 32768.
- The input and output formats must be the same.