Skip to content

Commit

Permalink
Ref: Fix Dim.with_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Jan 5, 2025
1 parent ac78934 commit 921df39
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion phiml/math/_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,10 @@ def with_size(self, size, keep_item_names=True):
return Dim(self.name, None, self.dim_type, None)
if keep_item_names and _size_equal(self.size, size):
return self
return Dim(self.name, int(size), self.dim_type, None)
from ._tensors import Tensor
if not isinstance(size, Tensor):
size = int(size)
return Dim(self.name, size, self.dim_type, None)

def with_dim_size(self, dim: Union[str, 'Shape'], size: Union[int, 'math.Tensor', str, tuple, list], keep_item_names=True):
name = dim.name if isinstance(dim, SHAPE_TYPES) else dim
Expand Down

0 comments on commit 921df39

Please sign in to comment.