tenferro_ext_tropical/prims/
mod.rs

1//! Semiring-family implementations for tropical algebras on
2//! [`tenferro_prims::CpuBackend`].
3//!
4//! Each tropical algebra gets its own `impl TensorSemiringCore<XxxAlgebra> for CpuBackend`
5//! plus a `TensorSemiringFastPath` impl that reports no optional fast paths.
6//! The orphan rule is satisfied because `XxxAlgebra` is defined in this crate.
7//!
8//! Optional fast paths (`Contract`, elementwise semiring binary ops) are not
9//! supported for tropical algebras.
10//!
11//! Because tropical scalar types redefine `Add` (= max/min) and `Mul` (= +/×),
12//! the standard ScalarBase-based helper functions work correctly: the expression
13//! `sum = sum + a * b` becomes `sum = max(sum, a_val + b_val)` for MaxPlus,
14//! which is exactly tropical GEMM.
15
16mod execute;
17mod impls;
18mod plan;
19mod view;
20
21pub use self::plan::TropicalPlan;
22
23#[allow(unused_imports)]
24pub(crate) use self::execute::{
25    execute_anti_diag, execute_anti_trace, execute_batched_gemm_fallback, execute_make_contiguous,
26    execute_trace, tropical_execute,
27};
28#[allow(unused_imports)]
29pub(crate) use self::plan::tropical_plan;
30#[allow(unused_imports)]
31pub(crate) use self::view::{
32    for_each_index, scale_output, tensor_to_view, tensor_to_view_mut, unflatten_index,
33};
34
35#[cfg(test)]
36#[allow(unused_imports)]
37use crate::algebra::MaxPlusAlgebra;
38#[cfg(test)]
39#[allow(unused_imports)]
40use crate::scalar::MaxPlus;
41#[cfg(test)]
42#[allow(unused_imports)]
43use std::marker::PhantomData;
44#[cfg(test)]
45#[allow(unused_imports)]
46use tenferro_device::Error;
47#[cfg(test)]
48#[allow(unused_imports)]
49use tenferro_prims::{
50    CpuBackend, CpuContext, SemiringCoreDescriptor, SemiringFastPathDescriptor, TensorSemiringCore,
51    TensorSemiringFastPath,
52};
53
54#[cfg(test)]
55mod tests;