RoiAlign is a pooling layer used to input a feature map with a non-uniform size and output a fixed-size feature map. corresponds to the ONNX opset 10 operator prototype, and aclnnRoiAlignV2 corresponds to the torchvision operator prototype. aclnnRoiAlignV2 uses boxes to replace rois and batch_indices of aclnnRoiAlign, adds the aligned input parameter, and removes the mode argument, using mode="avg" by default.
Each operator has calls. First, aclnnRoiAlignV2GetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnRoiAlignV2 is called to perform computation.
[object Object][object Object]
Parameters:
self (aclTensor*, compute input): image feature map input. aclTensor on the device. The data type can be FLOAT16 or FLOAT, which must be the same as the data type of boxes and out. are supported. The can be NCHW. The shape is 4D (B, C, inputHeight, inputWidth), indicating that there are B images per batch in the input tensor, and each image has C feature maps whose size is inputHeight * inputWidth. B, inputHeight, and inputWidth cannot be 0D.
boxes (aclTensor*, compute input): box coordinates of the ROI. aclTensor on the device. The data type can be FLOAT16 or FLOAT, which must be the same as the data type of self and out. are supported. The can be ND. The shape is 2D (K, 5), where 5 indicates the box information (image_id, x1, y1, x2, y2), and K must be the same as the 0th dimension of out. The value range of image_id is [0, B), rounded down to an integer multiple of the image ID. B indicates the size of the 0th dimension of self. The coordinates must meet these requirements: 0 ≤ x1 ≤ x2 ≤ inputWidth/spatialScale and 0 ≤ y1 ≤ y2 ≤ inputHeight/spatialScale.
pooledHeight (int64_t, compute input): height of the output image after pooling. It is an input parameter on the host.
pooledWidth (int64_t, compute input): width of the output image after pooling. It is an input parameter on the host.
spatialScale (float, compute input): multiplication spatial scale factor. It is used to convert the ROI coordinates from the input spatial scale to the scale used for pooling, that is, the spatial scale of the input feature map X relative to the input image. It is an input parameter on the host. The value must be greater than 0.
samplingRatio (int64_t, compute input): sampling frequency for calculating each output element in the H and W directions. It is an input parameter on the host. The value must be greater than or equal to 0.
aligned (bool, compute input): If the value is false, is implemented. If the value is true, the box coordinates are pixel shifted by -0.5 to better align adjacent pixel indexes. It is an input parameter on the host.
out (aclTensor*, compute output): output after pooling. aclTensor on the device. The data type can be FLOAT16 or FLOAT, which must be the same as the data type of self and boxes. are supported. The can be NCHW. The shape is 4D (K, C, pooledHeight, pooledWidth), indicating that there are K elements per batch in the output tensor, and each element has C feature maps whose size is pooledHeight * pooledWidth.
workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
executor (aclOpExecutor**, output): operator executor, containing the operator computation process.
Returns:
Parameters:
workspace (void*, input): address of the workspace to be allocated on the device.
workspaceSize (uint64_t, input): size of the workspace to be allocated on the device, which is obtained by the first-phase API aclnnRoiAlignV2GetWorkspaceSize.
executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic computing:
- aclnnRoiAlignV2 defaults to a deterministic implementation.
The following example is for reference only. For details, see .