burn_tensor/tensor/ops/
binary.rs

1use alloc::vec::Vec;
2
3/// Computes the output shape for binary operations with broadcasting support.
4pub fn binary_ops_shape(lhs: &[usize], rhs: &[usize]) -> Vec<usize> {
5    let mut shape_out = Vec::with_capacity(lhs.len());
6
7    for (l, r) in lhs.iter().zip(rhs.iter()) {
8        shape_out.push(usize::max(*l, *r));
9    }
10
11    shape_out
12}