Skip to content

Fix export vit w/ QNN delegate #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2024
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
3 changes: 3 additions & 0 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ test_model_with_qnn() {
elif [[ "${MODEL_NAME}" == "ic3" ]]; then
EXPORT_SCRIPT=inception_v3
EXPORTED_MODEL_NAME=ic3_qnn.pte
elif [[ "${MODEL_NAME}" == "vit" ]]; then
EXPORT_SCRIPT=torchvision_vit
EXPORTED_MODEL_NAME=vit_qnn.pte
fi

"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m SM8550 --compile_only
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
# Separate default values from the workflow dispatch. To ensure defaults are accessible
# during scheduled runs and to provide flexibility for different defaults between
# on-demand and periodic benchmarking.
CRON_DEFAULT_MODELS: "stories110M,dl3,mv3,mv2,ic4,ic3"
CRON_DEFAULT_MODELS: "stories110M,dl3,mv3,mv2,ic4,ic3,vit"
CRON_DEFAULT_DEVICES: "samsung_galaxy_s2x"
CRON_DEFAULT_DELEGATES: "xnnpack,qnn"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ jobs:
strategy:
matrix:
dtype: [fp32]
model: [dl3, mv3, mv2, ic4, ic3]
model: [dl3, mv3, mv2, ic4, ic3, vit]
fail-fast: false
with:
runner: linux.2xlarge
Expand Down
6 changes: 5 additions & 1 deletion backends/qualcomm/partition/common_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
]

to_be_implemented_operator = [
exir_ops.edge.aten.where.default,
exir_ops.edge.aten.any.dim,
exir_ops.edge.aten.eq.Scalar,
exir_ops.edge.aten.full_like.default,
exir_ops.edge.aten.logical_not.default,
exir_ops.edge.aten.where.self,
]

allow_list_operator = [
Expand Down
23 changes: 16 additions & 7 deletions examples/qualcomm/scripts/torchvision_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import json
import os
import sys
from multiprocessing.connection import Client

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

data_num = 100
inputs, targets, input_list = get_dataset(
dataset_path=f"{args.dataset}",
data_size=data_num,
)
if args.compile_only:
inputs = [(torch.rand(1, 3, 224, 224),)]
else:
inputs, targets, input_list = get_dataset(
dataset_path=f"{args.dataset}",
data_size=data_num,
)

pte_filename = "vit_qnn"
instance = TorchVisionViTModel()
build_executorch_binary(
Expand All @@ -77,6 +82,9 @@ def main(args):
shared_buffer=args.shared_buffer,
)

if args.compile_only:
sys.exit(0)

adb = SimpleADB(
qnn_sdk=os.getenv("QNN_SDK_ROOT"),
build_path=f"{args.build_folder}",
Expand Down Expand Up @@ -126,13 +134,14 @@ def main(args):
"for https://www.kaggle.com/datasets/ifigotin/imagenetmini-1000)"
),
type=str,
required=True,
required=False,
)
parser.add_argument(
"-a",
"--artifact",
help="path for storing generated artifacts by this example. " "Default ./vit",
default="./vit",
help="path for storing generated artifacts by this example. "
"Default ./torchvision_vit",
default="./torchvision_vit",
type=str,
)

Expand Down
Loading