Repository navigation
Commit fa61c2b
MLX: add a cummax handler (pytorch#23051)
`aten.cummax` had no handler, and because it sits outside the core ATen
opset a graph containing it cannot be lowered at all: the verifier
rejects it. Adds the handler, a `CummaxNode` and its interpreter kernel.
Only the values output is produced. MLX has no cumulative argmax, so a
graph that consumes the indices is rejected rather than silently handed
an unfilled tensor. The dead `getitem` that torch.export always emits
for the unused half of the tuple does not count as consuming it.
`CummaxNode` is appended at the end of the union (137), per the
append-only rule in `schema.fbs`, so previously serialized `.pte` still
load. Spelled `Cummax` rather than `CumMax` so `generate.py`'s
CamelCase-to-SNAKE pass yields `CUMMAX`, matching the neighbouring
`CUMSUM`.
The partitioner preserves `cummax` through `ops_to_not_decompose`, but
exir still runs the core-ATen verifier over the result, so the op has to
be excused with `_core_aten_ops_exception_list`. The test does that, and
a caller has to do the same.
## Test plan
`python -m executorch.backends.mlx.test.run_all_tests cummax`: 4 configs
(1D, 2D over each axis, 3D over -1), all passing end to end on an
M-series Mac, comparing the delegate's output against PyTorch.
## Scope change since the first version
This started as five handlers. Four are dropped: measured against
`to_edge`, each op either disappears or becomes something already
handled, so the handler was only reachable because registering it made
`ops_to_not_decompose` preserve the op.
| dropped | what it becomes after `to_edge` | already handled |
| --- | --- | --- |
| `type_as`, `to.dtype` | `dim_order_ops._to_dim_order_copy` | yes |
| `detach` | `aten.alias_copy.default` | yes |
| `detach_` | node is folded away | n/a |
| `contiguous` | no node even after `torch.export` | n/a |
| `masked_fill.Scalar` | `scalar_tensor` + `aten.where.self` | yes, both
|
`cummax` is the only one that is load-bearing.
---------
Co-authored-by: Scott Roy <161522778+metascroy@users.noreply.github.com>1 parent 575f863 commit fa61c2b
4 files changed
Lines changed: 104 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
5330 | 5331 | | |
5331 | 5332 | | |
5332 | 5333 | | |
| 5334 | + | |
| 5335 | + | |
| 5336 | + | |
| 5337 | + | |
| 5338 | + | |
| 5339 | + | |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
| 5343 | + | |
| 5344 | + | |
| 5345 | + | |
| 5346 | + | |
| 5347 | + | |
| 5348 | + | |
| 5349 | + | |
| 5350 | + | |
| 5351 | + | |
| 5352 | + | |
| 5353 | + | |
| 5354 | + | |
| 5355 | + | |
| 5356 | + | |
| 5357 | + | |
| 5358 | + | |
| 5359 | + | |
| 5360 | + | |
| 5361 | + | |
| 5362 | + | |
| 5363 | + | |
| 5364 | + | |
| 5365 | + | |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
5333 | 5372 | | |
5334 | 5373 | | |
5335 | 5374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1859 | 1859 | | |
1860 | 1860 | | |
1861 | 1861 | | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
1862 | 1869 | | |
1863 | 1870 | | |
1864 | 1871 | | |
| |||
2540 | 2547 | | |
2541 | 2548 | | |
2542 | 2549 | | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
2543 | 2553 | | |
2544 | 2554 | | |
2545 | 2555 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
649 | 655 | | |
650 | 656 | | |
651 | 657 | | |
| |||
1204 | 1210 | | |
1205 | 1211 | | |
1206 | 1212 | | |
1207 | | - | |
| 1213 | + | |
| 1214 | + | |
1208 | 1215 | | |
1209 | 1216 | | |
1210 | 1217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7601 | 7601 | | |
7602 | 7602 | | |
7603 | 7603 | | |
| 7604 | + | |
| 7605 | + | |
| 7606 | + | |
| 7607 | + | |
| 7608 | + | |
| 7609 | + | |
| 7610 | + | |
| 7611 | + | |
| 7612 | + | |
| 7613 | + | |
| 7614 | + | |
| 7615 | + | |
| 7616 | + | |
| 7617 | + | |
| 7618 | + | |
| 7619 | + | |
| 7620 | + | |
| 7621 | + | |
| 7622 | + | |
| 7623 | + | |
| 7624 | + | |
| 7625 | + | |
| 7626 | + | |
| 7627 | + | |
| 7628 | + | |
| 7629 | + | |
| 7630 | + | |
| 7631 | + | |
| 7632 | + | |
| 7633 | + | |
| 7634 | + | |
| 7635 | + | |
| 7636 | + | |
| 7637 | + | |
| 7638 | + | |
| 7639 | + | |
| 7640 | + | |
| 7641 | + | |
| 7642 | + | |
| 7643 | + | |
| 7644 | + | |
| 7645 | + | |
| 7646 | + | |
| 7647 | + | |
| 7648 | + | |
| 7649 | + | |
| 7650 | + | |
7604 | 7651 | | |
7605 | 7652 | | |
7606 | 7653 | | |
| |||
0 commit comments