Skip to main content

provable_contracts/traits/
softmax_kernel_v1.rs

1//! Auto-generated contract trait for `softmax-kernel-v1`.
2//! Generated by: `pv scaffold --trait contracts/softmax-kernel-v1.yaml`
3//! DO NOT EDIT — regenerate from YAML source.
4
5#![allow(clippy::doc_markdown)]
6
7/// Contract trait for `softmax-kernel-v1` v1.0.0.
8///
9/// Softmax kernel — numerically stable exponential normalization
10/// Reference: Bridle (1990) Training Stochastic Model Recognition Algorithms as Networks
11/// Reference: Milakov & Gimelshein (2018) Online normalizer calculation for softmax
12///
13/// Implementors must provide all 1 equation(s).
14/// Missing method = compile error. Wrong signature = compile error.
15pub trait SoftmaxKernelV1 {
16    /// `softmax`: σ(x)_i = exp(x_i - max(x)) / Σ_j exp(x_j - max(x))
17    /// Domain: x ∈ ℝ^n, n ≥ 1
18    /// Codomain: σ(x) ∈ (0,1)^n
19    /// Invariant: Σ σ(x)_i = 1.0 (normalization)
20    /// Invariant: σ(x)_i > 0 for all i (strict positivity)
21    /// Invariant: argmax(σ(x)) = argmax(x) (order preservation)
22    fn softmax(&self, x: &[f32]) -> Vec<f32>;
23}