Skip to content

[Codegen][LLVMGPU] Add layout support for ArgCompare operations#23693

Merged
bangtianliu merged 2 commits intoiree-org:mainfrom
bangtianliu:argcompare-layout-propagation
Mar 30, 2026
Merged

[Codegen][LLVMGPU] Add layout support for ArgCompare operations#23693
bangtianliu merged 2 commits intoiree-org:mainfrom
bangtianliu:argcompare-layout-propagation

Conversation

@bangtianliu
Copy link
Copy Markdown
Contributor

@bangtianliu bangtianliu commented Mar 8, 2026

This PR adds tensor layout propagation for iree_linalg_ext.arg_compare operations in the LLVMGPU backend, enabling arg_compare to participate in the vector distribution pipeline.

Issue: #23005
Assisted-by: Claude Code

@bangtianliu bangtianliu marked this pull request as draft March 8, 2026 00:14
@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch 4 times, most recently from 95a1651 to 09f915e Compare March 8, 2026 00:58
@bangtianliu bangtianliu marked this pull request as ready for review March 8, 2026 04:27
@bangtianliu bangtianliu marked this pull request as draft March 8, 2026 04:56
@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch from 09f915e to 1b3345e Compare March 8, 2026 17:20
@bangtianliu bangtianliu marked this pull request as ready for review March 9, 2026 04:55
@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch 3 times, most recently from 1974732 to fd40274 Compare March 25, 2026 20:14
Copy link
Copy Markdown
Contributor

@Max191 Max191 left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe wait for someone who is more well-versed with layout analysis as well.

Comment on lines +291 to +300
if (argCompare.getInitValue() == val) {
LDBG() << " Propagating init_value layout to result\n";
addCandidate(argCompare.getResultValue(), layout);
continue;
}
if (argCompare.getInitIndex() == val) {
LDBG() << " Propagating init_index layout to result\n";
addCandidate(argCompare.getResultIndex(), layout);
continue;
}
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.

Weird edge case: Couldn't the init value and init index technically be the same tensor? I highly doubt there would ever be an arg_compare like that, but just for completeness, should we remove the continues in these init cases and put the continue at the end of the containing if (auto argCompare = dyn_cast<ArgCompareOp>(user)) { instead?

Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch from fd40274 to fd0e107 Compare March 27, 2026 17:33
@bangtianliu bangtianliu requested a review from sommerlukas March 27, 2026 17:56
@bangtianliu
Copy link
Copy Markdown
Contributor Author

cc @Groverkss @sommerlukas for review

Copy link
Copy Markdown
Contributor

@sommerlukas sommerlukas left a comment

Choose a reason for hiding this comment

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

Just a few small things on the tests.

@bangtianliu bangtianliu requested a review from sommerlukas March 30, 2026 15:30
Copy link
Copy Markdown
Contributor

@sommerlukas sommerlukas left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments, but I think we should have the check lines actually match the expected value.

@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch from a60ed3c to d51a71f Compare March 30, 2026 16:10
@bangtianliu bangtianliu requested a review from sommerlukas March 30, 2026 16:10
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
@bangtianliu bangtianliu force-pushed the argcompare-layout-propagation branch from d51a71f to 371a77e Compare March 30, 2026 16:29
@bangtianliu bangtianliu merged commit 4d476ec into iree-org:main Mar 30, 2026
61 of 63 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.

4 participants