pub fn add<T: Scalar, B: ElementwiseOps<T>>(
a: &Tensor<T, B>,
b: &Tensor<T, B>,
backend: &B,
) -> Result<Tensor<T, B>, B::Error>Expand description
Element-wise addition.
ยงExamples
use coeus_tensor::Tensor;
use coeus_core::SequentialBackend;
use coeus_ops::add;
let backend = SequentialBackend::new();
let a = Tensor::<f32, SequentialBackend>::from_slice([2], &[1.0, 2.0])
.expect("example tensor allocation succeeds");
let b = Tensor::<f32, SequentialBackend>::from_slice([2], &[3.0, 4.0])
.expect("example tensor allocation succeeds");
let c = add(&a, &b, &backend).expect("example addition succeeds");
assert_eq!(c.as_slice(), &[4.0, 6.0]);