Skip to content
class

InterpolateNearestBackward3D

InterpolateNearestBackward3D

Autograd node for 3-D nearest-neighbour interpolation.

Volumetric counterpart of InterpolateNearestBackward2D; resizes a 5-D tensor (N, C, D_in, H_in, W_in) to (N, C, D_out, H_out, W_out) by floor-rounding source voxel coordinates. The backward scatter-adds each output gradient onto its unique source voxel.

Attributes

schema_v1OpSchema
"interpolate_nearest_3d", AmpPolicy::KeepInput.
D_in_, H_in_, W_in_int
Saved input spatial dimensions.
D_out_, H_out_, W_out_int
Requested output spatial dimensions.
orig_shape_Shape
Full (N, C, D_in, H_in, W_in) shape for backward reconstruction.

Static methods

1
static

forward

→TensorImplPtr
int forward(const int & input, int D_out, int H_out, int W_out)

Compute the nearest-neighbour resize with autograd wiring.

Parameters

inputTensorImplPtr
5-D input tensor of shape (N, C, D_in, H_in, W_in).
D_outint
Desired output depth.
H_outint
Desired output height.
W_outint
Desired output width.

Returns

TensorImplPtr

Resampled tensor of shape (N, C, D_out, H_out, W_out).

Raises

ShapeMismatch
If input is not 5-D.

Methods

2
fn

apply

int apply(int grad_out)

Backward pass: scatter-adds grad_out onto the source voxels using the same floor coordinate mapping as the forward.

fn

apply_for_graph

int apply_for_graph(const int & grad_out)

Graph-mode backward for an integer scale factor: block sums, as in InterpolateNearestBackward2D.