You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update docs to use top-level CMake targets (#12807)
Update the "Building from Source" and "Using ExecuTorch with C++" docs
to specify the top-level CMake targets. I also added some info to the
selective build docs to document the CMake flags which control selective
build with the `executorch_kernels` target.
This is done in the context of top-level CMake targets, tracked in
#12293.
Copy file name to clipboardExpand all lines: docs/source/kernel-library-selective-build.md
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,25 @@ The basic flow looks like this:
34
34
3. A _kernel resolver _takes in the linked kernel libraries as well as the merged op info yaml file, then makes a decision on which kernels to be registered into ExecuTorch runtime.
35
35
36
36
37
+
## Selective Build CMake Options
38
+
39
+
To enable selective build when building the executorch kernel libraries as part of a CMake build, the following CMake options are exposed. These options affect the `executorch_kernels` CMake target. Make sure to link this target when using selective build.
40
+
41
+
*`EXECUTORCH_SELECT_OPS_YAML`: A path to a YAML file specifying the operators to include.
42
+
*`EXECUTORCH_SELECT_OPS_LIST`: A string containing the operators to include.
43
+
*`EXECUTORCH_SELECT_OPS_MODEL`: A path to a PTE file. Only operators used in this model will be included.
44
+
*`EXECUTORCH_ENABLE_DTYPE_SELECTIVE_BUILD`: If enabled, operators will be further specialized to only operator on the data types specified in the operator selection.
45
+
46
+
Note that `EXECUTORCH_SELECT_OPS_YAML`, `EXECUTORCH_SELECT_OPS_LIST`, and `EXECUTORCH_SELECT_OPS_MODEL` are mutually exclusive. Only one operator specifier directive is allowed.
47
+
48
+
As an example, to build with only operators used in mv2_xnnpack_fp32.pte, the CMake build can be configured as follows.
We expose a CMake macro [gen_selected_ops](https://github.com/pytorch/executorch/blob/main/tools/cmake/Codegen.cmake#L12), to allow users specifying op info:
55
+
For fine-grained control, we expose a CMake macro [gen_selected_ops](https://github.com/pytorch/executorch/blob/main/tools/cmake/Codegen.cmake#L12) to allow users to specify op info:
40
56
41
57
```
42
58
gen_selected_ops(
@@ -75,7 +91,7 @@ Beyond pruning the binary to remove unused operators, the binary size can furthe
75
91
76
92
## Example Walkthrough
77
93
78
-
In [CMakeLists.txt](https://github.com/BujSet/executorch/blob/main/examples/selective_build/CMakeLists.txt#L48-L72), we have the following cmake config options:
94
+
In [examples/selective_build/CMakeLists.txt](https://github.com/BujSet/executorch/blob/main/examples/selective_build/CMakeLists.txt#L48-L72), we have the following cmake config options:
Copy file name to clipboardExpand all lines: docs/source/using-executorch-cpp.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ Running a model using the low-level runtime APIs allows for a high-degree of con
40
40
41
41
## Building with CMake
42
42
43
-
ExecuTorch uses CMake as the primary build system. Inclusion of the module and tensor APIs are controlled by the `EXECUTORCH_BUILD_EXTENSION_MODULE` and `EXECUTORCH_BUILD_EXTENSION_TENSOR` CMake options. As these APIs may not be supported on embedded systems, they are disabled by default when building from source. The low-level API surface is always included. To link, add the `executorch` target as a CMake dependency, along with `extension_module_static` and `extension_tensor`, if desired.
43
+
ExecuTorch uses CMake as the primary build system. Inclusion of the module and tensor APIs are controlled by the `EXECUTORCH_BUILD_EXTENSION_MODULE` and `EXECUTORCH_BUILD_EXTENSION_TENSOR` CMake options. As these APIs may not be supported on embedded systems, they are disabled by default when building from source. The low-level API surface is always included. To link, add the `executorch` target as a CMake dependency, along with `executorch_backends`, `executorch_extensions`, and `extension_kernels`, to link all configured backends, extensions, and kernels.
44
44
45
45
```
46
46
# CMakeLists.txt
@@ -49,10 +49,9 @@ add_subdirectory("executorch")
49
49
target_link_libraries(
50
50
my_target
51
51
PRIVATE executorch
52
-
extension_module_static
53
-
extension_tensor
54
-
optimized_native_cpu_ops_lib
55
-
xnnpack_backend)
52
+
executorch::backends
53
+
executorch::extensions
54
+
executorch::kernels)
56
55
```
57
56
58
57
See [Building from Source](using-executorch-building-from-source.md) for more information on the CMake build process.
0 commit comments