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 ~/executorchFor 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} -dUse 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 -bThis 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:
- Has the Vulkan SDK installed
- Has Vulkan drivers
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 -eOnce 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 --testYou should see some output like
INFO:root:✓ Model test PASSED - outputs match reference within toleranceThe Vulkan backend supports 4-bit and 8-bit quantized linear layers. See the Vulkan quantization guide for supported schemes and export examples.