pub fn einsum_binary_into<Alg, Backend>(
ctx: &mut BackendContext<Alg, Backend>,
subscripts: &str,
left: &Tensor<Alg::Scalar>,
right: &Tensor<Alg::Scalar>,
alpha: Alg::Scalar,
beta: Alg::Scalar,
output: &mut Tensor<Alg::Scalar>,
size_dict: Option<&HashMap<u32, usize>>,
) -> Result<()>where
Alg: Semiring,
Alg::Scalar: Scalar + Conjugate + HasAlgebra<Algebra = Alg>,
Backend: EinsumBackend<Alg>,
BackendContext<Alg, Backend>: TensorTempPoolContext,Expand description
Execute a binary einsum and accumulate into an existing output buffer.
Computes output = alpha * einsum(left, right) + beta * output.
§Examples
ⓘ
use tenferro_algebra::Standard;
use tenferro_einsum::einsum_binary_into;
use tenferro_device::LogicalMemorySpace;
use tenferro_tensor::{MemoryOrder, Tensor};
use tenferro_prims::{CpuBackend, CpuContext};
let mut ctx = CpuContext::new(1);
let col = MemoryOrder::ColumnMajor;
let a = Tensor::<f64>::from_slice(&[1.0, 2.0, 3.0, 4.0], &[2, 2], col).unwrap();
let b = Tensor::<f64>::from_slice(&[5.0, 6.0, 7.0, 8.0], &[2, 2], col).unwrap();
let mut c = Tensor::<f64>::zeros(&[2, 2], LogicalMemorySpace::MainMemory, col).unwrap();
einsum_binary_into::<Standard<f64>, CpuBackend>(
&mut ctx, "ij,jk->ik", &a, &b, 1.0, 0.0, &mut c, None
)
.unwrap();