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
{{ message }}
Repository navigation
Commit ed9c4b2
Browse filesBrowse the repository at this point in the historyBrowse files
Lint the yamls, test op registration, and register the CPU runner's kernels (#24935)
Summary:
The x86 `cadence_runner` couldn't load most programs the Cadence compiler produces for CPU, because `backends/cadence/aot/functions.yaml` didn't register their kernels, and nothing checked the yamls or the registry. This diff adds both checks and registers the missing kernels.
The yaml lint, `aot/tests/test_functions_yaml.py`, checks every `functions*.yaml` for kernel names codegen can't resolve and for namespaces outside the libraries the backend builds. It found five bad entries, fixed here. `functions.yaml` registered `cadence::quantized_max_pool2d.out`, an op that no longer exists, instead of the `quantized_max_pool2d_nchw.out` the compiler emits. `functions_hifi.yaml` bound `quantize_per_tensor_asym16u` and `dequantize_per_tensor_asym32s` to the asym16s kernels, which clamp to int16 and read int32 as int16; on the simulator a round trip of 1.0 returned 0.65534 and alternating -0.31072 and 0.00001, and with the right kernels it returns 1.0, so this changes HiFi results for those two ops from wrong to correct. `functions_fusion_g3.yaml` had an extra `native::` in two names; Fusion G3 doesn't build against the pinned nnlib yet, so no CI result changes.
The registry test, `cadence_op_registry_test`, links the ops library and checks with `registry_has_op_function` that every op codegen selected from the yaml is registered. It catches a dropped registration, an unlinked kernel library, or the kernel table filling up before every op is registered. It reads its expected ops from the same yaml, so it can't catch an op missing from the yaml altogether; the backend test suite catches that. It runs on the host for `functions.yaml`, where it shares the runner's codegen and yaml but not its link line, because the runner links `cadence_ops_lib` again in its second-stage build, and on the simulator for the HiFi cores. Vision isn't included because OSS has neither a Vision op-test job nor the `vision/operators/tests/CMakeLists.txt` that would supply gtest; with a stub CMakeLists the test passes on the Vision simulator, so adding it is a separate change with its own CI job.
The diff registers the 7 Cadence ops the compiler emits for CPU (`conv1d`, `conv2d`, `avg_pool2d`, `fully_connected`, `transposed_im2row`, `transposed_convolution` and `_softmax_f32_f32`) against the existing generic kernels, and 38 ATen ops against their portable kernels. `conv3d` stays unregistered until a test covers it, and the 3-D pools have no portable kernel. `aten::linear.out` maps to the generic `fully_connected` kernel because the compiler keeps `aten.linear` on purpose and there is no portable linear kernel. `ReplaceLinearWithFullyConnectedOpPass` rewrites a linear to `fully_connected` only when it has one row, because the HiFi kernels compute one row, but the generic kernel computes every leading row with the same schema, and the kernel diff earlier in this stack added its dtype and shape checks.
`cadence_ops_lib` now links `portable_kernels` instead of the hand-kept source list in `aten_ops_cadence`, which is removed, so `functions.yaml` is the only list. Registration still comes only from the yaml and the linker keeps only the kernels it references, so the runner grows from 3.1 MB to 4.4 MB. The HiFi, Vision and Fusion G3 builds don't change.
Authored with Claude Code.
Reviewed By: DrJessop
Differential Revision: D128295395
Pull Request resolved: #24935
0 commit comments