Skip to content

Commit d277530

Browse files
committed
Update docs to use top-level CMake targets
ghstack-source-id: 4da6ffe ghstack-comment-id: 3111967018 Pull-Request: #12807
1 parent 5d1143f commit d277530

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

docs/source/kernel-library-selective-build.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,25 @@ The basic flow looks like this:
3434
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.
3535

3636

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.
49+
```
50+
cmake .. -DEXECUTORCH_SELECT_OPS_MODEL=mv2_xnnpack_fp32.pte
51+
```
52+
3753
## APIs
3854

39-
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:
4056

4157
```
4258
gen_selected_ops(
@@ -75,7 +91,7 @@ Beyond pruning the binary to remove unused operators, the binary size can furthe
7591

7692
## Example Walkthrough
7793

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:
7995

8096
1. `EXECUTORCH_SELECT_OPS_YAML`
8197
2. `EXECUTORCH_SELECT_OPS_LIST`

docs/source/using-executorch-building-from-source.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ I 00:00:00.000764 executorch:executor_runner.cpp:180] Model executed successfull
252252
I 00:00:00.000770 executorch:executor_runner.cpp:184] 1 outputs:
253253
Output 0: tensor(sizes=[1], [2.])
254254
```
255+
256+
### CMake Targets
257+
258+
To link against the ExecuTorch framework from CMake, the following top-level targets are exposed:
259+
260+
* `executorch::backends`: Contains all configured backends.
261+
* `executorch::extensions`: Contains all configured extensions.
262+
* `executorch::kernels`: Contains all configured kernel libraries.
263+
264+
The backends, extensions, and kernels included in these targets are controlled by the various `EXECUTORCH_` CMake options specified by the build.
265+
255266
## Build ExecuTorch for Windows
256267
257268
This document outlines the current known working build instructions for building and validating ExecuTorch on a Windows machine.

docs/source/using-executorch-cpp.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Running a model using the low-level runtime APIs allows for a high-degree of con
4040
4141
## Building with CMake
4242
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.
4444
4545
```
4646
# CMakeLists.txt
@@ -49,10 +49,9 @@ add_subdirectory("executorch")
4949
target_link_libraries(
5050
my_target
5151
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)
5655
```
5756
5857
See [Building from Source](using-executorch-building-from-source.md) for more information on the CMake build process.

0 commit comments

Comments
 (0)