This directory contains export.py, a utility script that can be used to export models registered in executorch/examples/models/__init__.py to the Vulkan backend.
Note that all example commands are assumed to be executed from executorch root.
cd ~/executorch
For example, to export MobileNet V2:
MODEL_NAME=mv2 && \ OUTPUT_DIR=. && \ python -m examples.vulkan.export -m ${MODEL_NAME} -o ${OUTPUT_DIR}
This will create a file name mv2_vulkan.pte in the specified output directory.
To enable exporting with dynamic shapes, simply add the -d flag.
MODEL_NAME=mv2 && \ OUTPUT_DIR=. && \ python -m examples.vulkan.export -m ${MODEL_NAME} -o ${OUTPUT_DIR} -d
Use the -b flag to export a bundled PTE file (i.e. .bpte). This is a .pte file with bundled test cases that can be used for correctness checking.
MODEL_NAME=mv2 && \ OUTPUT_DIR=. && \ python -m examples.vulkan.export -m ${MODEL_NAME} -o ${OUTPUT_DIR} -d -b
This will create a file called mv2_vulkan.bpte in the specified output directory.
The script can also execute the exported and lowered model via pybindings to check output correctness before writing the output file.
To enable this, ensure that your machine:
Additionally, you will need to install the executorch python package from source, since the Vulkan backend is not included by default in the pip package.
CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON " ./install_executorch.sh -e
Once these conditions are fulfilled, the --test flag can be passed to the script.
MODEL_NAME=mv2 && \ OUTPUT_DIR=. && \ python -m examples.vulkan.export -m ${MODEL_NAME} -o ${OUTPUT_DIR} -d --test
You should see some output like
INFO:root:✓ Model test PASSED - outputs match reference within tolerance
Support for quantization is under active development and will be added soon!