pub struct BatchNorm2dNchwBackward<D: Float> {
pub name: &'static str,
pub id: String,
pub block_hw: i32,
pub kernel_source: String,
pub entry_point_source: String,
pub source: String,
/* private fields */
}Expand description
Computes gradients for NCHW BatchNorm2d inference.
Since running_mean and running_var are frozen constants, the backward of
y = gamma * (x - mean) * rstd + beta (with respect to x) is simply:
dx[b,c,h,w] = gamma[c] * rstd[c] * dy[b,c,h,w]
dweight[c] = Σ_{b,h,w} dy * xhat
dbias[c] = Σ_{b,h,w} dyA single loop over (b, hw) computes all three simultaneously.
Grid: [C] — one CTA per channel.
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_hw: 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<D: Float> Kernel for BatchNorm2dNchwBackward<D>
impl<D: Float> Kernel for BatchNorm2dNchwBackward<D>
Source§type Args<'__a> = (*mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, i32, i32, i32, f32)
type Args<'__a> = (*mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, i32, i32, i32, f32)
This kernel’s launch-argument tuple type.
Source§fn kernel_source(&self) -> &str
fn kernel_source(&self) -> &str
This kernel’s body source, without the entry-point wrapper.
Source§fn entry_point_source(&self) -> &str
fn entry_point_source(&self) -> &str
Returns the Rust source of the generated C-ABI entry-point wrapper function.
Source§fn entry_point_name(&self) -> String
fn entry_point_name(&self) -> String
Returns the PTX symbol name for this kernel:
"{name}_entry_point".Auto Trait Implementations§
impl<D> Freeze for BatchNorm2dNchwBackward<D>
impl<D> RefUnwindSafe for BatchNorm2dNchwBackward<D>where
D: RefUnwindSafe,
impl<D> Send for BatchNorm2dNchwBackward<D>where
D: Send,
impl<D> Sync for BatchNorm2dNchwBackward<D>where
D: Sync,
impl<D> Unpin for BatchNorm2dNchwBackward<D>where
D: Unpin,
impl<D> UnsafeUnpin for BatchNorm2dNchwBackward<D>
impl<D> UnwindSafe for BatchNorm2dNchwBackward<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more