Skip to content

Conversation

@newling
Copy link
Contributor

@newling newling commented Jul 8, 2025

This work in progress PR combines

  1. Use rewrite patterns: [mlir][Vector] Turn Vector Linearization from a conversion to an IR rewrite? #146030 (comment)
  2. Gradually flatten innermost dimension: https://discourse.llvm.org/t/rfc-mlir-vector-modify-remove-bit-width-specific-flattening-linearization/86876/8

It is a large change.. there are some small parts I can easily disentangle from the bulk of this PR and post as initial PRs, but then it will get a bit trickier, because the change from type conversion to rewrite patterns cannot be done gradually. It could be more gradually than this PR though for sure, by focusing just on 1 above.

Anyway, posting this to hopefully get some initial high-level thoughts

@github-actions
Copy link

github-actions bot commented Jul 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@newling newling force-pushed the linearize_gradual branch from 56bae89 to a1e180f Compare July 8, 2025 21:23
@newling
Copy link
Contributor Author

newling commented Jul 8, 2025

Hi @Hardcode84 @dcaballe @banach-space @nbpatel -- this draft PR may be of interest to you as it related to #146030 (comment) and #145115 (comment). Please let me know if you have any initial thoughts, and possibly next steps

@nbpatel
Copy link
Contributor

nbpatel commented Jul 14, 2025

Hi @Hardcode84 @dcaballe @banach-space @nbpatel -- this draft PR may be of interest to you as it related to #146030 (comment) and #145115 (comment). Please let me know if you have any initial thoughts, and possibly next steps

Hi James, now that you don't use dialect conversion, do you plan to add patterns in linearization for scf ops as well?

@newling
Copy link
Contributor Author

newling commented Jul 14, 2025

Hi James, now that you don't use dialect conversion, do you plan to add patterns in linearization for scf ops as well?

Hi Nishant, thanks for the question! My plan is for linearization of scf ops to still happen using dialect conversion, as a second step. This is implemented in this PR: see the test linearize_across_for in linearize.mlir in this PR, and the comment "Step 2: linearize SCF structured ops using type conversion" in TestVectorLinearize.cpp. I guess I could expose more of TestVectorLinearize.cpp to the user in VectorRewritePatterns.h.

@dcaballe
Copy link
Contributor

Thanks a lot for working on this!

It could be more gradually than this PR though for sure, by focusing just on 1 above.

Indeed, would it be possible to separate 1 from 2? I'm not sure I understand why both need to happen at the same time.

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.

3 participants