einsum_with_plan

Function einsum_with_plan 

Source
pub fn einsum_with_plan<Alg, Backend>(
    ctx: &mut BackendContext<Alg, Backend>,
    tree: &ContractionTree,
    operands: &[&Tensor<Alg::Scalar>],
    size_dict: Option<&HashMap<u32, usize>>,
) -> Result<Tensor<Alg::Scalar>>
where Alg: Semiring, Alg::Scalar: Scalar + Conjugate + HasAlgebra<Algebra = Alg>, Backend: EinsumBackend<Alg>, BackendContext<Alg, Backend>: TensorTempPoolContext,
Expand description

Execute einsum with a pre-optimized ContractionTree.

§Examples

use tenferro_algebra::Standard;
use tenferro_einsum::{einsum_with_plan, ContractionTree, Subscripts};
use tenferro_prims::{CpuBackend, CpuContext};

let mut ctx = CpuContext::new(1);
let subs = Subscripts::new(&[&[0, 1], &[1, 2]], &[0, 2]);
let tree = ContractionTree::optimize(&subs, &[&[2, 3], &[3, 4]]).unwrap();
let out = einsum_with_plan::<Standard<f64>, CpuBackend>(&mut ctx, &tree, &[&a, &b], None)
    .unwrap();