pub fn upsample_nearest2d_backward<T: Triton, D: Num, const SCALE_H: i32, const SCALE_W: i32, const BLOCK_IW: i32>(
dy_ptr: T::Pointer<D>,
dx_ptr: T::Pointer<D>,
_B: i32,
C: i32,
H: i32,
W: i32,
OH: i32,
OW: i32,
)where
T::I32Tensor: Tensor<i32, 1> + Comparison<i32, BoolTensor = T::BoolTensor>,
T::Pointer<D>: AddOffsets<i32, 1, T::I32Tensor, Output = T::Tensor<T::Pointer<D>>>,Expand description
Nearest-neighbour 2-D upsample backward pass — NCHW layout.
Grid: one flat pid per (b, c, ih, iw-tile) — same spatial extent as the
input tensor:
pid = ((b * C + c) * H + ih) * num_iw_tiles + iw_tile
Each CTA computes the gradient for a BLOCK_IW-wide strip of input columns by summing the SCALE_H × SCALE_W upstream gradients that each input pixel received during the forward pass. No atomic operations are needed because each input element is the sole accumulator for exactly SCALE_H×SCALE_W output lanes (their ranges are disjoint).
dx does NOT need to be zero-initialised (every element is written once).