pub struct FlattenBackward<D: Num> {
pub name: &'static str,
pub id: String,
pub block_b: i32,
pub block_n: i32,
pub kernel_source: String,
pub entry_point_source: String,
pub source: String,
/* private fields */
}Expand description
Copy a contiguous row-major [B, N] gradient back to an output buffer with arbitrary strides.
This is the backward pass of the flatten operation. The gradient dy arrives as a contiguous row-major tensor (the upstream gradient matches the contiguous forward output); this kernel writes it back to dx using the original input strides so that the gradient is in the same memory layout as the forward input. When the forward input was already row-major contiguous this is again a simple memcpy; when the forward input used a different layout the kernel performs the inverse reordering.
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_b: i32Compile-time kernel constant, from the annotated fn’s const generics.
block_n: 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: Num> Kernel for FlattenBackward<D>
impl<D: Num> Kernel for FlattenBackward<D>
Source§type Args<'__a> = (*mut D, *mut D, i32, i32, i32, i32)
type Args<'__a> = (*mut D, *mut D, 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".