aclmdlSetAIPPByInputIndex

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

Function Usage

Sets the dynamic AIPP attributes for model inference based on an input index.

Dynamic AIPP provides the following functions and they are executed in the exact sequence: Cropping -> CSC -> Mean subtraction/normalization -> Padding.

Prototype

1
aclError aclmdlSetAIPPByInputIndex(uint32_t modelId, aclmdlDataset *dataset, size_t index, const aclmdlAIPP *aippParmsSet)

Parameters

Parameter

Input/Output

Description

modelId

Input

Model ID.

A successful aclmdlLoadFromFile, aclmdlLoadFromMem, aclmdlLoadFromFileWithMem, or aclmdlLoadFromMemWithMem call returns a model ID.

dataset

Input

Pointer to the input data for model inference. For details about the type definition, see aclmdlDataset.

Data of type aclmdlDataset describes the input data for model inference, while data of type aclDataBuffer describes the input memory size and address.

index

Input

Index of the dynamic AIPP input. If the input is not associated with a dynamic AIPP input, an error is reported.

Call aclmdlGetAippType to query whether a specified model input has an associated dynamic AIPP input. If yes, the index argument passed to this API call is the same as that of aclmdlGetAippType. If no, you do not need to set dynamic AIPP attributes.

aippParmsSet

Input

Pointer to the dynamic AIPP parameter object. For details about the type definition, see aclmdlAIPP.

Call aclmdlCreateAIPP in advance to create data of the aclmdlAIPP type.

Returns

0 on success; else, failure. For details, see aclError.

Restrictions

  • The image size after dynamic AIPP processing must be the same as that defined by the input shape required by the original model.
  • In batched inference scenarios, the image size after dynamic AIPP is calculated based on the configuration of each batch. After dynamic AIPP, the output image size must be consistent in a batch. Table 1 describes the formulas for calculating the result image size.
  • After image cropping, resizing, or padding, the rules for verifying the image size after dynamic AIPP are shown in the table below. aippOutputW and aippOutputH indicate the width and height of the AIPP output image, respectively. Other parameters are the input parameters of the aclmdlSetAIPPSrcImageSize, aclmdlSetAIPPScfParams, aclmdlSetAIPPCropParams, and aclmdlSetAIPPPaddingParams APIs.
    Table 1 Formulas for calculating the output image size

    Cropping

    Resizing

    Padding

    Output Width and Height

    No

    No

    No

    aippOutputW = srcImageSizeW, aippOutputH = srcImageSizeH

    Yes

    No

    No

    aippOutputW = cropSizeW, aippOutputH = cropSizeH

    Yes

    Yes

    No

    aippOutputW = scfOutputSizeW, aippOutputH = scfOutputSizeH

    Yes

    No

    Yes

    aippOutputW = cropSizeW + paddingSizeLeft + paddingSizeRight, aippOutputH = cropSizeH + paddingSizeTop + paddingSizeBottom

    No

    No

    Yes

    aippOutputW = srcImageSizeW + paddingSizeLeft + paddingSizeRight, aippOutputH = srcImageSizeH + paddingSizeTop + paddingSizeBottom

    No

    Yes

    Yes

    aippOutputW = scfOutputSizeW + paddingSizeLeft + paddingSizeRight, aippOutputH = scfOutputSizeH + paddingSizeTop + paddingSizeBottom

    No

    Yes

    No

    aippOutputW = scfOutputSizeW, aippOutputH = scfOutputSizeH

    Yes

    Yes

    Yes

    aippOutputW = scfOutputSizeW + paddingSizeLeft + paddingSizeRight, aippOutputH = scfOutputSizeH + paddingSizeTop + paddingSizeBottom

Example

For the API call example, see Dynamic AIPP (Multiple Dynamic AIPP Inputs).