Skip to content

[Relax] Normalize negative concat axis in ReorderPermuteDimsAfterConcat#19588

Draft
cchung100m wants to merge 3 commits into
apache:mainfrom
cchung100m:issue-19575
Draft

[Relax] Normalize negative concat axis in ReorderPermuteDimsAfterConcat#19588
cchung100m wants to merge 3 commits into
apache:mainfrom
cchung100m:issue-19575

Conversation

@cchung100m
Copy link
Copy Markdown
Contributor

Hi Committers,

This PR fixes #19575.

Root Cause

ReorderPermuteDimsAfterConcat reads concat axis and uses it as an index into the permutation axes.

When concat(axis=-1) is used, the negative axis was converted directly to size_t before indexing, which can produce an out-of-range index and crash (e.g. IndexError: Index -1 out of bounds 4).

Solution

In src/relax/transform/reorder_permute_dims_after_concat.cc:

  1. Read concat axis as signed integer first.
  2. Normalize negative axis with axis += ndim.
  3. Add explicit range checks after normalization.
  4. Use the normalized axis for permutation-axis remapping

This keeps behavior unchanged for non-negative axes and only fixes negative-axis handling.

Copy link
Copy Markdown
Contributor

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

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 updates the reorder_permute_dims_after_concat.cc file to implement axis normalization and bounds checking for concatenation operations. A critical issue was identified where the new implementation was added alongside the old one, resulting in variable redefinitions and a compilation error.

Comment thread src/relax/transform/reorder_permute_dims_after_concat.cc
@cchung100m cchung100m changed the title [Relax] Normalize negative concat axis in ReorderPermuteDimsAfterConcat [Relax] Normalize negative concat axis in ReorderPermuteDimsAfterConcat May 19, 2026
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] ReorderPermuteDimsAfterConcat crashes with negative concat axis

1 participant