provable_contracts/traits/activation_kernel_v1.rs
1//! Auto-generated contract trait for `activation-kernel-v1`.
2//! Generated by: `pv scaffold --trait contracts/activation-kernel-v1.yaml`
3//! DO NOT EDIT — regenerate from YAML source.
4
5#![allow(clippy::doc_markdown)]
6
7/// Contract trait for `activation-kernel-v1` v1.0.0.
8///
9/// Activation functions — GELU, SiLU/Swish, ReLU kernels
10/// Reference: Hendrycks & Gimpel (2016) Gaussian Error Linear Units (GELUs)
11/// Reference: Ramachandran et al. (2017) Searching for Activation Functions (SiLU)
12/// Reference: Nair & Hinton (2010) Rectified Linear Units Improve Restricted Boltzmann Machines
13///
14/// Implementors must provide all 3 equation(s).
15/// Missing method = compile error. Wrong signature = compile error.
16pub trait ActivationKernelV1 {
17 /// `gelu`: GELU(x) = x · Φ(x) ≈ 0.5x(1 + tanh(√(2/π)(x + 0.044715x³)))
18 /// Domain: x ∈ ℝ
19 /// Codomain: ℝ
20 /// Invariant: GELU(x) → x as x → +∞
21 /// Invariant: GELU(x) → 0 as x → -∞
22 /// Invariant: GELU(0) = 0
23 fn gelu(&self, x: f32) -> Vec<f32>;
24
25 /// `relu`: ReLU(x) = max(0, x)
26 /// Domain: x ∈ ℝ
27 /// Codomain: [0, ∞)
28 /// Invariant: ReLU(x) ≥ 0 (non-negativity)
29 /// Invariant: ReLU(x) = x for x > 0
30 /// Invariant: ReLU(x) = 0 for x ≤ 0
31 fn relu(&self, x: f32) -> Vec<f32>;
32
33 /// `silu`: SiLU(x) = x · σ(x) = x / (1 + exp(-x))
34 /// Domain: x ∈ ℝ
35 /// Codomain: ℝ
36 /// Invariant: SiLU(x) → x as x → +∞
37 /// Invariant: SiLU(x) → 0 as x → -∞
38 /// Invariant: SiLU(0) = 0
39 fn silu(&self, x: f32) -> Vec<f32>;
40}