mamba-webgpu / shaders /elementwise_mul.wgsl
LJTSG's picture
Upload shaders/elementwise_mul.wgsl with huggingface_hub
4cee88d verified
raw
history blame contribute delete
511 Bytes
// elementwise_mul.wgsl — a[i] = a[i] * b[i], in-place.
// Used in Mamba mixer for gate: gated = hidden_y * silu(gate).
struct Params { n: u32, }
@group(0) @binding(0) var<storage, read_write> a_buf: array<f32>;
@group(0) @binding(1) var<storage, read> b_buf: array<f32>;
@group(1) @binding(0) var<uniform> params: Params;
@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
let i = gid.x;
if (i >= params.n) { return; }
a_buf[i] = a_buf[i] * b_buf[i];
}