File: leanpass/tensor.py
Both Tensor.sum and Tensor.mean assume axis is either None or a single integer. When a tuple of axes is supplied (e.g., axis=(1,2)), the backward pass calls np.expand_dims(grad, axis=axis) which raises a TypeError. This breaks expected NumPy‑style behavior. The implementation should iterate over the tuple or use np.expand_dims in a loop to correctly reshape the gradient before broadcasting.
Filed automatically by ai-issue-scan.
File:
leanpass/tensor.pyBoth
Tensor.sumandTensor.meanassumeaxisis eitherNoneor a single integer. When a tuple of axes is supplied (e.g.,axis=(1,2)), the backward pass callsnp.expand_dims(grad, axis=axis)which raises aTypeError. This breaks expected NumPy‑style behavior. The implementation should iterate over the tuple or usenp.expand_dimsin a loop to correctly reshape the gradient before broadcasting.Filed automatically by ai-issue-scan.