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.
Prerequisite: finish the setting up wiki.
Run:
bash test_selective_build.sh [cmake|buck2]
Check out targets.bzl for demo of 3 selective build APIs:
--config executorch.select_ops=all: Select all ops from the dependency kernel libraries, register all of them into ExecuTorch runtime.--config executorch.select_ops=list: Only select ops from ops kwarg in et_operator_library macro.--config executorch.select_ops=yaml: Only select from a yaml file from ops_schema_yaml_target kwarg in et_operator_library macro.Other configs:
--config executorch.max_kernel_num=N: Only allocate memory for the required number of operators. Take this result from selected_operators.yaml.Check out CMakeLists.txt for demo of 3 selective build APIs:
SELECT_ALL_OPSSELECT_OPS_LISTSELECT_OPS_YAMLOther configs:
MAX_KERNEL_NUM=NWe have one more API incoming: only select from an exported model file (.pte).