From a5717e9d3445282a6db2b3a6cb7c6dba02bac6ac Mon Sep 17 00:00:00 2001 From: Min Guo Date: Mon, 10 Feb 2025 13:18:25 -0800 Subject: [PATCH] oss qnn bug fix Summary: https://github.com/pytorch/executorch/pull/8304 1. the graph actually include the torch.ops.aten.silu.default not the torch.nn.functional.silu 2. the aten.mul.tensor is arg is scalar, this could apply to other ops Differential Revision: D69286388 --- backends/qualcomm/_passes/annotate_and_quant_scalar.py | 1 + backends/qualcomm/_passes/decompose_silu.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/qualcomm/_passes/annotate_and_quant_scalar.py b/backends/qualcomm/_passes/annotate_and_quant_scalar.py index 86475c39b12..9daaa4aa624 100644 --- a/backends/qualcomm/_passes/annotate_and_quant_scalar.py +++ b/backends/qualcomm/_passes/annotate_and_quant_scalar.py @@ -36,6 +36,7 @@ class AnnotateAndQuantScalar(ExportPass): torch.ops.aten.sub.Scalar, torch.ops.aten.mul.Scalar, torch.ops.aten.div.Scalar, + torch.ops.aten.mul.Tensor, "add", "sub", "mul", diff --git a/backends/qualcomm/_passes/decompose_silu.py b/backends/qualcomm/_passes/decompose_silu.py index d40f13a5923..890d965dec2 100644 --- a/backends/qualcomm/_passes/decompose_silu.py +++ b/backends/qualcomm/_passes/decompose_silu.py @@ -22,7 +22,9 @@ def _copy_meta(self, meta: Dict): def call(self, graph_module: torch.fx.GraphModule): graph = graph_module.graph - partitions = get_source_partitions(graph, [torch.nn.functional.silu]) + partitions = get_source_partitions( + graph, [torch.nn.functional.silu, torch.ops.aten.silu.default] + ) for _, src_partitions in partitions.items(): for src_partition in src_partitions: