module ops
Arithmetic operators over Tensor: +, -, *, / and unary -,
in every reference/value combination, with f64 / i64 right-hand
scalars. An operator panics on a runtime failure (there is no way to
spell ? inside a + b); code that propagates errors calls the
f_tensor_add / f_tensor_mul / ... wrappers directly and keeps the
Result channel.
Operands are NEVER invalidated: an operator reads its inputs through
shared handles, and a by-value operand is dropped (released)
after the call. Both operands must come from the same Api.
let a = api.tensor_full(&[2, 2], 3.0, f32_)?;
let b = api.tensor_full(&[2, 2], 4.0, f32_)?;
let c = &a + &b; // 7.0 everywhere; `a` and `b` stay usable
let d = &c * 2.0;
let e = -&d;
IntoOperand (trait)
A right-hand operand: a tensor (borrowed; the handle stays valid) or a scalar. The conversions let one operator impl serve every operand kind.