Autograd node for 2-D nearest-neighbour interpolation.
Resizes a 4-D tensor of shape (N, C, H_in, W_in) to
(N, C, H_out, W_out) by copying, for each output pixel, the single
nearest input pixel:
(the floor mapping above is the exact rule the forward backend kernel
uses). Because the map is many-to-one, the backward scatter-adds each
output gradient onto its unique source pixel — an input pixel selected by
k output pixels receives the sum of those k gradients.
Attributes
schema_v1OpSchema"interpolate_nearest_2d", AmpPolicy::KeepInput (pure gather, no arithmetic — input dtype is preserved).H_in_, W_in_intSaved input spatial dimensions.
H_out_, W_out_intRequested output spatial dimensions.
orig_shape_ShapeFull
(N, C, H_in, W_in) shape for backward reconstruction.Static methods
1Compute the nearest-neighbour 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.
Returns
TensorImplPtrResampled tensor of shape (N, C, H_out, W_out).
Raises
ShapeMismatchIf
input is not 4-D.