-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update on "use-pt-pinned-commit for test-arm-{backend,reference}-dele…
…gation" Without this, these builds don't respect the torchgen pinned commit and thus fail with #7546. Differential Revision: [D67996459](https://our.internmc.facebook.com/intern/diff/D67996459/) [ghstack-poisoned]
- Loading branch information
Showing
54 changed files
with
2,687 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2ea4b56ec872424e486c4fe2d55da061067a2ed3 | ||
0a94bb432ed75cc2d950d81b2921363218a7e459 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2025 Arm Limited and/or its affiliates. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import torch | ||
from executorch.backends.arm.tosa_quant_utils import q_op | ||
from executorch.exir.dialects._ops import ops as exir_ops | ||
from executorch.exir.pass_base import ExportPass, PassResult | ||
from torch.fx import Node | ||
|
||
|
||
class FuseQuantizedActivationPass(ExportPass): | ||
def _is_fuseable_quantized_activation(self, node: Node): | ||
"""Fuse activations that have a 0 lower bound and quantized with a qmin zero-point""" | ||
is_fuseable = node.target == exir_ops.edge.aten.relu.default | ||
if node.target == exir_ops.edge.aten.hardtanh.default: | ||
min_val = node.args[1] | ||
is_fuseable = min_val == 0 | ||
|
||
is_quantized = len(node.users) == 1 and next(iter(node.users)).target == q_op | ||
if is_quantized: | ||
quant_node = next(iter(node.users)) | ||
zp = quant_node.args[2] | ||
qmin = quant_node.args[3] | ||
|
||
return is_fuseable and is_quantized and zp == qmin | ||
|
||
def _is_fuseable_input(self, node: Node): | ||
return ( | ||
node.target | ||
in ( | ||
exir_ops.edge.aten.convolution.default, | ||
exir_ops.edge.aten.linear.default, | ||
) | ||
and len(node.users) == 1 | ||
) | ||
|
||
def call(self, graph_module: torch.fx.GraphModule): | ||
modified = False | ||
for node in graph_module.graph.nodes: | ||
if node.op != "call_function": | ||
continue | ||
|
||
if not self._is_fuseable_quantized_activation(node): | ||
continue | ||
|
||
input_node = node.args[0] | ||
if not self._is_fuseable_input(input_node): | ||
continue | ||
|
||
node.replace_all_uses_with(input_node) | ||
graph_module.graph.erase_node(node) | ||
modified = True | ||
|
||
if modified: | ||
graph_module.recompile() | ||
graph_module = super().call(graph_module).graph_module | ||
|
||
return PassResult(graph_module, modified) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[run] | ||
omit = | ||
*__init__.py* | ||
|
||
[report] | ||
skip_covered = true | ||
exclude_also = | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.