Skip to content

Commit 0ac4435

Browse files
authored
[ET-VK] Modifying should_squeeze function in SqueezeUnsqueezeInputs to not squeeze if significant axis are all 1 and trailing axis are all > 1.
Differential Revision: D75483587 Pull Request resolved: #11177
1 parent a5f894f commit 0ac4435

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

backends/vulkan/_passes/squeeze_unsqueeze_inputs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def should_squeeze(self, op, shape: List[int]) -> bool: # pyre-ignore
3232
return shape[1] == 1 and shape[0] > 1
3333
if len(shape) == 4:
3434
# No need to squeeze if all dims are 1 except the width dim
35-
if all(dim == 1 for dim in shape[:-1]):
35+
if shape[0] == shape[1] == shape[2] == 1:
36+
return False
37+
# No need to squeeze if batch and channel dims are 1 and height and width are > 1
38+
if shape[0] == shape[1] == 1 and shape[2] > 1 and shape[3] > 1:
39+
return False
40+
# No need to squeeze if batch dim is 1 and channel, height and width are > 1
41+
if shape[0] == 1 and shape[1] > 1 and shape[2] > 1 and shape[3] > 1:
3642
return False
3743
# Otherwise, check for squeezable dim
3844
return 1 in shape[:-1]

0 commit comments

Comments
 (0)