acldvppRgbToGrayscale

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Description: converts RGB Images into grayscale images.

Prototype

Each operator has two-phase API calls. First, acldvppRgbToGrayscaleGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppRgbToGrayscale is called to perform computation. The two-phase APIs are as follows:

  • First-phase API:
    1
    acldvppStatus acldvppRgbToGrayscaleGetWorkspaceSize(const aclTensor *self, uint32_t outputChannelsNum, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)
    
  • Second-phase API:
    1
    acldvppStatus acldvppRgbToGrayscale(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
    

acldvppRgbToGrayscaleWorkspaceSize

  • 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 3 (3 indicates the input RGB image).
    • outputChannelsNum: number of channels for outputting grayscale images. The value can be 1 or 3. When the value is 3, the pixel values of all channels of the returned image are the same.
    • 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, the value of N can only be 1, and the value of C can be 1 or 3 (1 indicates the GRAY image, and 3 indicates the RGB image. However, the pixel values of the RGB channels are the same.). 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.

acldvppRgbToGrayscale

  • 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 acldvppRgbToGrayscaleGetWorkspaceSize.
    • executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppRgbToGrayscaleGetWorkspaceSize 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.
  • The data types, width, and height of the input and output must be the same.
  • For a forcible check, the input format is RGB and the output format is gray.