Skip to content

Commit

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

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

0 comments on commit 8a93b6d

Please sign in to comment.