Skip to content

[Relax][ONNX] Support ConcatFromSequenc/SequenceInsert with new_axis=1#19361

Merged
tlopex merged 4 commits into
apache:mainfrom
rknastenka:feat
Apr 7, 2026
Merged

[Relax][ONNX] Support ConcatFromSequenc/SequenceInsert with new_axis=1#19361
tlopex merged 4 commits into
apache:mainfrom
rknastenka:feat

Conversation

@rknastenka

@rknastenka rknastenka commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds support for new_axis=1 in the ONNX ConcatFromSequence operator, which was previously raising a NotImplementedError.

Note regarding the tracking issue: The tracking issue listed this task as "SequenceInsert — Does not support inserting with new axis.", but i think it meant ConcatFromSequence. ONNX's SequenceInsert does not have a new_axis attribute, whereas ConcatFromSequence does and was throwing the "Insert new axis is not supported yet" error. This PR implements the missing feature.

Changes:

  • Replaced the NotImplementedError in ConcatFromSequence with relax.op.stack(inputs[0], axis=axis)
  • Removed the pytest.skip from test_concat_from_sequence.
  • Parameterized the test to explicitly check both standard concatenation (new_axis=0, axis=0 yielding [64, 32]) and stacking operations (new_axis=1, axis=1 yielding [32, 2, 32]).

Testing

I tested the implementation via running:

pytest tests/python/relax/test_frontend_onnx.py::test_concat_from_sequence

and all tests passed:
image

Reference

https://onnx.ai/onnx/operators/onnx__ConcatFromSequence.html
https://onnx.ai/onnx/operators/onnx__SequenceInsert.html

partially addresses #18945

@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 implements support for the new_axis=1 attribute in the ONNX ConcatFromSequence operator by utilizing relax.op.stack. The test suite was updated to include cases for this new functionality. A review comment suggests adding a test case for concatenation along axis=1 to maintain the test coverage present in the previous version.

Comment thread tests/python/relax/test_frontend_onnx.py
@rknastenka rknastenka closed this Apr 6, 2026
@rknastenka rknastenka reopened this Apr 6, 2026

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good to me. Please add a validation check for new_axis not in (0, 1), currently invalid values silently fall through to the concat branch. Also, the test coverage needs more cases: at minimum add (1, 0, [2, 32, 32]) and (1, -1, [32, 32, 2]) to cover basic stack-on-axis-0 and negative axis.

@rknastenka

rknastenka commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

Last Commits summary:

  • support more test cases (1,0) & (1, -1)
  • validation check for new_axis not in (0, 1)
  • Refactor SequenceInsert with proper out-of-bounds boundary checks
  • Refactor SequenceErase and SequenceInsert to use pythonic list unpacking.
  • Add 2 more tests including (multiple tensors, edge dimensions, and exception handling)

thanks to @Dayuxiaoshui in #19360....i added one the tests he created and got inspired for other modifications as well :)

@tlopex tlopex merged commit f0863fd into apache:main Apr 7, 2026
9 checks passed
@rknastenka rknastenka deleted the feat branch April 7, 2026 13:21
Aharrypotter pushed a commit to Aharrypotter/tvm that referenced this pull request Apr 10, 2026
apache#19361)

## Description

This PR adds support for `new_axis=1` in the ONNX `ConcatFromSequence`
operator, which was previously raising a `NotImplementedError`.

*Note regarding the tracking issue:* The tracking issue listed this task
as "SequenceInsert — Does not support inserting with new axis.", but i
think it meant `ConcatFromSequence`. ONNX's `SequenceInsert` does not
have a `new_axis` attribute, whereas `ConcatFromSequence` does and was
throwing the "Insert new axis is not supported yet" error. This PR
implements the missing feature.

## Changes:
- Replaced the `NotImplementedError` in `ConcatFromSequence` with
`relax.op.stack(inputs[0], axis=axis)`
- Removed the `pytest.skip` from `test_concat_from_sequence`.
- Parameterized the test to explicitly check both standard concatenation
(`new_axis=0, axis=0` yielding `[64, 32]`) and stacking operations
(`new_axis=1, axis=1` yielding `[32, 2, 32]`).

## Testing
I tested the implementation via running:
```
pytest tests/python/relax/test_frontend_onnx.py::test_concat_from_sequence
```
and all tests passed:
<img width="1044" height="89" alt="image"
src="https://github.com/user-attachments/assets/25d6ad26-ad4b-4437-9fa5-e29efc9e0c9f"
/>


## Reference
https://onnx.ai/onnx/operators/onnx__ConcatFromSequence.html
https://onnx.ai/onnx/operators/onnx__SequenceInsert.html

partially addresses apache#18945
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.

2 participants