CenterCropPad - 18


  • name: CenterCropPad (GitHub)

  • domain: main

  • since_version: 18

  • function: True

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 18.


Center crop or pad an input to given dimensions.

The crop/pad dimensions can be specified for a subset of the axes. Non-specified dimensions will not be cropped or padded.

If the input dimensions are bigger than the crop shape, a centered cropping window is extracted from the input. If the input dimensions are smaller than the crop shape, the input is padded on each side equally, so that the input is centered in the output.


  • axes - INTS :

    If provided, it specifies a subset of axes that ‘shape’ refer to. If not provided, all axes are assumed [0, 1, …, r-1], where r = rank(data). Negative value means counting dimensions from the back. Accepted range is [-r, r-1], where r = rank(data). Behavior is undefined if an axis is repeated.


  • input_data (heterogeneous) - T:

    Input to extract the centered crop from.

  • shape (heterogeneous) - Tind:

    1-D tensor representing the cropping window dimensions.


  • output_data (heterogeneous) - T:

    Output data.

Type Constraints

  • T in ( tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ):

    Constrain input and output types to all tensor types.

  • Tind in ( tensor(int32), tensor(int64) ):

    Constrain indices to integer types