Skip to main content

EinsumInputs

Trait EinsumInputs 

Source
pub trait EinsumInputs: Sealed {
    type Repr: Repr;

    // Required method
    fn reads(&self) -> Vec<TensorRead<'_>>;
}
Expand description

The input list of a concrete einsum: a slice or array of values that implement AsView with one representation. Mix owned tensors and views by borrowing every element ([a.as_read(), b]); that copies no data.

§Examples

use tenferro_einsum::EinsumInputs;
use tenferro_tensor::Tensor;

let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let inputs = [&a, &a];
assert_eq!(inputs.reads().len(), 2);

Required Associated Types§

Source

type Repr: Repr

Representation of the inputs, which the result takes.

Required Methods§

Source

fn reads(&self) -> Vec<TensorRead<'_>>

Borrow every input; metadata only, never copies element data.

§Examples
use tenferro_einsum::EinsumInputs;
use tenferro_tensor::Tensor;

let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let b = Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0])?;
let inputs = vec![a, b];
let reads = inputs.reads();
assert_eq!(reads[0].shape(), &[2]);
assert_eq!(reads[1].shape(), &[3]);

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<X: AsView, const N: usize> EinsumInputs for [X; N]

Source§

type Repr = <X as AsView>::Repr

Source§

fn reads(&self) -> Vec<TensorRead<'_>>

Source§

impl<X: AsView> EinsumInputs for Vec<X>

Source§

type Repr = <X as AsView>::Repr

Source§

fn reads(&self) -> Vec<TensorRead<'_>>

Source§

impl<X: AsView> EinsumInputs for [X]

Source§

type Repr = <X as AsView>::Repr

Source§

fn reads(&self) -> Vec<TensorRead<'_>>

Implementors§