Skip to main content

channel_chunk_forward

Function channel_chunk_forward 

Source
pub fn channel_chunk_forward<T: Triton, D: Num, const BLOCK_SIZE: i32>(
    x_ptr: T::Pointer<D>,
    y_ptr: T::Pointer<D>,
    c_total: i32,
    chunk_c: i32,
    chunk_offset: 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

Channel-wise chunk (split) forward — NC layout.

Extracts one contiguous channel slice [chunk_offset, chunk_offset + chunk_c) from a wide NC tensor and writes it into a narrow NC output tensor.

Index mapping (NC layout, index = n * C + c): y[n * chunk_c + ci] = x[n * c_total + chunk_offset + ci]

This is the structural inverse of channel_cat_forward. The backward of this op is channel_cat_forward with the same parameters.

Grid: n_spatial * cdiv(chunk_c, BLOCK_SIZE) CTAs. pid is decoded into (pid_n, ci_tile) via scalar integer division — no tensor-level division or modulo is required.