Skip to content

Commit f24094e

Browse files
authored
Qualcomm AI Engine Direct - alias_copy op
Differential Revision: D73417415 Pull Request resolved: #10319
1 parent 098c58e commit f24094e

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
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.relu = torch.nn.ReLU()
18+
19+
def forward(self, x):
20+
alias_x = torch.ops.aten.alias.default(x)
21+
return self.relu(alias_x)
22+
23+
1324
class And(torch.nn.Module):
1425
def __init__(self, pos, neg):
1526
super().__init__()

backends/qualcomm/tests/test_qnn_delegate.py

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

127+
def test_qnn_backend_alias(self):
128+
module = Alias() # noqa: F405
129+
sample_input = (torch.randn(1, 10),)
130+
self.lower_module_and_test_output(module, sample_input)
131+
127132
def test_qnn_backend_amax(self):
128133
modules = [AMax(dim=1, keepdim=False), AMax(dim=1, keepdim=True)] # noqa: F405
129134
sample_input = (torch.randn(4, 4),)
@@ -1162,6 +1167,12 @@ def test_qnn_backend_adaptive_avg_pool2d(self):
11621167
module = self.get_qdq_module(module, sample_input)
11631168
self.lower_module_and_test_output(module, sample_input)
11641169

1170+
def test_qnn_backend_alias(self):
1171+
module = Alias() # noqa: F405
1172+
sample_input = (torch.randn(1, 10),)
1173+
module = self.get_qdq_module(module, sample_input)
1174+
self.lower_module_and_test_output(module, sample_input)
1175+
11651176
def test_qnn_backend_amax(self):
11661177
modules = [AMax(dim=1, keepdim=False), AMax(dim=1, keepdim=True)] # noqa: F405
11671178
sample_input = (torch.randn(4, 4),)

0 commit comments

Comments
 (0)