LoadImageToLocal
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
x |
Function Usage
Transfers image data from the global memory to the local memory. During data movement, you can preprocess images, including image flipping, image resizing (clipping, cropping, resizing, and stretching), color space conversion (CSC), and type conversion. The parameters related to image preprocessing are configured in SetAippFunctions.
Prototype
1 2 | template <typename T> __aicore__ inline void LoadImageToLocal(const LocalTensor<T>& dst, const LoadImageToLocalParams& loadDataParams) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
dst |
Output |
Destination operand, which is of the LocalTensor type. The start address of LocalTensor must be 32-byte aligned. For the Atlas 350 Accelerator Card, the supported data types are uint8_t, int8_t, and half, and the supported TPosition values are VECIN, VECCALC, and VECOUT. For the For the For the For the |
loadDataParams |
Input |
LoadData parameter structure, of the LoadImageToLocalParams type. For details, see ${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_mm.h. Replace ${INSTALL_DIR} with the actual path for storing files after the CANN software is installed. For details about the parameter description, see Table 2. |
Parameter |
Input/Output |
Description |
|---|---|---|
horizSize |
Input |
Horizontal width of the image loaded from the source image, in pixels. Value range: horizSize ∈ [2, 4095]. |
vertSize |
Input |
Vertical height of the image loaded from the source image, in pixels. Value range: vertSize ∈ [2, 4095]. |
horizStartPos |
Input |
Horizontal start address of the loaded image on the source image, in pixels. Value range: horizStartPos ∈ [0, 4095]. Default value: 0. Note: When the input image format is YUV420SP, XRGB8888, RGB888, or YUV400, the value of this parameter must be an even number. |
vertStartPos |
Input |
Vertical start address of the loaded image on the source image, in pixels. Value range: vertStartPos ∈ [0, 4095]. Default value: 0. Note: If the input image is in YUV420SP format, the value of this parameter must be an even number. |
srcHorizSize |
Input |
Horizontal width of the source image, in pixels. Value range: srcHorizSize ∈ [2, 4095]. Note: If the input image is in YUV420SP format, the value of this parameter must be an even number. |
topPadSize |
Input |
Number of pixels padded on the top of the destination image. Value range: topPadSize ∈ [0, 32]. Default value: 0. This parameter is used for data padding. You need to call SetAippFunctions and use AippPaddingParams to configure the padding value, and then use topPadSize, botPadSize, leftPadSize, and rightPadSize to configure the padding size range. |
botPadSize |
Input |
Number of pixels padded at the bottom of the destination image. Value range: botPadSize ∈ [0, 32]. Default value: 0. |
leftPadSize |
Input |
Number of pixels padded to the left of the destination image. Value range: leftPadSize ∈ [0, 32]. Default value: 0. |
rightPadSize |
Input |
Number of pixels padded to the right of the destination image. Value range: rightPadSize ∈ [0, 32]. Default value: 0. |
sid |
Input |
Reserved parameter. This parameter is reserved for future functions. You can use the default value. |
Restrictions
- For details about the operand address alignment requirements, see General Address Alignment Restrictions.
- The size of the image loaded to dst plus the padding size must be less than or equal to the size of the storage space.
- When the padding mode is set to block padding or mirrored block padding by referring to SetAippFunctions, the left and right padding sizes (leftPadSize and rightPadSize) must be less than or equal to the horizontal size (horizSize) of the cropped image, and the top and bottom padding sizes (topPadSize and botPadSize) must be less than or equal to the vertical size (vertSize) of the cropped image because the padding data comes from the cropped image.
Returns
None
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | uint16_t horizSize = 32, vertSize = 32, horizStartPos = 0, vertStartPos = 0, srcHorizSize = 32, srcVertSize = 32, leftPadSize = 0, rightPadSize = 0; uint32_t dstHorizSize = 32, dstVertSize = 32, cSize = 32; uint8_t topPadSize = 0, botPadSize = 0; uint32_t gmSrc0Size = 0, gmSrc1Size = 0, dstSize = 0; AscendC::AippInputFormat inputFormat = AscendC::AippInputFormat::YUV420SP_U8; uint32_t cPadMode = 0; int8_t cPaddingValue = 0; AscendC::TPipe pipe; AscendC::TQue<AscendC::TPosition::A1, 1> inQueueA1; AscendC::TQue<AscendC::TPosition::VECOUT, 1> outQueueUB; AscendC::LocalTensor<int8_t> featureMapA1 = inQueueA1.AllocTensor<int8_t>(); uint64_t fm_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(fmGlobal.GetPhyAddr())); // aipp config AscendC::AippParams<int8_t> aippConfig; aippConfig.cPaddingParams.cPaddingMode = cPadMode; aippConfig.cPaddingParams.cPaddingValue = cPaddingValue; // fmGlobal is the entire input image. Set src1 to the start address of the UV dimension of the image. AscendC::SetAippFunctions(fmGlobal, fmGlobal[gmSrc0Size], inputFormat, aippConfig); AscendC::LoadImageToLocal(featureMapA1, { horizSize, vertSize, horizStartPos, vertStartPos, srcHorizSize, topPadSize, botPadSize, leftPadSize, rightPadSize }); |