tenferro_internal_runtime/
contracts.rs1use chainrules::ScalarAd;
4use num_complex::Complex;
5use num_traits::Float;
6use tenferro_algebra::{Conjugate, HasAlgebra, Scalar, Standard};
7use tenferro_internal_frontend_core::DynTensorTyped;
8use tenferro_linalg::backend::CudaLinalgScalar;
9use tenferro_linalg::{KernelLinalgScalar, LinalgScalar};
10use tenferro_tensor::KeepCountScalar;
11
12#[doc(hidden)]
13pub trait StandardRuntimeValue:
14 Scalar + DynTensorTyped + HasAlgebra<Algebra = Standard<Self>> + 'static
15{
16}
17
18impl<T> StandardRuntimeValue for T where
19 T: Scalar + DynTensorTyped + HasAlgebra<Algebra = Standard<T>> + 'static
20{
21}
22
23#[doc(hidden)]
24pub trait EinsumRuntimeValue: StandardRuntimeValue + Conjugate {}
25
26impl<T> EinsumRuntimeValue for T where T: StandardRuntimeValue + Conjugate {}
27
28#[doc(hidden)]
29pub trait ScalarRuntimeValue: StandardRuntimeValue + Copy {}
30
31impl<T> ScalarRuntimeValue for T where T: StandardRuntimeValue + Copy {}
32
33#[doc(hidden)]
34pub trait AnalyticRuntimeValue: ScalarRuntimeValue {}
35
36impl<T> AnalyticRuntimeValue for T where T: ScalarRuntimeValue {}
37
38#[doc(hidden)]
39pub trait ScalarAnalyticRuntimeValue:
40 EinsumRuntimeValue + ScalarRuntimeValue + AnalyticRuntimeValue
41{
42}
43
44impl<T> ScalarAnalyticRuntimeValue for T where
45 T: EinsumRuntimeValue + ScalarRuntimeValue + AnalyticRuntimeValue
46{
47}
48
49#[doc(hidden)]
50pub trait GenericAdRuntimeValue: ScalarAnalyticRuntimeValue + ScalarAd {}
51
52impl<T> GenericAdRuntimeValue for T where T: ScalarAnalyticRuntimeValue + ScalarAd {}
53
54#[doc(hidden)]
55pub trait RealAdRuntimeValue: GenericAdRuntimeValue + ScalarAd<Real = Self> + Float {}
56
57impl<T> RealAdRuntimeValue for T where T: GenericAdRuntimeValue + ScalarAd<Real = T> + Float {}
58
59#[doc(hidden)]
60pub trait LinalgRuntimeValue:
61 EinsumRuntimeValue + KernelLinalgScalar + CudaLinalgScalar + 'static
62{
63}
64
65impl<T> LinalgRuntimeValue for T where
66 T: EinsumRuntimeValue + KernelLinalgScalar + CudaLinalgScalar + 'static
67{
68}
69
70#[doc(hidden)]
71pub trait RealLinalgRuntimeValue:
72 LinalgRuntimeValue
73 + HasAlgebra<Algebra = Standard<Self>>
74 + LinalgScalar<Real = Self>
75 + Float
76 + KeepCountScalar
77{
78}
79
80impl<T> RealLinalgRuntimeValue for T where
81 T: LinalgRuntimeValue
82 + HasAlgebra<Algebra = Standard<T>>
83 + LinalgScalar<Real = T>
84 + Float
85 + KeepCountScalar
86{
87}
88
89#[doc(hidden)]
90pub trait ComplexLinalgRuntimeValue:
91 RealLinalgRuntimeValue + LinalgScalar<Complex = Complex<Self>>
92where
93 Complex<Self>: Scalar + DynTensorTyped,
94{
95}
96
97impl<T> ComplexLinalgRuntimeValue for T
98where
99 T: RealLinalgRuntimeValue + LinalgScalar<Complex = Complex<T>>,
100 Complex<T>: Scalar + DynTensorTyped,
101{
102}