concision_core/activate/traits/
ops.rs

1/*
2    Appellation: ops <module>
3    Created At: 2026.01.13:17:12:10
4    Contrib: @FL03
5*/
6/// Compute the softmax activation along a specified axis.
7pub trait SoftmaxAxis: SoftmaxActivation {
8    fn softmax_axis(self, axis: usize) -> Self::Output;
9}
10
11macro_rules! unary {
12    (@impl $name:ident::$call:ident($($rest:tt)*)) => {
13        paste::paste! {
14            pub trait $name {
15                type Output;
16
17                fn $call($($rest)*) -> Self::Output;
18
19                fn [<$call _derivative>]($($rest)*) -> Self::Output;
20            }
21        }
22    };
23    ($($name:ident::$call:ident($($rest:tt)*)),* $(,)?) => {
24        $(
25            unary!(@impl $name::$call($($rest)*));
26        )*
27    };
28}
29
30unary! {
31    HeavysideActivation::heavyside(self),
32    LinearActivation::linear(self),
33    SigmoidActivation::sigmoid(self),
34    SoftmaxActivation::softmax(&self),
35    ReLUActivation::relu(&self),
36    TanhActivation::tanh(&self),
37}