From 00db9de4b05c4e794544ba0641f014c0140742d4 Mon Sep 17 00:00:00 2001 From: Angela Yi Date: Wed, 8 May 2024 23:07:25 -0700 Subject: [PATCH] Catch check on symbolic shapes (#3537) Summary: Fixing P1215895395 Reviewed By: tarun292 Differential Revision: D56325190 --- exir/tensor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exir/tensor.py b/exir/tensor.py index ee2633654e8..ee074cf7119 100644 --- a/exir/tensor.py +++ b/exir/tensor.py @@ -37,7 +37,11 @@ def contiguous_stride_from_shape(shape: torch.Size) -> Tuple[int]: strides.append(accum) # For sizes[i] == 0, treat it as 1 to be consistent with core Pytorch # This preserves the PT equivalent behavior for dims with 0 elements - if sz != 0: + if isinstance(sz, int): + if sz != 0: + accum *= sz + else: + # Unbacked symints may error on the != 0 check accum *= sz return tuple(reversed(strides))