Shortcuts

mmcv.ops.upfirdn2d

mmcv.ops.upfirdn2d(input: torch.Tensor, filter: torch.Tensor, up: int = 1, down: int = 1, padding: Union[int, List[int]] = 0, flip_filter: bool = False, gain: Union[float, int] = 1, use_custom_op: bool = True)[source]

Pad, upsample, filter, and downsample a batch of 2D images.

Performs the following sequence of operations for each channel:

  1. Upsample the image by inserting N-1 zeros after each pixel (up).

2. Pad the image with the specified number of zeros on each side (padding). Negative padding corresponds to cropping the image.

3. Convolve the image with the specified 2D FIR filter (f), shrinking it so that the footprint of all output pixels lies within the input image.

  1. Downsample the image by keeping every Nth pixel (down).

This sequence of operations bears close resemblance to

scipy.signal.upfirdn().

The fused op is considerably more efficient than performing the same calculation using standard PyTorch ops. It supports gradients of arbitrary order.

Parameters
  • input (torch.Tensor) – Float32/float64/float16 input tensor of the shape [batch_size, num_channels, in_height, in_width].

  • filter (torch.Tensor) – Float32 FIR filter of the shape [filter_height, filter_width] (non-separable), [filter_taps] (separable), or None (identity).

  • up (int) – Integer upsampling factor. Can be a single int or a list/tuple [x, y]. Defaults to 1.

  • down (int) – Integer downsampling factor. Can be a single int or a list/tuple [x, y]. Defaults to 1.

  • padding (int | tuple[int]) – Padding with respect to the upsampled image. Can be a single number or a list/tuple [x, y] or [x_before, x_after, y_before, y_after]. Defaults to 0.

  • flip_filter (bool) – False = convolution, True = correlation. Defaults to False.

  • gain (int) – Overall scaling factor for signal magnitude. Defaults to 1.

  • use_custom_op (bool) – Whether to use customized op. Defaults to True.

Returns

Tensor of the shape [batch_size, num_channels, out_height, out_width]

Read the Docs v: 2.x
Versions
master
latest
2.x
1.x
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
v1.3.12
v1.3.11
v1.3.10
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.