Skip to content

Conversation

@srcarroll
Copy link
Contributor

@srcarroll srcarroll commented Jun 16, 2024

This patch introduces pattern rewrites for reducing the rank of named linalg contraction ops with unit spatial dim(s) to other named contraction ops. For example linalg.batch_matmul with batch size 1 -> linalg.matmul and linalg.matmul with unit LHS spatial dim -> linalg.vecmat, etc. These patterns don't support reducing the rank along reduction dimension as those don't convert to other named contraction ops.

@srcarroll srcarroll changed the title implement canonicalizer for batched linalg operations [mlir][linalg] Implement canonicalizer for batched linalg operations with batch size 1 Jun 16, 2024
@srcarroll srcarroll changed the title [mlir][linalg] Implement canonicalizer for batched linalg operations with batch size 1 [mlir][linalg] Implement patterns for reducing rank of named linalg contraction ops Jun 19, 2024
Copy link
Member

@ftynse ftynse left a comment

Choose a reason for hiding this comment

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

A bunch of nits, LGTM otherwise.

@srcarroll srcarroll marked this pull request as ready for review June 21, 2024 16:39
@srcarroll srcarroll requested a review from ftynse June 21, 2024 23:42
@srcarroll srcarroll merged commit 431213c into llvm:main Jun 24, 2024
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…ontraction ops (llvm#95710)

This patch introduces pattern rewrites for reducing the rank of named
linalg contraction ops with unit spatial dim(s) to other named
contraction ops. For example `linalg.batch_matmul` with batch size 1 ->
`linalg.matmul` and `linalg.matmul` with unit LHS spatial dim ->
`linalg.vecmat`, etc. These patterns don't support reducing the rank
along reduction dimension as those don't convert to other named
contraction ops.
@j2kun
Copy link
Contributor

j2kun commented Jan 17, 2025

This is a neat feature! Any objection into making it a standalone pass?

@srcarroll
Copy link
Contributor Author

This is a neat feature! Any objection into making it a standalone pass?

Thanks. No objection at all. If I remember correctly the pattern rewrites are public so they should be able to be reused by any pass. In fact someone requested a feature to have options to choose what ops are targeted for reduction (or choose how low to take the rank). I was going to but haven't had time so if you want to address that too that would be great.

@srcarroll
Copy link
Contributor Author

srcarroll commented Jan 17, 2025

the pattern rewrites are public

correction. only the populate patterns function is public. so we can either make the pattern rewrite public to make it easier to build passes with individual patterns, or just add the options to the populate function. i dont think i have a particular preference

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