Skip to content

Commit 1547bcf

Browse files
lucylqfacebook-github-bot
authored andcommitted
Dtype selective build refactor (#3938)
Summary: Pull Request resolved: #3938 1. Add dtype_selective_build as an option to executorch_generated_lib 2. Copy portable source and header files into codegen.bzl directory (this is the caller's directory, eg. examples/selective_build) 3. If kernel_deps contains portable_ops, remove it and use the source files Note: dtype selective build only available for xplat. `header_namespace` is only available in xplat, used to link headers into correct place. ``` error: fail: cpp_library(): the `header_namespace` parameter is *not* supported in fbcode -- `#include` paths must match their fbcode-relative path. (executorch/backends/vulkan/serialization/schema/vk_delegate_schema) ``` New API usage: ``` executorch_generated_lib( ... dtype_selective_build = True, ... ) ``` Reviewed By: larryliu0820 Differential Revision: D58396325 fbshipit-source-id: 739ebc6b94ffa5f791e125442804a2fff27eb176
1 parent 7f0c0b8 commit 1547bcf

File tree

7 files changed

+1206
-1048
lines changed

7 files changed

+1206
-1048
lines changed

examples/selective_build/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ bash examples/selective_build/test_selective_build.sh [cmake|buck2]
1414

1515
## BUCK2 examples
1616

17-
Check out `targets.bzl` for demo of 3 selective build APIs:
17+
Check out `targets.bzl` for demo of 4 selective build APIs:
1818
1. `--config executorch.select_ops=all`: Select all ops from the dependency kernel libraries, register all of them into ExecuTorch runtime.
1919
2. `--config executorch.select_ops=list`: Only select ops from `ops` kwarg in `et_operator_library` macro.
2020
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.
2123

2224
Other configs:
2325
- `--config executorch.max_kernel_num=N`: Only allocate memory for the required number of operators. Take this result from `selected_operators.yaml`.
24-
- `--config executorch.dtype_selective_build_lib=<executorch_generated_lib_name>`: Use dtype selective build. For each op, we register the dtypes that are used. Eg. if the model only uses the float implementation of add, then only the float add will be registered. Pass in the executorch_generated_lib name (see buck2 model example in targets.bzl).
2526

2627
## CMake examples
2728

examples/selective_build/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def define_common_targets():
6363
deps = [
6464
":select_ops_in_dict",
6565
],
66+
dtype_selective_build = True,
6667
visibility = ["//executorch/..."],
6768
)
6869

0 commit comments

Comments
 (0)