Autograd node for 2-D bilinear interpolation.
Resizes a 4-D tensor of shape (N, C, H_in, W_in) to
(N, C, H_out, W_out) by linearly interpolating between the four
neighbouring input pixels:
where is the integer floor of the source coordinate and
, are the fractional bilinear weights computed from the
align_corners rule above. The backward distributes grad_out back
to the same four pixels weighted by the same bilinear coefficients,
recomputed in the backend (no per-sample weight cache is saved).
Math
(analogous formula for ).
Attributes
schema_v1OpSchema"interpolate_bilinear", AmpPolicy::Promote.H_in_, W_in_intSaved input spatial dimensions.
H_out_, W_out_intRequested output spatial dimensions.
align_corners_boolCoordinate mapping mode (see file header).
orig_shape_ShapeFull
(N, C, H_in, W_in) shape for backward reconstruction.Static methods
1static
forward
→TensorImplPtrint forward(const int & input, int H_out, int W_out, bool align_corners)Compute the bilinear resize with autograd wiring.
Parameters
inputTensorImplPtr4-D input tensor of shape
(N, C, H_in, W_in).H_outintDesired output height.
W_outintDesired output width.
align_cornersboolCoordinate mapping mode (see file header).
Returns
TensorImplPtrResampled tensor of shape (N, C, H_out, W_out).
Raises
ShapeMismatchIf
input is not 4-D.