Skip to content

Commit e0f7b35

Browse files
author
Guang Yang
committed
Fix reporting backends and dtyep to benchmark results
1 parent 0d1250a commit e0f7b35

File tree

9 files changed

+86
-16
lines changed

9 files changed

+86
-16
lines changed

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ else
171171
fi
172172

173173
# Check dtype.
174-
EXPORTED_MODEL_NAME="llama2"
174+
EXPORTED_MODEL_NAME="tinyllama_${MODE}_${DTYPE}"
175175
if [[ "${DTYPE}" == "fp16" ]]; then
176176
EXPORTED_MODEL_NAME="${EXPORTED_MODEL_NAME}_h"
177177
elif [[ "${DTYPE}" == "bf16" ]]; then

.ci/scripts/test_model.sh

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,32 +152,34 @@ test_model_with_qnn() {
152152

153153
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/
154154
export PYTHONPATH=$EXECUTORCH_ROOT/..
155+
# QNN support float16 only
156+
DTYPE=float16
155157

156158
if [[ "${MODEL_NAME}" == "dl3" ]]; then
157159
EXPORT_SCRIPT=deeplab_v3
158-
EXPORTED_MODEL_NAME=dlv3_qnn.pte
160+
EXPORTED_MODEL_NAME=dl3_qnn_${DTYPE}.pte
159161
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
160162
EXPORT_SCRIPT=mobilenet_v3
161-
EXPORTED_MODEL_NAME=mv3_qnn.pte
163+
EXPORTED_MODEL_NAME=mv3_qnn_${DTYPE}.pte
162164
elif [[ "${MODEL_NAME}" == "mv2" ]]; then
163165
EXPORT_SCRIPT=mobilenet_v2
164-
EXPORTED_MODEL_NAME=mv2_qnn.pte
166+
EXPORTED_MODEL_NAME=mv2_qnn_${DTYPE}.pte
165167
elif [[ "${MODEL_NAME}" == "ic4" ]]; then
166168
EXPORT_SCRIPT=inception_v4
167-
EXPORTED_MODEL_NAME=ic4_qnn.pte
169+
EXPORTED_MODEL_NAME=ic4_qnn_${DTYPE}.pte
168170
elif [[ "${MODEL_NAME}" == "ic3" ]]; then
169171
EXPORT_SCRIPT=inception_v3
170-
EXPORTED_MODEL_NAME=ic3_qnn.pte
172+
EXPORTED_MODEL_NAME=ic3_qnn_${DTYPE}.pte
171173
elif [[ "${MODEL_NAME}" == "vit" ]]; then
172174
EXPORT_SCRIPT=torchvision_vit
173-
EXPORTED_MODEL_NAME=vit_qnn.pte
175+
EXPORTED_MODEL_NAME=vit_qnn_${DTYPE}.pte
174176
fi
175177

176178
# Use SM8450 for S22, SM8550 for S23, and SM8560 for S24
177179
# TODO(guangyang): Make QNN chipset matches the target device
178180
QNN_CHIPSET=SM8450
179181

180-
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only
182+
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} -o ${EXPORTED_MODEL_NAME} --compile_only
181183
EXPORTED_MODEL=./${EXPORT_SCRIPT}/${EXPORTED_MODEL_NAME}
182184
}
183185

@@ -187,8 +189,20 @@ test_model_with_coreml() {
187189
exit 1
188190
fi
189191

190-
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}"
192+
DTYPE=float16
193+
194+
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}" --compute_precision "${DTYPE}"
191195
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
196+
# TODO:
197+
if [ -n "$EXPORTED_MODEL" ]; then
198+
EXPORTED_MODEL_WITH_DTYPE="${EXPORTED_MODEL%.pte}_${DTYPE}.pte"
199+
mv "$EXPORTED_MODEL" "$EXPORTED_MODEL_WITH_DTYPE"
200+
EXPORTED_MODEL="$EXPORTED_MODEL_WITH_DTYPE"
201+
echo "Renamed file path: $EXPORTED_MODEL"
202+
else
203+
echo "No .pte file found"
204+
exit 1
205+
fi
192206
}
193207

194208
if [[ "${BACKEND}" == "portable" ]]; then

examples/qualcomm/scripts/deeplab_v3.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def main(args):
8181
data_size=data_num, dataset_dir=args.artifact, download=args.download
8282
)
8383

84-
pte_filename = "dlv3_qnn"
84+
pte_filename = "dlv3_qnn" if not args.output_filename else args.output_filename
8585
instance = DeepLabV3ResNet101Model()
8686

8787
build_executorch_binary(
@@ -195,6 +195,14 @@ def post_process():
195195
default=False,
196196
)
197197

198+
parser.add_argument(
199+
"-o",
200+
"--output_filename",
201+
help="name of the output pte file",
202+
type=str,
203+
required=False,
204+
)
205+
198206
args = parser.parse_args()
199207
try:
200208
main(args)

examples/qualcomm/scripts/edsr.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def main(args):
107107
)
108108

109109
inputs, targets, input_list = dataset.lr, dataset.hr, dataset.get_input_list()
110-
pte_filename = "edsr_qnn"
110+
pte_filename = "edsr_qnn" if not args.output_filename else args.output_filename
111111
instance = EdsrModel()
112112

113113
build_executorch_binary(
@@ -217,6 +217,14 @@ def post_process():
217217
default=False,
218218
)
219219

220+
parser.add_argument(
221+
"-o",
222+
"--output_filename",
223+
help="name of the output pte file",
224+
type=str,
225+
required=False,
226+
)
227+
220228
args = parser.parse_args()
221229
try:
222230
main(args)

examples/qualcomm/scripts/inception_v3.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main(args):
4646
image_shape=(256, 256),
4747
crop_size=224,
4848
)
49-
pte_filename = "ic3_qnn"
49+
pte_filename = "ic3_qnn" if not args.output_filename else args.output_filename
5050
instance = InceptionV3Model()
5151
build_executorch_binary(
5252
instance.get_eager_model().eval(),
@@ -125,6 +125,14 @@ def main(args):
125125
type=str,
126126
)
127127

128+
parser.add_argument(
129+
"-o",
130+
"--output_filename",
131+
help="name of the output pte file",
132+
type=str,
133+
required=False,
134+
)
135+
128136
args = parser.parse_args()
129137
try:
130138
main(args)

examples/qualcomm/scripts/inception_v4.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def main(args):
4545
data_size=data_num,
4646
image_shape=(299, 299),
4747
)
48-
pte_filename = "ic4_qnn"
48+
pte_filename = "ic4_qnn" if not args.output_filename else args.output_filename
4949
instance = InceptionV4Model()
5050
build_executorch_binary(
5151
instance.get_eager_model().eval(),
@@ -124,6 +124,14 @@ def main(args):
124124
type=str,
125125
)
126126

127+
parser.add_argument(
128+
"-o",
129+
"--output_filename",
130+
help="name of the output pte file",
131+
type=str,
132+
required=False,
133+
)
134+
127135
args = parser.parse_args()
128136
try:
129137
main(args)

examples/qualcomm/scripts/mobilenet_v2.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main(args):
4646
image_shape=(256, 256),
4747
crop_size=224,
4848
)
49-
pte_filename = "mv2_qnn"
49+
pte_filename = "mv2_qnn" if not args.output_filename else args.output_filename
5050
instance = MV2Model()
5151
build_executorch_binary(
5252
instance.get_eager_model().eval(),
@@ -125,6 +125,14 @@ def main(args):
125125
type=str,
126126
)
127127

128+
parser.add_argument(
129+
"-o",
130+
"--output_filename",
131+
help="name of the output pte file",
132+
type=str,
133+
required=False,
134+
)
135+
128136
args = parser.parse_args()
129137
try:
130138
main(args)

examples/qualcomm/scripts/mobilenet_v3.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def main(args):
4545
image_shape=(256, 256),
4646
crop_size=224,
4747
)
48-
pte_filename = "mv3_qnn"
48+
pte_filename = "mv3_qnn" if not args.output_filename else args.output_filename
4949
instance = MV3Model()
5050
build_executorch_binary(
5151
instance.get_eager_model().eval(),
@@ -123,6 +123,14 @@ def main(args):
123123
type=str,
124124
)
125125

126+
parser.add_argument(
127+
"-o",
128+
"--output_filename",
129+
help="name of the output pte file",
130+
type=str,
131+
required=False,
132+
)
133+
126134
args = parser.parse_args()
127135
try:
128136
main(args)

examples/qualcomm/scripts/torchvision_vit.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def main(args):
3838
crop_size=224,
3939
)
4040

41-
pte_filename = "vit_qnn"
41+
pte_filename = "vit_qnn" if not args.output_filename else args.output_filename
4242
instance = TorchVisionViTModel()
4343
build_executorch_binary(
4444
instance.get_eager_model().eval(),
@@ -113,6 +113,14 @@ def main(args):
113113
type=str,
114114
)
115115

116+
parser.add_argument(
117+
"-o",
118+
"--output_filename",
119+
help="name of the output pte file",
120+
type=str,
121+
required=False,
122+
)
123+
116124
args = parser.parse_args()
117125
try:
118126
main(args)

0 commit comments

Comments
 (0)