Skip to content

Commit

Permalink
guard_size_oblivious in unbind (#124959)
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #124959
Approved by: https://github.com/albanD
  • Loading branch information
ezyang authored and pytorchmergebot committed Apr 25, 2024
1 parent c715e76 commit c4b6ed4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torch/_refs/__init__.py
Expand Up @@ -3890,12 +3890,14 @@ def unflatten(a: TensorLikeType, dim: int, sizes: ShapeType) -> TensorLikeType:

@register_decomposition(aten.unbind)
def unbind(t: TensorLikeType, dim: int = 0) -> TensorSequenceType:
from torch.fx.experimental.symbolic_shapes import guard_size_oblivious

dim = utils.canonicalize_dim(t.ndim, dim)
torch._check_index(
len(t.shape) > 0,
lambda: "Dimension specified as 0 but tensor has no dimensions",
)
if t.shape[dim] == 0:
if guard_size_oblivious(t.shape[dim] == 0):
return tuple()
else:
return tuple(
Expand Down

0 comments on commit c4b6ed4

Please sign in to comment.