Skip to content

Commit f8c674d

Browse files
committed
Qualcomm AI Engine Direct - CI for Non-LLM GA model Part1
1 parent 44d2643 commit f8c674d

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

.ci/scripts/test_model.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ test_model_with_qnn() {
201201
exit 1
202202
fi
203203

204+
SCRIPT_FOLDER=""
205+
case "${MODEL_NAME}" in
206+
"dl3"|"mv3"|"mv2"|"ic4"|"ic3"|"vit"|"mb"|"w2l")
207+
SCRIPT_FOLDER=scripts
208+
;;
209+
"deit"|"pvt"|"swin")
210+
SCRIPT_FOLDER=oss_scripts
211+
;;
212+
*)
213+
echo "Unsupported model $MODEL_NAME"
214+
exit 1
215+
;;
216+
esac
217+
218+
204219
# Use SM8450 for S22, SM8550 for S23, and SM8560 for S24
205220
# TODO(guangyang): Make QNN chipset matches the target device
206221
QNN_CHIPSET=SM8450

.github/workflows/trunk.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,32 @@ jobs:
479479
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
480480
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
481481
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
482+
483+
test-qnn-optimum-model:
484+
name: test-qnn-optimum-model
485+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
486+
permissions:
487+
id-token: write
488+
contents: read
489+
strategy:
490+
matrix:
491+
dtype: [fp32]
492+
model: [deit, pvt, swin]
493+
fail-fast: false
494+
with:
495+
runner: linux.2xlarge
496+
docker-image: executorch-ubuntu-22.04-qnn-sdk
497+
submodules: 'recursive'
498+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
499+
timeout: 900
500+
script: |
501+
# The generic Linux job chooses to use base env, not the one setup by the image
502+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
503+
conda activate "${CONDA_ENV}"
504+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool cmake
505+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
506+
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
507+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
482508
483509
test-qnn-optimum-model:
484510
name: test-qnn-optimum-model

backends/qualcomm/builders/op_slice_copy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def define_node(
5656
if start < 0:
5757
start = start % input_tensor.shape[dim]
5858

59-
if len(node.args) > 3:
59+
if len(node.args) > 3 and node.args[3] is not None:
6060
end = min(cast(int, node.args[3]), input_tensor.shape[dim])
6161
if end < 0:
6262
end = end % input_tensor.shape[dim]

examples/qualcomm/oss_scripts/deit.py

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

77
import getpass
88
import json
9+
import logging
910
import os
1011
from multiprocessing.connection import Client
1112

1213
import numpy as np
14+
import torch
1315
from executorch.backends.qualcomm._passes.qnn_pass_manager import (
1416
get_capture_program_passes,
1517
)
@@ -46,12 +48,19 @@ def main(args):
4648
data_num = 100
4749
height = config.image_size
4850
width = config.image_size
49-
inputs, targets, input_list = get_imagenet_dataset(
50-
dataset_path=f"{args.dataset}",
51-
data_size=data_num,
52-
image_shape=(height, width),
53-
crop_size=(height, width),
54-
)
51+
52+
if args.ci:
53+
inputs = [(torch.rand(1, 3, height, width),)]
54+
logging.warning(
55+
"This option is for CI to verify the export flow. It uses random input and will result in poor accuracy."
56+
)
57+
else:
58+
inputs, targets, input_list = get_imagenet_dataset(
59+
dataset_path=f"{args.dataset}",
60+
data_size=data_num,
61+
image_shape=(height, width),
62+
crop_size=(height, width),
63+
)
5564

5665
# Get the Deit model.
5766
model = get_instance()
@@ -134,7 +143,7 @@ def main(args):
134143
"for https://www.kaggle.com/datasets/ifigotin/imagenetmini-1000)"
135144
),
136145
type=str,
137-
required=True,
146+
required=False,
138147
)
139148

140149
args = parser.parse_args()

examples/qualcomm/oss_scripts/swin_transformer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def main(args):
8989

9090
data_num = 100
9191
if args.ci:
92-
inputs = [torch.rand(1, 3, 224, 224)]
92+
inputs = [(torch.rand(1, 3, 224, 224),)]
9393
logging.warning(
9494
"This option is for CI to verify the export flow. It uses random input and will result in poor accuracy."
9595
)
@@ -181,8 +181,9 @@ def main(args):
181181
parser.add_argument(
182182
"-a",
183183
"--artifact",
184-
help="path for storing generated artifacts by this example. " "Default ./swin",
185-
default="./swin",
184+
help="path for storing generated artifacts by this example. "
185+
"Default ./swin_transformer",
186+
default="./swin_transformer",
186187
type=str,
187188
)
188189

0 commit comments

Comments
 (0)