Skip to content

Commit b370ae7

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

File tree

9 files changed

+84
-16
lines changed

9 files changed

+84
-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: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,29 @@ test_model_with_qnn() {
155155

156156
if [[ "${MODEL_NAME}" == "dl3" ]]; then
157157
EXPORT_SCRIPT=deeplab_v3
158-
EXPORTED_MODEL_NAME=dlv3_qnn.pte
158+
EXPORTED_MODEL_NAME=dl3_qnn_q8.pte
159159
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
160160
EXPORT_SCRIPT=mobilenet_v3
161-
EXPORTED_MODEL_NAME=mv3_qnn.pte
161+
EXPORTED_MODEL_NAME=mv3_qnn_fp16.pte
162162
elif [[ "${MODEL_NAME}" == "mv2" ]]; then
163163
EXPORT_SCRIPT=mobilenet_v2
164-
EXPORTED_MODEL_NAME=mv2_qnn.pte
164+
EXPORTED_MODEL_NAME=mv2_qnn_q8.pte
165165
elif [[ "${MODEL_NAME}" == "ic4" ]]; then
166166
EXPORT_SCRIPT=inception_v4
167-
EXPORTED_MODEL_NAME=ic4_qnn.pte
167+
EXPORTED_MODEL_NAME=ic4_qnn_q8.pte
168168
elif [[ "${MODEL_NAME}" == "ic3" ]]; then
169169
EXPORT_SCRIPT=inception_v3
170-
EXPORTED_MODEL_NAME=ic3_qnn.pte
170+
EXPORTED_MODEL_NAME=ic3_qnn_q8.pte
171171
elif [[ "${MODEL_NAME}" == "vit" ]]; then
172172
EXPORT_SCRIPT=torchvision_vit
173-
EXPORTED_MODEL_NAME=vit_qnn.pte
173+
EXPORTED_MODEL_NAME=vit_qnn_q8.pte
174174
fi
175175

176176
# Use SM8450 for S22, SM8550 for S23, and SM8560 for S24
177177
# TODO(guangyang): Make QNN chipset matches the target device
178178
QNN_CHIPSET=SM8450
179179

180-
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only
180+
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} -o ${EXPORTED_MODEL_NAME} --compile_only
181181
EXPORTED_MODEL=./${EXPORT_SCRIPT}/${EXPORTED_MODEL_NAME}
182182
}
183183

@@ -187,8 +187,20 @@ test_model_with_coreml() {
187187
exit 1
188188
fi
189189

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

194206
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)