Skip to content
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

Arm backend: Fix bug in ConvertExpandCopyToRepeatPass #7199

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions backends/arm/_passes/convert_expand_copy_to_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def call_operator(self, op, args, kwargs, meta):
]

# To convert expand arg to repeat arg, non-repeated dims should have
# multiples[dim] = 1.
# multiples[dim] = 1. Passing -1 to expand arg means
# not changing the size of that dimension.
multiples = [
multiples[i] if extended_shape[i] == 1 else 1 for i in range(expanded_rank)
multiples[i] if multiples[i] != -1 and extended_shape[i] == 1 else 1
for i in range(expanded_rank)
]
return super().call_operator(
op=self.repeat, args=(args[0], multiples), kwargs=kwargs, meta=meta
Expand Down
1 change: 1 addition & 0 deletions backends/arm/test/ops/test_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Expand(torch.nn.Module):
(torch.ones(1, 1, 2, 2), (4, 3, -1, 2)),
(torch.ones(1), (2, 2, 4)),
(torch.ones(3, 2, 4, 1), (-1, -1, -1, 3)),
(torch.ones(1, 1, 192), (1, -1, -1)),
]

def forward(self, x: torch.Tensor, multiples: Sequence):
Expand Down
Loading