|
1 | 1 | # Selective Build Examples
|
2 |
| -To optimize binary size of ExecuTorch runtime, selective build can be used. This folder contains examples to select only the operators needed for ExecuTorch build. We provide APIs for both CMake build and buck2 build. This example will demonstrate both. You can find more information on how to use buck2 macros in [wiki](../../docs/source/kernel-library-selective_build.md). |
| 2 | +To optimize binary size of ExecuTorch runtime, selective build can be used. This folder contains examples to select only the operators needed for ExecuTorch build. We provide APIs for both CMake build and buck2 build. This example will demonstrate the CMake build. To use the buck2 API, check `test_selective_build.sh` in the current directory. You can find more information on how to use buck2 macros in [wiki](../../docs/source/kernel-library-selective_build.md). |
3 | 3 |
|
4 | 4 | ## How to run
|
5 | 5 |
|
|
9 | 9 |
|
10 | 10 | ```bash
|
11 | 11 | cd executorch
|
12 |
| -bash examples/selective_build/test_selective_build.sh [cmake|buck2] |
| 12 | +bash examples/selective_build/test_selective_build.sh cmake |
13 | 13 | ```
|
14 | 14 |
|
15 |
| -## BUCK2 examples |
16 |
| - |
17 |
| -Check out `targets.bzl` for demo of 4 selective build APIs: |
18 |
| -1. `--config executorch.select_ops=all`: Select all ops from the dependency kernel libraries, register all of them into ExecuTorch runtime. |
19 |
| -2. `--config executorch.select_ops=list`: Only select ops from `ops` kwarg in `et_operator_library` macro. |
20 |
| -3. `--config executorch.select_ops=yaml`: Only select from a yaml file from `ops_schema_yaml_target` kwarg in `et_operator_library` macro. |
21 |
| -4. `--config executorch.select_ops=dict`: Only select ops with from `ops_dict` kwarg in `et_operator_library` macro. Optionally, add dtype information to each operator and add `dtype_selective_build = True` to only select those dtypes. |
22 |
| -Eg. if the model only uses the float implementation of add, then only the float add will be registered. Note: setting `dtype_selective_build = True` is only available in xplat. |
23 |
| - |
24 |
| -Other configs: |
25 |
| -- `--config executorch.max_kernel_num=N`: Only allocate memory for the required number of operators. Take this result from `selected_operators.yaml`. |
26 |
| - |
27 |
| -## CMake examples |
28 |
| - |
29 | 15 | Check out `CMakeLists.txt` for demo of 3 selective build APIs:
|
30 |
| -1. `SELECT_ALL_OPS` |
31 |
| -2. `SELECT_OPS_LIST` |
32 |
| -3. `SELECT_OPS_YAML` |
| 16 | +1. `SELECT_ALL_OPS`: Select all ops from the dependency kernel libraries, register all of them into ExecuTorch runtime. |
| 17 | +2. `SELECT_OPS_LIST`: Only select from a list of ops. |
| 18 | +3. `SELECT_OPS_YAML`: Only select from a yaml file. |
33 | 19 |
|
34 | 20 | Other configs:
|
35 |
| -- `MAX_KERNEL_NUM=N` |
| 21 | +- `MAX_KERNEL_NUM=N`: Only allocate memory for N operators. |
36 | 22 |
|
37 | 23 | We have one more API incoming: only select from an exported model file (.pte).
|
0 commit comments