.. _op_ai_onnx_DeformConv: DeformConv ========== - **Domain**: ``ai.onnx`` - **Since version**: 22 Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data. **Inputs** - **X** (*T*): Input data tensor. For 2D image data, it has shape (N, C, H, W) where N is the batch size, C is the number of input channels, and H and W are the height and width. In general, the shape is (N, C, D1, D2, ... , Dn) for n-dimensional data, where D1 to Dn are the spatial dimension sizes. Most common use cases have n = 2 or 3. - **W** (*T*): Weight tensor that will be used in the convolutions. It has shape (oC, C/group, kH, kW), where oC is the number of output channels and kH and kW are the kernel height and width. For more than 2 dimensions, it has shape (oC, C/group, k1, k2, ... , kn). - **offset** (*T*): Offset tensor denoting the offset for the sampling locations in the convolution kernel. It has shape (N, offset_group \* kH \* kW \* 2, oH, oW) for 2D data or (N, offset_group \* k1 \* k2 \* ... \* kn \* n, o1, o2, ... , on) for nD data. Use linear interpolationfor fractional offset values. Sampling locations outside of the padded input tensor gives zero. - **B** (*T*): Optional 1D bias of length oC to be added to the convolution. Default is a tensor of zeros. - **mask** (*T*): The mask tensor to be applied to each position in the convolution kernel. It has shape (N, offset_group \* kH \* kW, oH, oW) for 2D data or (N, offset_group \* k1 \* k2 \* ... \* kn \* n, o1, o2, ... , on) for nD data. Default is a tensor of ones. **Outputs** - **Y** (*T*): Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) for 2D data or (N, oC, o1, o2, ..., on) for nD data **Type Constraints** - **T**: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16). Examples -------- **test_cc_basic_deform_conv_with_padding** .. code-block:: text Node: DeformConv(X, W, offset) -> (Y) Attributes: kernel_shape = [2, 2] pads = [1, 1, 1, 1] .. code-block:: text Inputs: X: shape=(1, 1, 3, 3), dtype=float32 [[[[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]]]] W: shape=(1, 1, 2, 2), dtype=float32 [[[[1., 1.], [1., 1.]]]] offset: shape=(1, 8, 4, 4), dtype=float32 [[[[ 0.5, 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]], [[ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]], [[ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]], ..., [[ 0. , 0. , 0. , 0. ], [ 0. , 0. , -0.1, 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]], [[ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]], [[ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]]]] Outputs: Y: shape=(1, 1, 4, 4), dtype=float32 [[[[ 0. , 1. , 3. , 2. ], [ 3. , 8. , 11.9, 7. ], [ 9. , 20. , 24. , 13. ], [ 6. , 13. , 15. , 8. ]]]] **test_cc_basic_deform_conv_without_padding** .. code-block:: text Node: DeformConv(X, W, offset) -> (Y) Attributes: kernel_shape = [2, 2] pads = [0, 0, 0, 0] .. code-block:: text Inputs: X: shape=(1, 1, 3, 3), dtype=float32 [[[[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]]]] W: shape=(1, 1, 2, 2), dtype=float32 [[[[1., 1.], [1., 1.]]]] offset: shape=(1, 8, 2, 2), dtype=float32 [[[[ 0.5, 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , -0.1], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]]]] Outputs: Y: shape=(1, 1, 2, 2), dtype=float32 [[[[ 9.5, 11.9], [20. , 24. ]]]] **test_cc_deform_conv_with_mask_bias** .. code-block:: text Node: DeformConv(X, W, offset, B, mask) -> (Y) Attributes: kernel_shape = [2, 2] pads = [0, 0, 0, 0] .. code-block:: text Inputs: X: shape=(1, 1, 3, 3), dtype=float32 [[[[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]]]] W: shape=(1, 1, 2, 2), dtype=float32 [[[[1., 1.], [1., 1.]]]] offset: shape=(1, 8, 2, 2), dtype=float32 [[[[ 0.5, 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , -0.1], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]]]] B: shape=(1,), dtype=float32 [1.] mask: shape=(1, 4, 2, 2), dtype=float32 [[[[1. , 1. ], [1. , 1. ]], [[1. , 1. ], [1. , 1. ]], [[1. , 1. ], [1. , 0.2]], [[1. , 1. ], [1. , 1. ]]]] Outputs: Y: shape=(1, 1, 2, 2), dtype=float32 [[[[10.5, 12.9], [21. , 19.4]]]] **test_cc_deform_conv_with_multiple_offset_groups** .. code-block:: text Node: DeformConv(X, W, offset) -> (Y) Attributes: kernel_shape = [2, 2] pads = [0, 0, 0, 0] offset_group = 2 .. code-block:: text Inputs: X: shape=(1, 2, 3, 3), dtype=float32 [[[[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], [[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]]]] W: shape=(1, 2, 2, 2), dtype=float32 [[[[1., 1.], [1., 1.]], [[1., 1.], [1., 1.]]]] offset: shape=(1, 16, 2, 2), dtype=float32 [[[[ 0.5, 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , -0.1], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]], [[ 0. , 0. ], [ 0. , 0. ]]]] Outputs: Y: shape=(1, 1, 2, 2), dtype=float32 [[[[33.5, 32.1], [32. , 32. ]]]] Differences with previous version (19) -------------------------------------- **SchemaDiff**: ``DeformConv`` (domain ``'ai.onnx'``) * old version: 19 * new version: 22 * breaking: no **Type constraints:** * changed 'T': added types: ['tensor(bfloat16)'] Version History --------------- - :doc:`Version 19 `