Skip to content

[ET-VK] fix index error bug in ViewCopyToSqueezeUnsqueezePass #8281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions backends/transforms/view_copy_to_squeeze_unsqueeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ def find_squeeze_dims(
i = 0
j = 0
idx = []
while i < len(input_shape):
if input_shape[i] != view_shape[j]:
if input_shape[i] == 1:
idx.append(i)
j -= 1
# continue to check remaining dims are equal
else:
return None
i += 1
j += 1
while i < len(input_shape) and j < len(view_shape):
if input_shape[i] == view_shape[j]:
i += 1
j += 1
elif input_shape[i] == 1:
# squeeze axis on i and check next dim
idx.append(i)
i += 1
else:
return None
# If there are remaining dimensions, shapes do not match
if i < len(input_shape) or j < len(view_shape):
return None
return idx

def find_unsqueeze_dim(
Expand Down
Loading