pub fn custom_reduce<T, F>(
input: &DenseND<T>,
axes: &[Axis],
init_value: T,
reduce_fn: F,
) -> Result<DenseND<T>>Expand description
Custom reduction operation with user-defined reduction function
§Arguments
input- Input tensoraxes- Axes along which to reduce (empty = reduce all)init_value- Initial value for the reductionreduce_fn- Binary reduction function: (accumulator, element) -> new_accumulator
§Example
ⓘ
// Compute product along axis 0
custom_reduce(&tensor, &[0], 1.0, |acc, x| acc * x)?;