-
Notifications
You must be signed in to change notification settings - Fork 624
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
[DT] Switch MaterializeEncodingIntoNop to use EncodingLayoutAttr. #19294
base: main
Are you sure you want to change the base?
Conversation
da0bd66
to
ed7f415
Compare
It depends on #19292, please take a look at the last commit. Technically, it is NFC because it only shuffle the codes and make few changes. So there are no new tests. However, I do update logics for some passes and methods and introduce new things, so I do not mark it NFC in PR title. |
The revision introduces LayoutAttrInterface attribute interface and implements the codegen attribute that discards the encodings for lowering. It is used in the MaterializeEncodingIntoNop pass that turns encodings into nop. The layout attributes for other backends are not implemented, so the GPU/CPU materialization pass does not take it into account. The revision also implements a isIdentityLayout method for the MaterializeEncodingInfo struct and adds an unit test for it. Signed-off-by: hanhanW <hanhan0912@gmail.com>
ed7f415
to
dfaa723
Compare
Signed-off-by: hanhanW <hanhan0912@gmail.com>
compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenInterfaces.td
Outdated
Show resolved
Hide resolved
// iree_codegen.encoding_layout | ||
//===---------------------------------------------------------------------===// | ||
|
||
def IREECodegen_EncodingLayoutAttr : |
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 should probably rename it to EncodingNopLayoutAttr, which is clearer.
Signed-off-by: hanhanW <hanhan0912@gmail.com>
This POC shows that we're able to implement the attribute for VMVX backend. There are some dup code in the POC though. I think my next step is moving most of methods from |
compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/MaterializeEncodingIntoPackUnPack.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: hanhanW <hanhan0912@gmail.com>
2eca2f9
to
af409d0
Compare
Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
The revision introduces LayoutAttrInterface attribute interface and
implements the codegen attribute that discards the encodings for
lowering. It is used in the MaterializeEncodingIntoNop pass that turns
encodings into nop.
The new interface has two methods in the patch:
getEncodingInfo
: It takes a ranked tensor type and returns the layout.lowerOp
: It takes the operation, converted operands and result types to lower the op.The layout attributes for other backends are not implemented, so the
GPU/CPU materialization pass does not take it into account.
The revision also implements a isIdentityLayout method for the
MaterializeEncodingInfo struct and adds an unit test for it.
To support identity layout materialization, it adds a shortcut for lowering set/unset encodings ops to packing ops. If the relayout is not needed, the original source tensor value is returned. It is possible to add a folder for pack ops, but it is hard for unpack ops. Because the unpack ops have slicing semantics and it is not easy to identify it. Also, creating an operation is not cheap, so we have the shortcut in the two methods.
There are no new lit tests because the tests are covered by materialize_encoding_into_nop.mlir