:nosearch: .. _op_ai_onnx_Pad-2: Pad - version 2 =============== This page documents version **2** of operator **Pad**. See :doc:`Pad` for the latest version (since version 25). - **Domain**: ``ai.onnx`` - **Since version**: 2 Given ``data`` tensor, pads, mode, and value. Example: .. code-block:: text Insert 0 pads to the beginning of the second dimension. data = [ [1.0, 1.2], [2.3, 3.4], [4.5, 5.7], ] pads = [0, 2, 0, 0] output = [ [ [0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7], ], ] **Inputs** - **data** (*T*): Input tensor. **Outputs** - **output** (*T*): Tensor after padding. **Attributes** - **mode** (*string*): Three modes: constant(default), reflect, edge - **pads** (*int[]*): List of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D it is the number of pixels. ``pads`` rank should be double of the input's rank. ``pads`` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis ``i`` and xi_end, the number of pixels added at the end of axis ``i``. - **value** (*float*): One float, indicates the value to be filled. **Type Constraints** - **T**: Constrain input and output types to float tensors. Allowed types: tensor(double), tensor(float), tensor(float16). Differences with previous version (1) ------------------------------------- **SchemaDiff**: ``Pad`` (domain ``'ai.onnx'``) * old version: 1 * new version: 2 * breaking: **yes** **Breaking reasons:** * attribute 'paddings' (removed): type=INTS; required=True * attribute 'pads' (added): type=INTS; required=True **Attributes:** * [BREAKING] removed 'paddings': type=INTS; required=True * [BREAKING] added 'pads': type=INTS; required=True **Documentation:** * line similarity: 0.82 (+3/-3 lines) .. code-block:: diff --- Pad v1 +++ Pad v2 @@ -1,13 +1,13 @@ -Given `data` tensor, paddings, mode, and value. +Given `data` tensor, pads, mode, and value. Example: - Insert 0 paddings to the beginning of the second dimension. + Insert 0 pads to the beginning of the second dimension. data = [ [1.0, 1.2], [2.3, 3.4], [4.5, 5.7], ] - paddings = [0, 0, 2, 0] + pads = [0, 2, 0, 0] output = [ [ [0.0, 0.0, 1.0, 1.2],