Skip to content

Commit

Permalink
fix: re-write ivy.Shape.numel to make it traceable
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam-Armstrong committed Jul 10, 2024
1 parent a373675 commit ae17824
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,9 @@ def numel(self):
raise ivy.utils.exceptions.IvyException(
"Cannot calculate the number of elements in a partially known Shape"
)
res = 1
for dim in self._shape:
res *= dim
return res
if self.rank > 0:
return ivy.prod(self._shape, dtype=ivy.int64).to_scalar()
return 1

def __concat__(self, other):
return self.concatenate(other)
Expand Down

0 comments on commit ae17824

Please sign in to comment.