pub trait CoreRepr: Repr {
type Real;
type Bool;
// Required methods
fn wrap_value_of(op: &'static str, t: Tensor) -> Result<Self::Value>;
fn wrap_real(op: &'static str, t: Tensor) -> Result<Self::Real>;
fn wrap_bool(op: &'static str, t: Tensor) -> Result<Self::Bool>;
}Expand description
The core result types for an input representation.
Erased returns Tensor everywhere. Typed<T> returns
TypedTensor<T::Real> for real-valued results (abs) and
TypedTensor<bool> for predicates (compare).
§Examples
use tenferro_runtime::CoreRepr;
use tenferro_tensor::{Erased, Tensor, Typed};
let t = Tensor::from_vec_col_major(vec![1], vec![true])?;
let erased = <Erased as CoreRepr>::wrap_bool("compare", t.duplicate()?)?;
let typed = <Typed<f64> as CoreRepr>::wrap_bool("compare", t.duplicate()?)?;
assert_eq!(erased.shape(), typed.shape());
// A typed result of another dtype is a validation error naming the op.
assert!(<Typed<f64> as CoreRepr>::wrap_value_of("add", t).is_err());Required Associated Types§
Required Methods§
Sourcefn wrap_value_of(op: &'static str, t: Tensor) -> Result<Self::Value>
fn wrap_value_of(op: &'static str, t: Tensor) -> Result<Self::Value>
Wrap the erased result of op in this representation’s value type;
typed representations check the dtype.
§Errors
Returns Error::Validation with ValidationError::DTypeMismatch (op
op) when a typed representation receives a tensor of another dtype.
§Examples
use tenferro_runtime::CoreRepr;
use tenferro_tensor::{Tensor, Typed};
let t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Typed<f64> as CoreRepr>::wrap_value_of("add", t.duplicate()?).is_ok());
assert!(<Typed<f32> as CoreRepr>::wrap_value_of("add", t).is_err());Sourcefn wrap_real(op: &'static str, t: Tensor) -> Result<Self::Real>
fn wrap_real(op: &'static str, t: Tensor) -> Result<Self::Real>
Wrap the erased real-valued result of op; typed representations
check the dtype.
§Errors
Returns Error::Validation with ValidationError::DTypeMismatch when a
typed representation receives a tensor of another dtype.
§Examples
use tenferro_runtime::CoreRepr;
use tenferro_tensor::{Tensor, Typed};
let t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Typed<f64> as CoreRepr>::wrap_real("abs", t.duplicate()?).is_ok());
assert!(<Typed<f32> as CoreRepr>::wrap_real("abs", t).is_err());Sourcefn wrap_bool(op: &'static str, t: Tensor) -> Result<Self::Bool>
fn wrap_bool(op: &'static str, t: Tensor) -> Result<Self::Bool>
Wrap the erased predicate result of op; typed representations check
the dtype.
§Errors
Returns Error::Validation with ValidationError::DTypeMismatch when a
typed representation receives a tensor of another dtype.
§Examples
use tenferro_runtime::CoreRepr;
use tenferro_tensor::{Tensor, Typed};
let flags = Tensor::from_vec_col_major(vec![2], vec![true, false])?;
assert!(<Typed<f64> as CoreRepr>::wrap_bool("compare", flags).is_ok());
let real = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Typed<f64> as CoreRepr>::wrap_bool("compare", real).is_err());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".