Skip to main content

tenferro_scalar_consumer_application/
lib.rs

1//! The final application role of the external-scalar consumer.
2//!
3//! The application composes a canonical support with an optional scalar contribution and
4//! binds the capabilities the algorithm states. It is the only role that names a scalar,
5//! a provider, or a concrete dtype.
6//!
7//! The bindings live with the tests that exercise them, because a binding is only
8//! meaningful together with the runtime it registers into.
9//!
10//! The application also declares its own scalar set. Together with the contribution's set
11//! this gives two sets that both contain the external scalar, which is what #1785 asks for
12//! when it requires reuse of a contribution-owned kernel by two containing sets. A set is
13//! membership and dispatch only: the numerical entry point is parameterized by the
14//! contribution's own scalar and operation type, so a second containing set adds no
15//! numerical specialization.
16
17use tenferro_df64_proof::Df64;
18
19tenferro_tensor::define_scalar_set! {
20    /// Tag for the set the application declares.
21    ///
22    /// # Examples
23    ///
24    /// ```rust
25    /// use tenferro_scalar_consumer_application::ApplicationTag;
26    ///
27    /// assert_ne!(ApplicationTag::F64, ApplicationTag::Df64);
28    /// ```
29    pub enum ApplicationTag {
30        /// Standard single precision.
31        F32 => f32 : Float 0 32,
32        /// Standard double precision.
33        F64 => f64 : Float 1 64,
34        /// The contribution's extended-precision scalar, ranked above double precision.
35        Df64 => Df64 : Float 2 64,
36    }
37    /// Value enum for the set the application declares.
38    ///
39    /// # Examples
40    ///
41    /// ```rust
42    /// use tenferro_df64_proof::Df64;
43    /// use tenferro_scalar_consumer_application::{ApplicationSet, ApplicationTag};
44    /// use tenferro_tensor::{DynRank, Host, ScalarSet, TypedTensor};
45    ///
46    /// let value = ApplicationSet::Df64(
47    ///     TypedTensor::<_, DynRank, Host>::from_host_vec_col_major(vec![1], vec![Df64::from_f64(2.0)])?,
48    /// );
49    /// assert_eq!(value.tag(), ApplicationTag::Df64);
50    /// # Ok::<(), tenferro_tensor::Error>(())
51    /// ```
52    pub enum ApplicationSet;
53}