Skip to content
Merged
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
8 changes: 4 additions & 4 deletions backends/qualcomm/_passes/decompose_silu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def __init__(self):
def call(self, graph_module: torch.fx.GraphModule):
graph = graph_module.graph
for node in graph.nodes:
if (
node.op == "call_function"
and node.target == torch.ops.aten.silu.default
):
if node.op == "call_function" and node.target in {
torch.ops.aten.silu.default,
torch.ops.aten.silu_.default,
}:
silu_node = node
silu_node_input = node.args[0]
with graph_module.graph.inserting_after(silu_node_input):
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/_passes/qnn_pass_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_capture_program_passes():
(DecomposeAny, True),
(DecomposeColIm, True),
(DecomposeMinMaxDim, True),
(ExpandBroadcastTensorShape, False),
(ExpandBroadcastTensorShape, True),
(FixedLinearKeepDim, True),
(FoldQDQ, True),
(I64toI32, True),
Expand Down
19 changes: 4 additions & 15 deletions backends/qualcomm/tests/test_qnn_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@
from collections import defaultdict
from typing import List

from executorch.backends.qualcomm._passes import (
ExpandBroadcastTensorShape,
FoldQDQ,
TagQuantIO,
)
from executorch.backends.qualcomm._passes import FoldQDQ, TagQuantIO
from executorch.backends.qualcomm.builders.node_visitor_manager import get_node_visitors
from executorch.backends.qualcomm.debugger.utils import DrawGraph
from executorch.examples.models.deeplab_v3 import DeepLabV3ResNet101Model
Expand Down Expand Up @@ -645,16 +641,12 @@ def test_qnn_backend_expand(self):
(torch.randn([3, 1]),),
(torch.randn([4]),),
]
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
index = 0
for module in modules:
for sample_input in sample_inputs:
with self.subTest(i=index):
index += 1
self.lower_module_and_test_output(
module, sample_input, passes_job=passes_job
)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_expm1(self):
sample_input = (torch.randn(3, 4, 5),)
Expand Down Expand Up @@ -2539,17 +2531,13 @@ def test_qnn_backend_expand(self):
(torch.randn([3, 1]),),
(torch.randn([4]),),
]
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
index = 0
for module in modules:
for sample_input in sample_inputs:
with self.subTest(i=index):
index += 1
module = self.get_qdq_module(module, sample_input)
self.lower_module_and_test_output(
module, sample_input, passes_job=passes_job
)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_expm1(self):
sample_input = (torch.randn(3, 4, 5),)
Expand Down Expand Up @@ -6587,6 +6575,7 @@ def test_efficientnet(self):
self.assertGreaterEqual(msg["top_1"], 61)
self.assertGreaterEqual(msg["top_5"], 88)

@unittest.skip("Bad accuracy, need investigation")
def test_efficientSAM(self):
if not self.required_envs(
[self.image_dataset, self.pretrained_weight, self.oss_repo]
Expand Down
12 changes: 2 additions & 10 deletions examples/qualcomm/oss_scripts/conv_former.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
import numpy as np
import timm
import torch
from executorch.backends.qualcomm._passes.expand_broadcast_tensor_shape import (
ExpandBroadcastTensorShape,
)
from executorch.backends.qualcomm._passes.qnn_pass_manager import (
get_capture_program_passes,
)
from executorch.backends.qualcomm.quantizer.quantizer import QuantDtype
from executorch.backends.qualcomm.utils.constants import QCOM_PASS_ACTIVATE_KEY
from executorch.examples.qualcomm.utils import (
build_executorch_binary,
get_imagenet_dataset,
Expand Down Expand Up @@ -59,16 +52,15 @@ def main(args):
model = model.eval()

# lower to QNN
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
build_executorch_binary(
model,
inputs[0],
args.model,
f"{args.artifact}/{pte_filename}",
inputs,
quant_dtype=QuantDtype.use_8a8w,
passes_job=passes_job,
skip_node_id_set=skip_node_id_set,
skip_node_op_set=skip_node_op_set,
)

if args.compile_only:
Expand Down
10 changes: 0 additions & 10 deletions examples/qualcomm/oss_scripts/convnext_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
import torch
import torchvision

from executorch.backends.qualcomm._passes.expand_broadcast_tensor_shape import (
ExpandBroadcastTensorShape,
)
from executorch.backends.qualcomm._passes.qnn_pass_manager import (
get_capture_program_passes,
)
from executorch.backends.qualcomm.quantizer.quantizer import QuantDtype
from executorch.backends.qualcomm.utils.constants import QCOM_PASS_ACTIVATE_KEY
from executorch.examples.qualcomm.utils import (
build_executorch_binary,
get_imagenet_dataset,
Expand Down Expand Up @@ -54,8 +47,6 @@ def main(args):

pte_filename = "convnext_small_qnn_q8"
instance = torchvision.models.convnext_small(weights="IMAGENET1K_V1").eval()
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
build_executorch_binary(
instance,
inputs[0],
Expand All @@ -66,7 +57,6 @@ def main(args):
quant_dtype=QuantDtype.use_8a8w,
per_channel_linear=True,
),
passes_job=passes_job,
shared_buffer=args.shared_buffer,
)

Expand Down
8 changes: 0 additions & 8 deletions examples/qualcomm/oss_scripts/efficientSAM/efficientSAM.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

import numpy as np
import torch
from executorch.backends.qualcomm._passes import ExpandBroadcastTensorShape
from executorch.backends.qualcomm._passes.qnn_pass_manager import (
get_capture_program_passes,
)
from executorch.backends.qualcomm.utils.constants import QCOM_PASS_ACTIVATE_KEY
from executorch.examples.qualcomm.oss_scripts.efficientSAM.source_transformation import (
replace_maskdecoder_with_custom_op,
replace_pos_emb_with_custom_op,
Expand Down Expand Up @@ -236,8 +231,6 @@ def main(args):
pte_filename = "efficientSAM_qnn"

# lower to QNN
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
build_executorch_binary(
model,
inputs[0],
Expand All @@ -246,7 +239,6 @@ def main(args):
dataset=inputs,
skip_node_id_set=skip_node_id_set,
skip_node_op_set=skip_node_op_set,
passes_job=passes_job,
shared_buffer=args.shared_buffer,
)

Expand Down
10 changes: 0 additions & 10 deletions examples/qualcomm/oss_scripts/fastvit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@

import numpy as np
import torch
from executorch.backends.qualcomm._passes.expand_broadcast_tensor_shape import (
ExpandBroadcastTensorShape,
)

from executorch.backends.qualcomm._passes.qnn_pass_manager import (
get_capture_program_passes,
)
from executorch.backends.qualcomm.quantizer.annotators import (
QuantizationConfig,
QuantizationSpec,
Expand All @@ -31,7 +25,6 @@
)

from executorch.backends.qualcomm.quantizer.quantizer import QuantDtype
from executorch.backends.qualcomm.utils.constants import QCOM_PASS_ACTIVATE_KEY
from executorch.backends.qualcomm.utils.utils import convert_linear_to_conv2d
from executorch.examples.qualcomm.utils import (
build_executorch_binary,
Expand Down Expand Up @@ -113,8 +106,6 @@ def main(args):
)

# lower to QNN
passes_job = get_capture_program_passes()
passes_job[ExpandBroadcastTensorShape][QCOM_PASS_ACTIVATE_KEY] = True
build_executorch_binary(
convert_linear_to_conv2d(get_instance(args.oss_repo, args.pretrained_weight)),
inputs[0],
Expand All @@ -125,7 +116,6 @@ def main(args):
skip_node_op_set=skip_node_op_set,
quant_dtype=QuantDtype.use_8a8w,
custom_quantizer=quantizer,
passes_job=passes_job,
shared_buffer=args.shared_buffer,
)

Expand Down
4 changes: 1 addition & 3 deletions examples/qualcomm/util_scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ def main():
"--pass_job",
nargs="+",
type=str,
help=(
'Add extra passes for model lowering. e.g. "ExpandBroadcastTensorShape".'
),
help=('Add extra passes for model lowering. e.g. "TagQuantIO".'),
)
sub_compile.add_argument(
"--shared_buffer",
Expand Down
Loading