Skip to main content

binary_op

Function binary_op 

Source
pub fn binary_op<F32Op, F64Op>(
    lhs: HostTensor,
    rhs: HostTensor,
    f32_op: F32Op,
    f64_op: F64Op,
    simd_hint: Option<BinaryOp>,
) -> HostTensor
where F32Op: Fn(f32, f32) -> f32 + Copy, F64Op: Fn(f64, f64) -> f64 + Copy,
Expand description

Apply a binary operation element-wise to two tensors.

Requires tensors to have the same shape. Uses SIMD acceleration for f32 when available and both tensors are contiguous.

Pass simd_hint to enable direct SIMD dispatch for standard ops (add/sub/mul/div). Pass None for custom operations that have no SIMD fast path.