pub fn scalar_binary_into<T, Op>(
op: &'static str,
destination: &mut TypedTensor<T, DynRank, Host>,
lhs: &TypedTensor<T, DynRank, Host>,
rhs: &TypedTensor<T, DynRank, Host>,
) -> Result<(), Error>Expand description
Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Apply a named binary operation elementwise into a caller-owned destination.
The destination, the two operands, and the operation are all the caller’s.
The traversal is the same zip_map2_into body the preset scalar types use
through the typed pool; only the destination’s origin differs. The operation
is a type rather than a closure so the instantiation depends on the element
type and the operation, not on the call site.
§Examples
use tenferro_internal_cpu_kernels::scalar_ops::{scalar_binary_into, AddOp};
use tenferro_tensor::{DynRank, Host, TypedTensor};
let lhs = TypedTensor::<_, DynRank, Host>::from_host_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let rhs = TypedTensor::<_, DynRank, Host>::from_host_vec_col_major(vec![2], vec![10.0_f64, 20.0])?;
let mut out = TypedTensor::<_, DynRank, Host>::from_host_vec_col_major(vec![2], vec![0.0_f64, 0.0])?;
scalar_binary_into::<f64, AddOp>("add", &mut out, &lhs, &rhs)?;
assert_eq!(out.as_slice(), &[11.0, 22.0]);§Errors
Returns [Error::Validation] when the destination shape does not match the operands’,
or [Error::BackendSource] when the underlying strided traversal rejects the views.