Commit 0a43e2f
MLX delegate: add integer support for aten.bitwise_not (#19053)
### Summary
Fixes #18924
Extends `aten.bitwise_not` support in the MLX delegate to handle integer
tensors, not just boolean tensors.
Previously the handler only dispatched to `LogicalNotNode` for `bool`
and raised `NotImplementedError` for all other dtypes. This adds a
dedicated `BitwiseInvertNode` backed by `mlx::core::bitwise_invert`, and
updates the handler to dispatch based on dtype:
- `bool` → `LogicalNotNode` (unchanged)
- `int32`, `int64` → `BitwiseInvertNode`
#### Changes:
- `serialization/schema.fbs`: add `BitwiseInvertNode` table and append
to `OpNode` union
- `runtime/MLXInterpreter.h`: add `exec_bitwise_invert()` and dispatch
case
- `ops.py`: update `_bitwise_not_handler` to dispatch to
`BitwiseInvertNode` for integers
- `test/test_ops.py`: add `bitwise_not_int` test for `int32` and `int64`
### Test plan
All tests were ran on a machine with an Apple M1 Pro CPU, macOS 26.4.1.
- `python3 -m py_compile backends/mlx/ops.py
backends/mlx/test/test_ops.py`
- `python3 backends/mlx/serialization/generate.py`
- `python3 -m executorch.backends.mlx.test.run_all_tests
bitwise_not_int`
### Test output
```
============================================================
TEST SUMMARY
============================================================
Passed: 6
Failed: 0
============================================================
```
cc @metascroy
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Scott Roy <161522778+metascroy@users.noreply.github.com>1 parent 2330652 commit 0a43e2f
4 files changed
Lines changed: 40 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
3066 | 3067 | | |
3067 | 3068 | | |
3068 | 3069 | | |
3069 | | - | |
| 3070 | + | |
3070 | 3071 | | |
3071 | 3072 | | |
3072 | 3073 | | |
3073 | 3074 | | |
| 3075 | + | |
3074 | 3076 | | |
3075 | | - | |
3076 | | - | |
3077 | | - | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
3078 | 3083 | | |
3079 | 3084 | | |
3080 | 3085 | | |
3081 | 3086 | | |
3082 | 3087 | | |
3083 | 3088 | | |
3084 | | - | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
3085 | 3099 | | |
3086 | 3100 | | |
3087 | | - | |
3088 | | - | |
| 3101 | + | |
3089 | 3102 | | |
| 3103 | + | |
3090 | 3104 | | |
3091 | 3105 | | |
3092 | 3106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1380 | 1380 | | |
1381 | 1381 | | |
1382 | 1382 | | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1383 | 1390 | | |
1384 | 1391 | | |
1385 | 1392 | | |
| |||
2028 | 2035 | | |
2029 | 2036 | | |
2030 | 2037 | | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
2031 | 2042 | | |
2032 | 2043 | | |
2033 | 2044 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
| |||
1113 | 1118 | | |
1114 | 1119 | | |
1115 | 1120 | | |
1116 | | - | |
| 1121 | + | |
| 1122 | + | |
1117 | 1123 | | |
1118 | 1124 | | |
1119 | 1125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4111 | 4111 | | |
4112 | 4112 | | |
4113 | 4113 | | |
| 4114 | + | |
4114 | 4115 | | |
4115 | 4116 | | |
4116 | 4117 | | |
| |||
0 commit comments