Repository navigation
[DT] Collapse matmul_narrow_M/N field into round_dims_to attribute. - #18599
Conversation
Signed-off-by: hanhanW <[email protected]>
Signed-off-by: hanhanW <[email protected]>
Signed-off-by: hanhanW <[email protected]>
Signed-off-by: hanhanW <[email protected]>
|
oh, there are issues in vmvx + uk. Because the old path assumes that the sizes will always be aligned with 16. Let me take a look how to fix it properly. |
Signed-off-by: hanhanW <[email protected]>
| namespace mlir::iree_compiler::IREE::Encoding { | ||
|
|
||
| /// Threadshold that determines if a dimension is considered "narrow" or not. | ||
| constexpr int64_t kNarrowThreshold = 32; |
There was a problem hiding this comment.
I would call that constant kDefaultRoundDimsTo. EDIT - sorry, I realize now that the default value of round_dims_to is defined elsewhere. What I mean here is that these two constants should be united. We shouldn't hardcode the constant 32 in two different places, right?
The "narrow" concept is merely an optimization for narrow matmuls. It is one of the purposes of this constant, but since it is only an optimization purpose, it is not the most essential purpose. Instead, the primary purpose of this constant is ensuring sufficiently large allocations (the original role of round_dims_to). The naming should reflect that - so that a future developer tempted to reduce this constant's value understand that that might cause crashes, not just performance regressions.
In a follow-up PR, I would like this kDefaultRoundDimsTo to become per-target-backend, and in the case of multi-target-backend compilations, we should use the maximum value over the individual backends. WDYT?
There was a problem hiding this comment.
Nevermind, let's land your PR as-is and I will do a follow-up with what I have in mind.
The revision refines how we handle matmul_narrow_M/N in encodings. The matmul_narrow_M/N attributes are retired in the patch. The information is carried in
round_dims_toattribute which is rounded to the next power of two. E.g., if the value ofmatmul_narrow_Mis3, it will be4in theround_dims_toattribute.The
kNarrowThresholdconstant is introduced to Encoding namespace. A dimension is considered as "narrow" only if the size of the dimension is less thankNarrowThreshold.The revision implements
getMatmulNarrowMandgetMatmulNarrowNhelpers based on the definition ofround_dims_toand thekNarrowThresholdvariable. Users can call the helpers to get the narrow size of M/N. Again, you'll get the value that is rounded to the next power of two if they are considered "narrow". E.g.,getMatmulNarrowM()returns4ifMequals to3.The revision also fixes a bug in
chooseMatmulTileon CPU side. The hostDefinedUpperBound is not updated in the narrow-N cases.Fixes #17729
Fixes #15466