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
Pico2: Document selective build options and auto-detect ops from model (#18640)
A community user hit "Operator missing" (error 20) on bare-metal RISC-V
because the selective build guidance was unclear (see #18573).
- Document the three selective build approaches in README, recommending
EXECUTORCH_SELECT_OPS_MODEL as the default
- Update build_firmware_pico.sh to auto-pass SELECT_OPS_MODEL when a
model file is provided
- Note that the baremetal pattern is portable to other architectures
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: examples/raspberry_pi/pico2/README.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,15 @@ This demo demonstrates ExecuTorch's ability to bring your own PyTorch model and
15
15
- Build firmware with one command and pass the model file (.pte) as an argument
16
16
- Deploy directly to Pico2
17
17
18
+
### Adapting to Other Baremetal Architectures
19
+
20
+
While this example targets the Pico2 board, the same pattern — embedding the `.pte` model as a C array, using `BufferDataLoader`, and statically allocating memory — can be adapted to other baremetal targets (e.g., RISC-V) by providing your own CMake toolchain file. The key requirement is a correct selective build (see below) so all operators your model needs are included.
21
+
18
22
### Important Caveats
19
23
20
24
- Memory constraints - Models must fit in 520KB SRAM (Pico2)
21
-
- Missing operators - Some ops may not be supported
22
-
- Selective builds - Include only operators your model uses if you want to reduce binary size
25
+
- Missing operators - If you get "Operator missing" (error 20) at runtime, your build is missing operators that the model needs. Use `EXECUTORCH_SELECT_OPS_MODEL` (see below) to auto-detect the required operators from your `.pte` file.
26
+
- Selective builds - Include only operators your model uses to reduce binary size
23
27
24
28
## Memory Constraints & Optimization
25
29
@@ -36,10 +40,30 @@ Large models will not fit. Keep your `.pte` files small!
36
40
- Operator fusion
37
41
- Selective builds (include only needed operators)
38
42
39
-
For more details , refer to the following guides:
43
+
### Selective Build: Choosing the Right Operators
44
+
45
+
When cross-compiling ExecuTorch for baremetal targets, you need to register the operators your model uses. There are three approaches:
46
+
47
+
1.**`EXECUTORCH_SELECT_OPS_MODEL` (recommended)** — Point to your `.pte` file and the build system auto-detects all required operators:
This is the most reliable approach because it reads the exact operators from the serialized model, including any operators introduced by compiler passes or edge IR lowering that may not be obvious from the original PyTorch model.
52
+
53
+
2.**`EXECUTORCH_SELECT_OPS_LIST`** — Manually specify operators by name:
This requires you to know the exact operator names (including `.out` suffixes). If you miss any, you'll get "Operator missing" (error 20) at runtime.
58
+
59
+
3.**All portable operators (no selective build)** — Omit any `EXECUTORCH_SELECT_OPS_*` options when configuring CMake. This registers all portable operators, which is simple but produces larger binaries, an important consideration on memory-constrained targets.
60
+
61
+
The `build_firmware_pico.sh` script uses `EXECUTORCH_SELECT_OPS_MODEL` by default when a model file is provided.
0 commit comments