Skip to content

Commit 5d1f963

Browse files
committed
Simplify B.mean for PyTorch (closes #21)
1 parent 60fde3e commit 5d1f963

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lab/torch/generic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,8 @@ def prod(a: Numeric, axis: Union[Int, None] = None, squeeze: bool = True):
291291

292292
@dispatch
293293
def mean(a: Numeric, axis: Union[Int, None] = None, squeeze: bool = True):
294-
if axis is None:
295-
return torch.mean(a)
296-
else:
297-
return torch.mean(a, dim=axis, keepdim=not squeeze)
294+
# Only `torch.mean` allows `dim=None`. The other functions don't.
295+
return torch.mean(a, dim=axis, keepdim=not squeeze)
298296

299297

300298
@dispatch

0 commit comments

Comments
 (0)