-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support default configs for BATCH_MATMUL_* in MaterializeEncoding pass #14762
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to add this code in to LinalgExt/Utils/Utils.h
, but LinalgExt/Utils/Utils.h
is used in LinalgExt/IR/LinalgExtOps.cpp
. And we need to use linalg_ext ops, which results in cyclic library dependencies.
I'm not sure what the better way is to solve this. Here I simply creates a separate utils library.
If I put this code into LinalgExt/Utils/Utils.h
and add IREELinalgExtDialect
to the dependencies of IREELinalgExtUtils
, I'll get the error:
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"obj.IREELinalgExtDialect" of type OBJECT_LIBRARY
depends on "IREELinalgExtUtils" (strong)
"IREELinalgExtDialect" of type STATIC_LIBRARY
depends on "obj.IREELinalgExtDialect" (strong)
depends on "IREELinalgExtUtils" (strong)
"obj.IREELinalgExtUtils" of type OBJECT_LIBRARY
depends on "IREELinalgExtDialect" (strong)
"IREELinalgExtUtils" of type STATIC_LIBRARY
depends on "IREELinalgExtDialect" (strong)
depends on "obj.IREELinalgExtUtils" (strong)
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed. Build files cannot be regenerated correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHy does Utils
needs IR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new code added here needs IREE::LinalgExt::EncodingUser
, which is defined in LinalgExt/IR/LinalgExtOps.h
. So if we add the code into LinalgExt/Utils/Utils.h
instead, IIUC IREELinalgExtUtils will have a dependency to IREELinalgExtDialect.
On the other hand, LinalgExtOps.cpp is using getDimValue
and computeInterchangeFromDimPos
defined in Utils.cpp
, so it currently has a dependecy to IREELinalgExtUtils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, here I'm trying to move chooseEncodingInfoForMatmul
from IREE codegen into LinalgExt so we can reuse the same logic to choose tiling and permutations for materialization based on LinExt::EncodingUser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen similar issues in MLIR repo. I think the solution is that *IR
should not depends on *Util
. The common methods are moved to *IR.h
in upstream, and we can probably follow the convention. Dependency issue looks fine to me, and we can refactor it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaheshRavishankar Kindly ping : ) Do you have further comments on this PR?
@RoboTux FYI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Sorry I didnt know you were waiting for me to approve. I saw Hanhan approve so I just left it at that.
In #14705 we added
BATCH_MATMUL_*
encoding users and handled the materialization in IREE codegen path by providing a customMaterializeEncodingFn
. However MaterializeEncoding pass also can be called standalone, this change updates the defaultchooseEncodingInfo
function to support new encoding users.This is done by moving
chooseEncodingInfoForMatmul
under LinalgExt to reuse the logic of deciding materialization based on matmul encoding.The problem was found when adding tests for
MaterializeEncoding
withBATCH_MATMUL_*
encoding users, sinceMaterializeEncoding
pass is called standalone by--iree-linalg-ext-materialize-encoding
#14431