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_intH_ out_ , W_ out_intalign_ corners_boolorig_ shape_Shape(N, C, H_in, W_in) shape for backward reconstruction.Static methods
1forward
→TensorImplPtrint forward(const int & input, int H_out, int W_out, bool align_corners)Compute the bilinear resize with autograd wiring.
Parameters
inputTensorImplPtr(N, C, H_in, W_in).H_ outintW_ outintalign_ cornersboolReturns
TensorImplPtrResampled tensor of shape (N, C, H_out, W_out).
Raises
ShapeMismatchinput is not 4-D.Methods
2Backward pass: scatters grad_out to source pixels using the same bilinear weights as the forward.
Graph-mode backward: the same adjoint as two matmuls against the 1-D resampling matrices, so it can be differentiated again.