diff --git a/.ci/scripts/test_ios_ci.sh b/.ci/scripts/test_ios_ci.sh index a160bceed62..7a64d6ae241 100755 --- a/.ci/scripts/test_ios_ci.sh +++ b/.ci/scripts/test_ios_ci.sh @@ -49,6 +49,37 @@ python3 -m examples.portable.scripts.export --model_name="$MODEL_NAME" --segment python3 -m examples.apple.coreml.scripts.export --model_name="$MODEL_NAME" python3 -m examples.xnnpack.aot_compiler --model_name="$MODEL_NAME" --delegate +# MLX has no examples/ export script of its own yet. Lowering is ahead of time and +# imports no mlx runtime package, so it runs on this runner like the others. +python3 - "$MODEL_NAME" <<'PY' +import sys + +import torch +from executorch.backends.mlx import MLXPartitioner +from executorch.examples.models import MODEL_NAME_TO_MODEL +from executorch.examples.models.model_factory import EagerModelFactory +from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower +from executorch.extension.export_util.utils import save_pte_program + +model_name = sys.argv[1] +model, example_inputs, _, _ = EagerModelFactory.create_model( + *MODEL_NAME_TO_MODEL[model_name] +) +program = to_edge_transform_and_lower( + torch.export.export(model.eval(), example_inputs), + partitioner=[MLXPartitioner()], + compile_config=EdgeCompileConfig(_skip_dim_order=True), +).to_executorch() +save_pte_program(program, f"{model_name}_mlx") +PY + +# save_pte_program logs write failures instead of raising, and the wildcard move +# below would happily stage a truncated file, so check the result here. +test -s "${MODEL_NAME}_mlx.pte" || { + echo "error: ${MODEL_NAME}_mlx.pte was not produced" >&2 + exit 1 +} + mkdir -p "$APP_PATH/Resources/Models/MobileNet/" mv $MODEL_NAME*.pte "$APP_PATH/Resources/Models/MobileNet/" diff --git a/scripts/test_ios.sh b/scripts/test_ios.sh index 0c6cf85652b..4145bd2a45f 100755 --- a/scripts/test_ios.sh +++ b/scripts/test_ios.sh @@ -66,6 +66,37 @@ python3 -m examples.portable.scripts.export --model_name="$MODEL_NAME" python3 -m examples.apple.coreml.scripts.export --model_name="$MODEL_NAME" python3 -m examples.xnnpack.aot_compiler --model_name="$MODEL_NAME" --delegate +# MLX has no examples/ export script of its own yet. Lowering is ahead of time and +# imports no mlx runtime package, so it runs on this runner like the others. +python3 - "$MODEL_NAME" <<'PY' +import sys + +import torch +from executorch.backends.mlx import MLXPartitioner +from executorch.examples.models import MODEL_NAME_TO_MODEL +from executorch.examples.models.model_factory import EagerModelFactory +from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower +from executorch.extension.export_util.utils import save_pte_program + +model_name = sys.argv[1] +model, example_inputs, _, _ = EagerModelFactory.create_model( + *MODEL_NAME_TO_MODEL[model_name] +) +program = to_edge_transform_and_lower( + torch.export.export(model.eval(), example_inputs), + partitioner=[MLXPartitioner()], + compile_config=EdgeCompileConfig(_skip_dim_order=True), +).to_executorch() +save_pte_program(program, f"{model_name}_mlx") +PY + +# save_pte_program logs write failures instead of raising, and the wildcard move +# below would happily stage a truncated file, so check the result here. +test -s "${MODEL_NAME}_mlx.pte" || { + echo "error: ${MODEL_NAME}_mlx.pte was not produced" >&2 + exit 1 +} + mkdir -p "$APP_PATH/Resources/Models/MobileNet/" mv $MODEL_NAME*.pte "$APP_PATH/Resources/Models/MobileNet/"