Commit f2252a6
Avoid duplicate ops registration in macOS executor_runner (#19804)
### Summary
The macOS preset builds `executor_runner` with optimized kernels
enabled, so the top-level runner link logic already selects
`optimized_native_cpu_ops_lib` as the ops registration library.
`coremldelegate` was also linking `portable_ops_lib` and
`portable_kernels` through `EXECUTORCH_COREML_BUILD_EXECUTOR_RUNNER`.
Since `coremldelegate` is included through `executorch_backends`,
`executor_runner` could force-load both `portable_ops_lib` and
`optimized_native_cpu_ops_lib`. Their generated static initializers
register overlapping ATen kernels, causing `executor_runner` to abort
before `main()` with a duplicate registration error.
This removes the CoreML-side ops-lib link and removes the obsolete
`EXECUTORCH_COREML_BUILD_EXECUTOR_RUNNER` preset option. The CoreML
executor runner under `examples/apple/coreml/executor_runner` is not a
CMake target, so this option was not actually building that runner.
### Compatibility
The `coreml_executor_runner` built by
`examples/apple/coreml/scripts/build_executor_runner.sh` is unaffected.
That script builds the relevant CMake targets, then stages
`libportable_ops_lib.a` and `libportable_kernels.a` into
`examples/apple/coreml/executor_runner/libraries/`. The Xcode project
links those archives directly, independent of `libcoremldelegate.a`'s
internal link list, so the Xcode-built runner keeps working through its
own link line.
Other CMake consumers of `coremldelegate` already select an ops
registration library independently before force-loading
`coremldelegate`, so they are unaffected by removing the private
portable-kernel link from the delegate. Non-Apple platforms do not build
`coremldelegate` because `backends/apple/coreml/CMakeLists.txt` is gated
by `if(APPLE)`. The iOS and iOS-simulator presets never set the removed
option.
### Test plan
```bash
cmake --preset macos
cmake --build cmake-out --target executor_runner --config Debug -j
./cmake-out/Debug/executor_runner
cmake --build cmake-out --target coremldelegate --config Debug -j
```
Verified the `executor_runner` link line no longer contains
`libportable_ops_lib.a` or unprefixed `libportable_kernels.a`.
`liboptimized_native_cpu_ops_lib.a` is still force-loaded.
`liboptimized_portable_kernels.a` is still present, which is expected
because it is one of `optimized_native_cpu_ops_lib`'s kernel libraries.
Running without `--model_path` now reaches `main()`, resets the
threadpool, and fails only on the expected missing `model.pte` path
instead of aborting during static kernel registration.
Authored with Claude.
cc @larryliu0820 @GregoryComer @kimishpatel @YifanShenSZ @cymbalrush
@metascroy
Co-authored-by: Digant Desai <digantdesai@meta.com>1 parent 3a6e400 commit f2252a6
3 files changed
Lines changed: 0 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 233 | | |
240 | 234 | | |
241 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
0 commit comments