1*523fa7a6SAndroid Build Coastguard Worker# Selective Build Examples 2*523fa7a6SAndroid Build Coastguard WorkerTo optimize binary size of ExecuTorch runtime, selective build can be used. This folder contains examples to select only the operators needed for ExecuTorch build. This example will demonstrate the CMake build. 3*523fa7a6SAndroid Build Coastguard Worker 4*523fa7a6SAndroid Build Coastguard Worker## How to run 5*523fa7a6SAndroid Build Coastguard Worker 6*523fa7a6SAndroid Build Coastguard WorkerPrerequisite: finish the [setting up wiki](https://pytorch.org/executorch/stable/getting-started-setup). 7*523fa7a6SAndroid Build Coastguard Worker 8*523fa7a6SAndroid Build Coastguard WorkerRun: 9*523fa7a6SAndroid Build Coastguard Worker 10*523fa7a6SAndroid Build Coastguard Worker```bash 11*523fa7a6SAndroid Build Coastguard Workercd executorch 12*523fa7a6SAndroid Build Coastguard Workerbash examples/selective_build/test_selective_build.sh cmake 13*523fa7a6SAndroid Build Coastguard Worker``` 14*523fa7a6SAndroid Build Coastguard Worker 15*523fa7a6SAndroid Build Coastguard WorkerCheck out `CMakeLists.txt` for demo of 3 selective build APIs: 16*523fa7a6SAndroid Build Coastguard Worker1. `SELECT_ALL_OPS`: Select all ops from the dependency kernel libraries, register all of them into ExecuTorch runtime. 17*523fa7a6SAndroid Build Coastguard Worker2. `SELECT_OPS_LIST`: Only select operators from a list. 18*523fa7a6SAndroid Build Coastguard Worker3. `SELECT_OPS_YAML`: Only select operators from a yaml file. 19*523fa7a6SAndroid Build Coastguard Worker 20*523fa7a6SAndroid Build Coastguard WorkerOther configs: 21*523fa7a6SAndroid Build Coastguard Worker- `MAX_KERNEL_NUM=N`: Only allocate memory for N operators. 22*523fa7a6SAndroid Build Coastguard Worker 23*523fa7a6SAndroid Build Coastguard WorkerWe have one more API incoming: only select from an exported model file (.pte). 24