Skip to content

[Relax][ONNX] Support exclusive option in CumSum#19773

Merged
tlopex merged 1 commit into
apache:mainfrom
javierdejesusda:fix/19692-onnx-cumsum-exclusive
Jun 15, 2026
Merged

[Relax][ONNX] Support exclusive option in CumSum#19773
tlopex merged 1 commit into
apache:mainfrom
javierdejesusda:fix/19692-onnx-cumsum-exclusive

Conversation

@javierdejesusda

Copy link
Copy Markdown
Contributor

Root Cause

The ONNX CumSum converter in the Relax frontend rejected any node with exclusive=1 via a bare
assert not attr.get("exclusive", False), "Exclusive option not yet supported.", so importing a
model that used exclusive cumulative sums failed with AssertionError: Exclusive option not yet supported.. The underlying op already supports the exclusive form: relax.op.cumsum forwards an
exclusive flag to the FFI and topi/scan.py implements the exclusive branch, so the converter
only needed to pass the attribute through.

Solution

Drop the assert and read the attribute as exclusive = attr.get("exclusive", 0) != 0 (matching the
existing attr.get("reverse", 0) != 0 idiom in the same converter), then pass it to
relax.op.cumsum(data, axis, exclusive=exclusive). The existing reverse handling
(flip -> cumsum -> flip) composes correctly with exclusive, so reverse=1, exclusive=1 lowers to
an exclusive scan over the reversed axis.

Test Plan

Extended test_cumsum in tests/python/relax/test_frontend_onnx.py to parametrize exclusive over
[True, False], so check_correctness now exercises all four (reverse, exclusive) combinations
against ONNX Runtime:

python -m pytest tests/python/relax/test_frontend_onnx.py::test_cumsum -v

Issue

Fixes #19692

The CumSum converter aborted on any node with exclusive=1 via a bare
assert. relax.op.cumsum and topi.cumsum already implement the exclusive
form, so pass the attribute through instead of rejecting it. The existing
flip-cumsum-flip reverse handling composes correctly with exclusive.

Extend test_cumsum to cover exclusive=True so check_correctness exercises
all four reverse/exclusive combinations against ONNX Runtime.

Fixes apache#19692

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the exclusive attribute in the ONNX CumSum operator converter within the Relax frontend. It updates the CumSum implementation to extract and pass the exclusive flag to the underlying relax.op.cumsum operation, and expands the test suite to cover both True and False values for this parameter. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@tlopex tlopex merged commit 21298c7 into apache:main Jun 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Relax][ONNX] CumSum with exclusive=1 hits a bare AssertionError

2 participants