@@ -232,21 +232,24 @@ test_model_with_qnn() {
232232# @param should_test If true, build and test the model using the coreml_executor_runner.
233233test_model_with_coreml () {
234234 local should_test=" $1 "
235+ local test_with_pybindings=" $2 "
236+ local dtype=" $3 "
235237
236238 if [[ " ${BUILD_TOOL} " != " cmake" ]]; then
237239 echo " coreml only supports cmake."
238240 exit 1
239241 fi
240242
241- DTYPE=float16
243+ RUN_WITH_PYBINDINGS=" "
244+ if [[ " ${test_with_pybindings} " == true ]]; then
245+ echo \" Running with pybindings\"
246+ export RUN_WITH_PYBINDINGS=" --run_with_pybindings"
247+ fi
242248
243- " ${PYTHON_EXECUTABLE} " -m examples.apple.coreml.scripts.export --model_name=" ${MODEL_NAME} " --compute_precision " ${DTYPE} " --use_partitioner
249+ " ${PYTHON_EXECUTABLE} " -m examples.apple.coreml.scripts.export --model_name=" ${MODEL_NAME} " --compute_precision ${dtype} --use_partitioner ${RUN_WITH_PYBINDINGS}
244250 EXPORTED_MODEL=$( find " ." -type f -name " ${MODEL_NAME} *.pte" -print -quit)
245251
246252 if [ -n " $EXPORTED_MODEL " ]; then
247- EXPORTED_MODEL_WITH_DTYPE=" ${EXPORTED_MODEL% .pte} _${DTYPE} .pte"
248- mv " $EXPORTED_MODEL " " $EXPORTED_MODEL_WITH_DTYPE "
249- EXPORTED_MODEL=" $EXPORTED_MODEL_WITH_DTYPE "
250253 echo " OK exported model: $EXPORTED_MODEL "
251254 else
252255 echo " [error] failed to export model: no .pte file found"
@@ -303,7 +306,15 @@ elif [[ "${BACKEND}" == *"coreml"* ]]; then
303306 if [[ " ${BACKEND} " == * " test" * ]]; then
304307 should_test_coreml=true
305308 fi
306- test_model_with_coreml " ${should_test_coreml} "
309+ test_with_pybindings=false
310+ if [[ " ${BACKEND} " == * " pybind" * ]]; then
311+ test_with_pybindings=true
312+ fi
313+ dtype=float16
314+ if [[ " ${BACKEND} " == * " float32" * ]]; then
315+ dtype=float32
316+ fi
317+ test_model_with_coreml " ${should_test_coreml} " " ${test_with_pybindings} " " ${dtype} "
307318 if [[ $? -eq 0 ]]; then
308319 prepare_artifacts_upload
309320 fi
0 commit comments