File: leanpass/tensor.py
Both mean and sum use np.expand_dims(grad, axis=axis) when axis is not None. np.expand_dims only accepts an integer axis, so passing a tuple (e.g., axis=(0,2)) raises a TypeError. This deviates from NumPy’s behavior where tuple axes are allowed for reduction operations.
Fix: replace the expand_dims call with np.reshape or manually add new axes for each dimension in the tuple, then broadcast the gradient.
Impact: Users cannot compute means or sums over multiple axes while retaining gradient flow.
Filed automatically by ai-issue-scan.
File:
leanpass/tensor.pyBoth
meanandsumusenp.expand_dims(grad, axis=axis)whenaxisis notNone.np.expand_dimsonly accepts an integer axis, so passing a tuple (e.g.,axis=(0,2)) raises aTypeError. This deviates from NumPy’s behavior where tuple axes are allowed for reduction operations.Fix: replace the
expand_dimscall withnp.reshapeor manually add new axes for each dimension in the tuple, then broadcast the gradient.Impact: Users cannot compute means or sums over multiple axes while retaining gradient flow.
Filed automatically by ai-issue-scan.