pub struct Conv2dBnSiluGemmForward {
pub name: &'static str,
pub id: String,
pub block_m: i32,
pub block_n: i32,
pub block_k: i32,
pub group_m: i32,
pub kernel_source: String,
pub entry_point_source: String,
pub source: String,
}Expand description
Fused Conv2d(1×1, stride=1, pad=0, groups=1) + BatchNorm2d + SiLU using GEMM.
A 1×1 stride=1 no-padding convolution is mathematically equivalent to: Y[N, M] = W[N, K] @ X[K, M] where: N = C_OUT, K = C_IN, M = OH * OW (batch handled in grid)
Input X is stored NCHW = [B, K, OH, OW], viewed as 2-D [K, OHOW] per batch (column-major spatial: stride_K = OHOW, stride_spatial = 1).
Weight W is [C_OUT, C_IN] row-major.
T::dot uses TF32 Tensor Cores on sm_87+ (Jetson Orin) for ~8× throughput vs direct scalar accumulation.
Restrictions (enforced by dispatch in graph/mod.rs):
- kernel_h == 1, kernel_w == 1
- stride_h == 1, stride_w == 1
- padding_h == 0, padding_w == 0
- groups == 1
BN parameters must be precomputed (same convention as conv2d_bn_silu_forward).
Grid: pid = b * num_pid_per_batch + group_id * (GROUP_M * num_pid_n) + pid_in_group (same L2-locality grouping as Triton’s matmul tutorial)
Inference-only; no backward pass.
Fields§
§name: &'static strThe kernel function’s name (e.g. "flash_attention2_forward").
id: StringUnique kernel identifier: fn_name + dtype(s) + const values joined by “__”.
block_m: i32Compile-time kernel constant, from the annotated fn’s const generics.
block_n: i32Compile-time kernel constant, from the annotated fn’s const generics.
block_k: i32Compile-time kernel constant, from the annotated fn’s const generics.
group_m: i32Compile-time kernel constant, from the annotated fn’s const generics.
kernel_source: StringThe original kernel function source.
entry_point_source: StringThe Rust source of the generated C-ABI entry-point wrapper function.
source: StringCombined source (kernel_source + "\n\n" + entry_point_source); used by the Kernel trait.
Implementations§
Trait Implementations§
Source§impl Kernel for Conv2dBnSiluGemmForward
impl Kernel for Conv2dBnSiluGemmForward
Source§type Args<'__a> = (*mut f32, *mut f32, *mut f32, *mut f32, *mut f32, i32, i32, i32, i32)
type Args<'__a> = (*mut f32, *mut f32, *mut f32, *mut f32, *mut f32, i32, i32, i32, i32)
Source§fn kernel_source(&self) -> &str
fn kernel_source(&self) -> &str
Source§fn entry_point_source(&self) -> &str
fn entry_point_source(&self) -> &str
Source§fn entry_point_name(&self) -> String
fn entry_point_name(&self) -> String
"{name}_entry_point".Source§impl RuntimeOp for Conv2dBnSiluGemmForward
impl RuntimeOp for Conv2dBnSiluGemmForward
Source§fn n_activation_inputs(&self) -> usize
fn n_activation_inputs(&self) -> usize
Source§fn param_shapes(
&self,
input_shapes: &[&[usize]],
output_shape: &[usize],
) -> Vec<Vec<usize>>
fn param_shapes( &self, input_shapes: &[&[usize]], output_shape: &[usize], ) -> Vec<Vec<usize>>
LoadedModel::load() time to pre-allocate device buffers.
input_shapes / output_shape are concrete (batch dim resolved).Source§fn param_names(&self) -> &'static [&'static str]
fn param_names(&self) -> &'static [&'static str]
param_shapes], in the same order.
Used as the suffix in the dotted key {node_name}.{slot_name}.
Return an empty slice for ops that have no named parameters.Source§fn pack_args(
&self,
inputs: &[(RawPtr, &[usize])],
params: &[RawPtr],
output: RawPtr,
output_shape: &[usize],
_output_row_stride: i32,
visitor: &mut dyn ArgVisitor,
)
fn pack_args( &self, inputs: &[(RawPtr, &[usize])], params: &[RawPtr], output: RawPtr, output_shape: &[usize], _output_row_stride: i32, visitor: &mut dyn ArgVisitor, )
visitor in the correct order. Read moreSource§fn grid(&self, output_shape: &[usize]) -> [u32; 3]
fn grid(&self, output_shape: &[usize]) -> [u32; 3]
Source§fn forward_output_row_stride(&self, output_shape: &[usize]) -> usize
fn forward_output_row_stride(&self, output_shape: &[usize]) -> usize
output_shape[-1]). Kernels using TMA must round up to satisfy the
16-byte alignment constraint (e.g. 4 elements for f32).Source§fn param_init_data(&self, _param_idx: usize) -> Option<Vec<u8>>
fn param_init_data(&self, _param_idx: usize) -> Option<Vec<u8>>
param_idx
immediately after device buffer allocation. Return None to leave the
slot zero-initialised (the default for trained parameters).
Byte count must equal param_shapes()[param_idx].iter().product() * dtype_bytes.Source§fn compute_concrete_output_shape(
&self,
_input_shapes: &[&[usize]],
resolved: &[usize],
) -> Vec<usize>
fn compute_concrete_output_shape( &self, _input_shapes: &[&[usize]], resolved: &[usize], ) -> Vec<usize>
Source§fn n_launches(&self) -> usize
fn n_launches(&self) -> usize
Source§fn pack_args_for_launch(
&self,
launch_idx: usize,
inputs: &[(*mut c_void, &[usize])],
params: &[*mut c_void],
output: *mut c_void,
output_shape: &[usize],
output_row_stride: i32,
visitor: &mut dyn ArgVisitor,
)
fn pack_args_for_launch( &self, launch_idx: usize, inputs: &[(*mut c_void, &[usize])], params: &[*mut c_void], output: *mut c_void, output_shape: &[usize], output_row_stride: i32, visitor: &mut dyn ArgVisitor, )
i (0-indexed). Read moreSource§fn grid_for_launch(
&self,
launch_idx: usize,
input_shapes: &[&[usize]],
output_shape: &[usize],
) -> [u32; 3]
fn grid_for_launch( &self, launch_idx: usize, input_shapes: &[&[usize]], output_shape: &[usize], ) -> [u32; 3]
i. Receives concrete input shapes so that per-chunk
grids can be computed without storing them in the op. Read moreSource§fn has_backward(&self) -> bool
fn has_backward(&self) -> bool
Source§fn backward_grad_output_row_stride(&self, output_shape: &[usize]) -> usize
fn backward_grad_output_row_stride(&self, output_shape: &[usize]) -> usize
pack_backward_args. The default is the natural row-major
stride (output_shape[-1]). Kernels using TMA must round up to satisfy
the 16-byte alignment constraint (e.g. 4 elements for f32).Source§fn pack_backward_args(
&self,
inputs: &[(*mut c_void, &[usize])],
params: &[*mut c_void],
output: *mut c_void,
output_shape: &[usize],
grad_output: *mut c_void,
grad_output_row_stride: i32,
grad_inputs: &[*mut c_void],
grad_params: &[*mut c_void],
visitor: &mut dyn ArgVisitor,
)
fn pack_backward_args( &self, inputs: &[(*mut c_void, &[usize])], params: &[*mut c_void], output: *mut c_void, output_shape: &[usize], grad_output: *mut c_void, grad_output_row_stride: i32, grad_inputs: &[*mut c_void], grad_params: &[*mut c_void], visitor: &mut dyn ArgVisitor, )
Source§fn backward_block(&self) -> [u32; 3]
fn backward_block(&self) -> [u32; 3]
Source§fn backward_grid(
&self,
input_shapes: &[&[usize]],
output_shape: &[usize],
) -> [u32; 3]
fn backward_grid( &self, input_shapes: &[&[usize]], output_shape: &[usize], ) -> [u32; 3]
Source§fn n_backward_launches(&self) -> usize
fn n_backward_launches(&self) -> usize
Source§fn pack_backward_args_for_launch(
&self,
launch_idx: usize,
inputs: &[(*mut c_void, &[usize])],
params: &[*mut c_void],
output: *mut c_void,
output_shape: &[usize],
grad_output: *mut c_void,
grad_output_row_stride: i32,
grad_inputs: &[*mut c_void],
grad_params: &[*mut c_void],
visitor: &mut dyn ArgVisitor,
)
fn pack_backward_args_for_launch( &self, launch_idx: usize, inputs: &[(*mut c_void, &[usize])], params: &[*mut c_void], output: *mut c_void, output_shape: &[usize], grad_output: *mut c_void, grad_output_row_stride: i32, grad_inputs: &[*mut c_void], grad_params: &[*mut c_void], visitor: &mut dyn ArgVisitor, )
i (0-indexed). Read more