Skip to content

Commit 34223a0

Browse files
committed
Remove alias_copy op
1 parent 17cbef5 commit 34223a0

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

backends/qualcomm/_passes/remove_redundancy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def __init__(self):
2222
exir_ops.edge.aten.clone.default: self._default_condition,
2323
torch.ops.aten.alias.default: self._default_condition,
2424
exir_ops.edge.aten.alias.default: self._default_condition,
25+
exir_ops.edge.aten.alias_copy.default: self._default_condition,
2526
exir_ops.edge.aten.lift_fresh_copy.default: self._default_condition,
2627
# remove this target if '_skip_dim_order' is set to False
2728
exir_ops.edge.dim_order_ops._to_dim_order_copy.default: self._dim_order_op_condition,

backends/qualcomm/tests/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
# module with related operator only
1111

1212

13+
# Ensure alias_copy is removed in remove_redundancy pass
14+
class Alias(torch.nn.Module):
15+
def __init__(self):
16+
super().__init__()
17+
self.fc = torch.nn.Linear(10, 10)
18+
19+
def forward(self, x):
20+
alias_x = torch.ops.aten.alias.default(x)
21+
out = self.fc(alias_x)
22+
return out
23+
24+
1325
class And(torch.nn.Module):
1426
def __init__(self, pos, neg):
1527
super().__init__()

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ def test_qnn_backend_adaptive_avg_pool2d(self):
118118
sample_input = (torch.randn(1, 512, 7, 7),)
119119
self.lower_module_and_test_output(module, sample_input)
120120

121+
def test_qnn_backend_alias(self):
122+
module = Alias() # noqa: F405
123+
sample_input = (torch.randn(1, 10),)
124+
self.lower_module_and_test_output(module, sample_input)
125+
121126
def test_qnn_backend_amax(self):
122127
modules = [AMax(dim=1, keepdim=False), AMax(dim=1, keepdim=True)] # noqa: F405
123128
sample_input = (torch.randn(4, 4),)
@@ -1156,6 +1161,12 @@ def test_qnn_backend_adaptive_avg_pool2d(self):
11561161
module = self.get_qdq_module(module, sample_input)
11571162
self.lower_module_and_test_output(module, sample_input)
11581163

1164+
def test_qnn_backend_alias(self):
1165+
module = Alias() # noqa: F405
1166+
sample_input = (torch.randn(1, 10),)
1167+
module = self.get_qdq_module(module, sample_input)
1168+
self.lower_module_and_test_output(module, sample_input)
1169+
11591170
def test_qnn_backend_amax(self):
11601171
modules = [AMax(dim=1, keepdim=False), AMax(dim=1, keepdim=True)] # noqa: F405
11611172
sample_input = (torch.randn(4, 4),)

0 commit comments

Comments
 (0)