custom_binary_op

Function custom_binary_op 

Source
pub fn custom_binary_op<T, F>(
    x: &DenseND<T>,
    y: &DenseND<T>,
    op_fn: F,
) -> Result<DenseND<T>>
where T: Clone + Num, F: Fn(T, T) -> T,
Expand description

Custom element-wise binary operation with user-defined function

Applies a custom binary operation element-wise to two tensors with broadcasting support.

§Arguments

  • x - First input tensor
  • y - Second input tensor
  • op_fn - Binary operation function: (x_elem, y_elem) -> result_elem

§Example

// Custom operation: (x + y) / 2
custom_binary_op(&x, &y, |a, b| (a + b) / 2.0)?;