pub fn sum<T: Tensor<Dtype = f32>>(t: T) -> Tensor0D<T::Tape>
Expand description

Sums all the values of the tensor. Returns a Tensor0D (i.e. one number).

Examples:

let t = Tensor2D::new([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]);
let r: Tensor0D = t.sum();
assert_eq!(r.data(), &21.0);