Skip to content

Commit 698e137

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

File tree

10 files changed

+78
-18
lines changed

10 files changed

+78
-18
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: 9 additions & 7 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 fp16 only
156+
DTYPE=fp16
155157

156158
if [[ "${MODEL_NAME}" == "dl3" ]]; then
157159
EXPORT_SCRIPT=deeplab_v3
158-
EXPORTED_MODEL_NAME=dlv3_qnn.pte
160+
EXPORTED_MODEL_NAME=deeplab-v3_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=mobilenet-v3_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=mobilenet-v2_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=inception-v4_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=inception-v3_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=torchvision-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

examples/apple/coreml/scripts/export.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def export_lowered_module_to_executorch_program(lowered_module, example_inputs):
110110
return exec_prog
111111

112112

113-
def save_executorch_program(exec_prog, model_name, compute_unit):
113+
def save_executorch_program(exec_prog, model_name, compute_unit, precision):
114114
buffer = exec_prog.buffer
115-
filename = f"{model_name}_coreml_{compute_unit}.pte"
115+
filename = f"{model_name}_coreml_{compute_unit}_{precision}.pte"
116116
print(f"Saving exported program to {filename}")
117117
with open(filename, "wb") as file:
118118
file.write(buffer)
@@ -189,7 +189,9 @@ def main():
189189
example_inputs,
190190
)
191191

192-
save_executorch_program(exec_program, args.model_name, args.compute_unit)
192+
save_executorch_program(
193+
exec_program, args.model_name, args.compute_unit, args.compute_precision
194+
)
193195
generate_etrecord(f"{args.model_name}_coreml_etrecord.bin", edge_copy, exec_program)
194196

195197
if args.save_processed_bytes and lowered_module is not None:

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)