Skip to main content

Module activation

Module activation 

Source
Expand description

Activation kernels: ReLU, GELU, SiLU.

Matches activation-kernel-v1.yaml.

Each function provides one of three backends:

  • fn {name}_scalar(...) — Pure Rust scalar reference (ground truth)
  • unsafe fn {name}_avx2(...) — AVX2 SIMD implementation
  • fn {name}_ptx() -> &'static str — PTX assembly source string

Functions§

gelu_avx2
AVX2 GELU — delegates to scalar (no hardware tanh in AVX2).
gelu_ptx
PTX assembly for the GELU kernel.
gelu_scalar
GELU: 0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))
relu_avx2
AVX2 ReLU: _mm256_max_ps(x, zero) with scalar tail.
relu_ptx
PTX assembly for the ReLU kernel (elementwise, 1 thread per element).
relu_scalar
ReLU: max(0, x)
silu_avx2
AVX2 SiLU — delegates to scalar (no hardware exp in AVX2).
silu_ptx
PTX assembly for the SiLU (Swish) kernel.
silu_scalar
SiLU (Swish): x / (1 + exp(-x))