Rspress

# #Dynamic Input Introduction

When the model input tensor properties `validShape` or `stride` contains `-1`, it means that the model input is dynamic and you need to fill in the dynamic dimension according to the actual input.

The following rules should be followed when filling in `stride`:

- Make sure the filled value satisfies s t r i d e[i d x]>=s t r i d e[i d x+1]∗v a l i d S h a p e.d i m e n s i o n S i z e[i d x+1]stride[idx] >= stride[idx+1] * validShape.dimensionSize[idx+1]s t r i d e[i d x]>=s t r i d e[i d x+1]∗v a l i d S ha p e.d im e n s i o n S i ze[i d x+1], where `idx` represents the current dimension.

- For `stride` of Y and UV inputs, due to some hardware constraints, fixed alignment requirement needs to be ensured in the W direction, where S600 requires 64-byte alignment and non-S600 requires 32-byte alignment, which means you need to align the input according to `stride`.

Here, using the S100 model as an example, the stride is required to be 32-byte aligned, and the model has three inputs:

- `input_y` : validShape = [1,-1,-1,1]，stride = [-1,-1,1,1]
- `input_uv` : validShape = [1,-1,-1,2]，stride = [-1,-1,2,1]
- `input_roi` : validShape = [1,4]，stride = [16,4]

`input_y` and `input_uv` are dynamic inputs, and are Y and UV inputs. Assume that the actually inputs: `input_y`'s `validShape` = [1,220,220,1], `input_uv`'s `validShape` = [1,110,110,2]. `stride` is calculated as follows to ensure that the dynamic dimension is aligned to 32, where `ALIGN_32` represents 32-byte alignment:

- `input_y` :

  stride[3] = 1;

  stride[2] = 1;

  stride[1] = ALIGN_32(stride[2] * validShape.dimensionSize[2]) = ALIGN_32(1 * 220) = 224;

  stride[0] = ALIGN_32(stride[1] * validShape.dimensionSize[1]) = ALIGN_32(224 * 220) = 49280;

- `input_uv` :

  stride[3] = 1;

  stride[2] = 2;

  stride[1] = ALIGN_32(stride[2] * validShape.dimensionSize[2]) = ALIGN_32(2 * 110) = 224;

  stride[0] = ALIGN_32(stride[1] * validShape.dimensionSize[1]) = ALIGN_32(224 * 110) = 24640;

You need to set the following properties when preparing the input, and align the input data according to `stride`:

- `input_y` : validShape = [1,220,220,1]，stride = [49280,224,1,1]
- `input_uv` : validShape = [1,110,110,2]，stride = [24640,224,2,1]
- `input_roi` : validShape = [1,4]，stride = [16,4]

On This Page