Skip to content

Commit 9c1a52c

Browse files
authored
Fix export vit w/ QNN delegate
Differential Revision: D62012121 Pull Request resolved: #4997
1 parent cd8aed6 commit 9c1a52c

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

.ci/scripts/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ test_model_with_qnn() {
170170
elif [[ "${MODEL_NAME}" == "ic3" ]]; then
171171
EXPORT_SCRIPT=inception_v3
172172
EXPORTED_MODEL_NAME=ic3_qnn.pte
173+
elif [[ "${MODEL_NAME}" == "vit" ]]; then
174+
EXPORT_SCRIPT=torchvision_vit
175+
EXPORTED_MODEL_NAME=vit_qnn.pte
173176
fi
174177

175178
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m SM8550 --compile_only

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
# Separate default values from the workflow dispatch. To ensure defaults are accessible
8585
# during scheduled runs and to provide flexibility for different defaults between
8686
# on-demand and periodic benchmarking.
87-
CRON_DEFAULT_MODELS: "stories110M,dl3,mv3,mv2,ic4,ic3"
87+
CRON_DEFAULT_MODELS: "stories110M,dl3,mv3,mv2,ic4,ic3,vit"
8888
CRON_DEFAULT_DEVICES: "samsung_galaxy_s2x"
8989
CRON_DEFAULT_DELEGATES: "xnnpack,qnn"
9090
run: |

.github/workflows/trunk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jobs:
305305
strategy:
306306
matrix:
307307
dtype: [fp32]
308-
model: [dl3, mv3, mv2, ic4, ic3]
308+
model: [dl3, mv3, mv2, ic4, ic3, vit]
309309
fail-fast: false
310310
with:
311311
runner: linux.2xlarge

backends/qualcomm/partition/common_defs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
]
1818

1919
to_be_implemented_operator = [
20-
exir_ops.edge.aten.where.default,
20+
exir_ops.edge.aten.any.dim,
21+
exir_ops.edge.aten.eq.Scalar,
22+
exir_ops.edge.aten.full_like.default,
23+
exir_ops.edge.aten.logical_not.default,
24+
exir_ops.edge.aten.where.self,
2125
]
2226

2327
allow_list_operator = [

examples/qualcomm/scripts/torchvision_vit.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import json
88
import os
9+
import sys
910
from multiprocessing.connection import Client
1011

1112
import numpy as np
@@ -61,10 +62,14 @@ def main(args):
6162
os.makedirs(args.artifact, exist_ok=True)
6263

6364
data_num = 100
64-
inputs, targets, input_list = get_dataset(
65-
dataset_path=f"{args.dataset}",
66-
data_size=data_num,
67-
)
65+
if args.compile_only:
66+
inputs = [(torch.rand(1, 3, 224, 224),)]
67+
else:
68+
inputs, targets, input_list = get_dataset(
69+
dataset_path=f"{args.dataset}",
70+
data_size=data_num,
71+
)
72+
6873
pte_filename = "vit_qnn"
6974
instance = TorchVisionViTModel()
7075
build_executorch_binary(
@@ -77,6 +82,9 @@ def main(args):
7782
shared_buffer=args.shared_buffer,
7883
)
7984

85+
if args.compile_only:
86+
sys.exit(0)
87+
8088
adb = SimpleADB(
8189
qnn_sdk=os.getenv("QNN_SDK_ROOT"),
8290
build_path=f"{args.build_folder}",
@@ -126,13 +134,14 @@ def main(args):
126134
"for https://www.kaggle.com/datasets/ifigotin/imagenetmini-1000)"
127135
),
128136
type=str,
129-
required=True,
137+
required=False,
130138
)
131139
parser.add_argument(
132140
"-a",
133141
"--artifact",
134-
help="path for storing generated artifacts by this example. " "Default ./vit",
135-
default="./vit",
142+
help="path for storing generated artifacts by this example. "
143+
"Default ./torchvision_vit",
144+
default="./torchvision_vit",
136145
type=str,
137146
)
138147

0 commit comments

Comments
 (0)