Commit 99f1f0b
authored
Add MLX integer support for aten.bitwise_and (pytorch#18979)
### Summary
Fixes pytorch#18925
`aten.bitwise_and` currently goes through the bool-only `LogicalAndNode`
path in the MLX delegate, which means integer tensors do not lower
correctly. This switches `aten.bitwise_and` to a dedicated
`BitwiseAndNode` while keeping `aten.logical_and` on the existing
logical path.
This change:
- adds `BitwiseAndNode` to the MLX schema
- adds `exec_bitwise_and()` to the MLX interpreter runtime
- registers `aten.bitwise_and.Tensor` and `aten.bitwise_and.Scalar` as
table-driven MLX binary ops
- keeps `aten.logical_and` on the existing bool-only logical path
- adds MLX op tests for bool, integer, and scalar `bitwise_and`
### Test plan
- `python3 -m py_compile backends/mlx/ops.py
backends/mlx/test/test_ops.py`
- `python3 backends/mlx/serialization/generate.py`
- `PYTHONPATH=src python3 -m executorch.backends.mlx.test.run_all_tests
--list | rg 'bitwise_and'`
- in a local dev env, this registers:
- `bitwise_and_bool`
- `bitwise_and_int`
- `bitwise_and_scalar`
cc @metascroy1 parent bd5752a commit 99f1f0b
4 files changed
Lines changed: 75 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| 485 | + | |
484 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
485 | 493 | | |
486 | 494 | | |
487 | 495 | | |
| |||
3143 | 3151 | | |
3144 | 3152 | | |
3145 | 3153 | | |
3146 | | - | |
3147 | | - | |
3148 | | - | |
3149 | | - | |
3150 | | - | |
3151 | | - | |
3152 | | - | |
3153 | | - | |
3154 | | - | |
3155 | | - | |
3156 | | - | |
3157 | | - | |
3158 | | - | |
3159 | | - | |
3160 | | - | |
3161 | | - | |
3162 | | - | |
3163 | | - | |
3164 | | - | |
3165 | | - | |
3166 | | - | |
3167 | | - | |
3168 | | - | |
3169 | | - | |
3170 | | - | |
3171 | | - | |
3172 | | - | |
3173 | | - | |
3174 | 3154 | | |
3175 | 3155 | | |
3176 | 3156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1402 | 1402 | | |
1403 | 1403 | | |
1404 | 1404 | | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1405 | 1414 | | |
1406 | 1415 | | |
1407 | 1416 | | |
| |||
2052 | 2061 | | |
2053 | 2062 | | |
2054 | 2063 | | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
2055 | 2067 | | |
2056 | 2068 | | |
2057 | 2069 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
582 | 588 | | |
583 | 589 | | |
584 | 590 | | |
| |||
1130 | 1136 | | |
1131 | 1137 | | |
1132 | 1138 | | |
1133 | | - | |
| 1139 | + | |
| 1140 | + | |
1134 | 1141 | | |
1135 | 1142 | | |
1136 | 1143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4274 | 4274 | | |
4275 | 4275 | | |
4276 | 4276 | | |
| 4277 | + | |
| 4278 | + | |
4277 | 4279 | | |
4278 | 4280 | | |
4279 | 4281 | | |
| |||
4286 | 4288 | | |
4287 | 4289 | | |
4288 | 4290 | | |
| 4291 | + | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
4289 | 4336 | | |
4290 | 4337 | | |
4291 | 4338 | | |
| |||
0 commit comments