struct nbla::PadItem

struct PadItem

Pad the input N-D array `x` over the number dimensions given by half the length of the `pad_width` iterable, where every two values in `pad_width` determine the before and after pad size of an axis starting from the last (innermost) dimension and continuing towards the first (outermost) dimension.

The `pad_width` iterable must hold an even number of positive values which may cover all or fewer dimensions of the input variable `x`.

Padding is performed according to the requested `mode`. If pad mode is “constant” then all padded elements are set to `constant_value`. If pad mode is “reflect” then the padded alements are populated with the reflection of the vector mirrored on the first and last values of the vector along each axis.

Inputs:

  • x: N-D array variable.

  • pad_width: Vector with an even number of padding values.

  • mode: Padding mode string, either ‘constant’ or ‘reflect’.

  • constant_value - Fill value if mode is ‘constant’.

Outputs:

  • Padded N-D array with the same number of dimensions as the input.

Template Parameters:

T – Data type for computation.