Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .ci/scripts/test_ios_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
31 changes: 31 additions & 0 deletions scripts/test_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
Loading