pub trait TypedTensorReadEinsumExt<T: TensorScalar> {
// Required methods
fn einsum_read<B: TensorBackend>(
&self,
subscripts: &str,
backend: &mut B,
) -> Result<TypedTensor<T>>;
fn einsum_read_subscripts<B: TensorBackend>(
&self,
subscripts: &EinsumSubscripts,
backend: &mut B,
) -> Result<TypedTensor<T>>;
}Expand description
Backend-explicit einsum methods for typed borrowed views.
The _read suffix distinguishes this borrowed-view surface from
TypedTensorEinsumExt, whose unsuffixed methods accept only owned compact
typed tensors.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_einsum::TypedTensorReadEinsumExt;
use tenferro_tensor::TypedTensor;
let lhs = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![1.0, 2.0])?;
let rhs = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![3.0, 4.0])?;
let mut backend = CpuBackend::new();
let result = [lhs.as_view(), rhs.as_view()].einsum_read("i,i->", &mut backend)?;
assert_eq!(result.as_slice()?, &[11.0]);Required Methods§
Sourcefn einsum_read<B: TensorBackend>(
&self,
subscripts: &str,
backend: &mut B,
) -> Result<TypedTensor<T>>
fn einsum_read<B: TensorBackend>( &self, subscripts: &str, backend: &mut B, ) -> Result<TypedTensor<T>>
Execute an einsum from string notation over typed borrowed views.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_einsum::TypedTensorReadEinsumExt;
use tenferro_tensor::TypedTensor;
let input = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![2.0, 3.0])?;
let mut backend = CpuBackend::new();
let result = [input.as_view()].einsum_read("i->i", &mut backend)?;
assert_eq!(result.as_slice()?, &[2.0, 3.0]);§Errors
Returns Error::InvalidSubscripts for malformed notation,
Error::Validation with shape or rank payloads for incompatible
views, or Error::Tensor for a typed backend failure.
Sourcefn einsum_read_subscripts<B: TensorBackend>(
&self,
subscripts: &EinsumSubscripts,
backend: &mut B,
) -> Result<TypedTensor<T>>
fn einsum_read_subscripts<B: TensorBackend>( &self, subscripts: &EinsumSubscripts, backend: &mut B, ) -> Result<TypedTensor<T>>
Execute an einsum from parsed integer-label subscripts over typed borrowed views.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_einsum::{EinsumSubscripts, TypedTensorReadEinsumExt};
use tenferro_tensor::TypedTensor;
let input = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![2.0, 3.0])?;
let subscripts = EinsumSubscripts::new(&[&[0]], &[0]);
let mut backend = CpuBackend::new();
let result = [input.as_view()].einsum_read_subscripts(&subscripts, &mut backend)?;
assert_eq!(result.as_slice()?, &[2.0, 3.0]);§Errors
Returns Error::Validation with shape or rank payloads for
incompatible views, or Error::Tensor for a typed backend failure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.