Repository navigation
Conversation
92adf73 to
ca5f6d0
Compare
| } | ||
|
|
||
| Attribute getLayout(Attribute attr, RankedTensorType type) const { | ||
| return EncodingNopLayoutAttr::get(attr.getContext()); |
There was a problem hiding this comment.
Is it correct? I thought that it should be something like identity pad encoding attribute.
MLIRContext *ctx = getContext();
SmallVector<int64_t> zeros(type.getRank(), 0);
return IREE::Encoding::PadEncodingLayoutAttr::get(
ctx, DenseI64ArrayAttr::get(ctx, zeros));There was a problem hiding this comment.
I don't get this, why does it need to become a PadEncodingLayoutAttr? I guess it could become any attribute that implements SerializableEncodingAttrInterface and is an identity layout, but then it would go down a different route in the type converter. What I did here is make EncodingNopLayoutAttr a SerializableEncodingAttrInterface as well, so that it can just return itself and handle its own type conversion (which is likely indeed the same as the type conversion for any other encoding with identity layout).
There was a problem hiding this comment.
Thanks for the good question, and I've been thinking it whole today. You are right that it can be any attribute that implements SerializableEncodingAttrInterface. I over-index on the point that I want to separate "tensor encoding attribute" and "encoding resolvers" when possible. And I made a mistake that ties SerializableEncodingAttrInterface to tensor encoding attribute. Because returning a resolver smelled weird to me. Now I realized that also what we've been doing.
| return EncodingNopLayoutAttr::get(attr.getContext()); | |
| return attr; |
Let me put my thoughts here for visibility, and I'll convert them to issues if I figure action items.
IMO, there are two types of encodings. One is the encodings that will be attached to tensor types, and the other is the encoding resolvers. E.g., iree_encoding.encoding and iree_encoding.layout are tensor encoding attributes, iree_gpu.pad_layout_attr is an encoding resolver. I want to keep a clear line between these two categories. It might not be feasible as they evolve, but so far I haven't seen an example that could break my mental model.
My mistake was that I thought the return value of getLayout() falls into the former category. E.g., SpecializedEncodingAttr is not an encoding resolver to me, but it implements the interface for getLayout method. I implemented before we have today's understanding, and I'll fix it.
There was a problem hiding this comment.
#20718 fixes the issue that leads me to the wrong direction.
There was a problem hiding this comment.
IMO, there are two types of encodings. One is the encodings that will be attached to tensor types, and the other is the encoding resolvers. E.g., iree_encoding.encoding and iree_encoding.layout are tensor encoding attributes, iree_gpu.pad_layout_attr is an encoding resolver. I want to keep a clear line between these two categories.
That makes sense to me. I got guided by CPUEncodingLayoutAttr, VMVXEncodingLayoutAttr and GPUEncodingLayoutAttr implementing both the resolver and serializable encoding interfaces. On the other hand, GPUPadLayoutAttr only implements resolver interface and its getLayout returns a serializable PadEncodingLayoutAttr. We should probably standardize this? And based on your comment, I think we would ideally want separate attributes for the encoding resolvers and encodings?
Also, it might help making a clear distinction if we had some visual clue on whether an attribute is a resolver or not, like renaming GPUPadLayoutAttr to GPUPadLayoutResolverAttr?
There was a problem hiding this comment.
Yes, let me try to collect what we have for the encodings, and we will get a clearer picture. I think we are close to a point that we can have concrete definition, and I can document them in EncodingBase.td, like the other dialects. E.g., FlowBased.td:
iree/compiler/src/iree/compiler/Dialect/Flow/IR/FlowBase.td
Lines 27 to 64 in 02cf396
RE renaming, I'll create an issue and get back to this. I might need to tweak UnspcecializedEncodingAttr, or have a new resolver (e.g., UnspecializedEncodingResolver) that converts unspecialized_encoding to specialized encoding. I'd also like to discuss the naming after I create the issue. E.g., could we drop Encoding from the naming, since they are already within Encoding namespace? I'll propose the new names in the issue.
There was a problem hiding this comment.
I'd also like to discuss the naming after I create the issue. E.g., could we drop Encoding from the naming, since they are already within Encoding namespace? I'll propose the new names in the issue.
+1 on that, I was thinking the same.
There was a problem hiding this comment.
I created an identity layout resolver when I worked on encoding specialization. Can you help evaluate if we can retire the Codegen one and switch it to IREE::Encoding::IdentityEncoding in a follow-up? I think it will have to implement lowerOp method, then it can work.
There was a problem hiding this comment.
Let me take it over because I need to revisit the old encoding attributes.
67fab2f to
458a3ad
Compare
hanhanW
left a comment
There was a problem hiding this comment.
LGTM % 2 minor nits.
I made a mistake in the previous review, and I left how I made the mistake to the comment. I'll fix it, and sorry about that.
| } | ||
|
|
||
| Attribute getLayout(Attribute attr, RankedTensorType type) const { | ||
| return EncodingNopLayoutAttr::get(attr.getContext()); |
There was a problem hiding this comment.
Thanks for the good question, and I've been thinking it whole today. You are right that it can be any attribute that implements SerializableEncodingAttrInterface. I over-index on the point that I want to separate "tensor encoding attribute" and "encoding resolvers" when possible. And I made a mistake that ties SerializableEncodingAttrInterface to tensor encoding attribute. Because returning a resolver smelled weird to me. Now I realized that also what we've been doing.
| return EncodingNopLayoutAttr::get(attr.getContext()); | |
| return attr; |
Let me put my thoughts here for visibility, and I'll convert them to issues if I figure action items.
IMO, there are two types of encodings. One is the encodings that will be attached to tensor types, and the other is the encoding resolvers. E.g., iree_encoding.encoding and iree_encoding.layout are tensor encoding attributes, iree_gpu.pad_layout_attr is an encoding resolver. I want to keep a clear line between these two categories. It might not be feasible as they evolve, but so far I haven't seen an example that could break my mental model.
My mistake was that I thought the return value of getLayout() falls into the former category. E.g., SpecializedEncodingAttr is not an encoding resolver to me, but it implements the interface for getLayout method. I implemented before we have today's understanding, and I'll fix it.
There was a problem hiding this comment.
Let me take it over because I need to revisit the old encoding attributes.
Signed-off-by: Jorn Tuyls <[email protected]>
458a3ad to
9a2c5aa
Compare
…ree-org#20700) Adds the `convertType` interface method to `SerializableEncodingAttrInterface`. This is the first stage for collapsing MaterializeEncodingIntoPadding into MaterializeEncoding, see iree-org#20160. Note that this removes the need for MaterializePadEncodingTypeConverter if the `convertType` method is implemented for `PadEncodingLayoutAttr`, however, this is intentionally left out of the PR as @MaheshRavishankar is looking at adjusting the MaterializeEncodingIntoPadding for dynamic padding. To check what it looks like with MaterializePadEncodingTypeConverter collapsed into MaterializeEncodingTypeConverter you can view this branch instead: https://github.com/iree-org/iree/compare/main...jtuyls:materialize-encoding-into-padding-convert-type?expand=1. Second note that while the type conversion for `EncodingNopLayoutAttr` was previously combined with the common implementation for `CPUEncodingLayoutAttr`, `VMVXEncodingLayoutAttr` and `GPUEncodingLayoutAttr`, this PR provides a minimal standalone implementation for clarity on what's going on. `CPUEncodingLayoutAttr`, `VMVXEncodingLayoutAttr` and `GPUEncodingLayoutAttr` still share the same implementation as they did previously through the `convertType` implementation in HostSerializableEncodingAttrInterfaceExternalModelBase. `EncodingNopLayoutAttr` now implements both IREE::Encoding::EncodingLayoutResolverAttrInterface and IREE::Encoding::SerializableEncodingAttrInterface to go down the same path as the above attributes, but provides its own implementation. Signed-off-by: Jorn Tuyls <[email protected]>
…20700) Adds the `convertType` interface method to `SerializableEncodingAttrInterface`. This is the first stage for collapsing MaterializeEncodingIntoPadding into MaterializeEncoding, see #20160. Note that this removes the need for MaterializePadEncodingTypeConverter if the `convertType` method is implemented for `PadEncodingLayoutAttr`, however, this is intentionally left out of the PR as @MaheshRavishankar is looking at adjusting the MaterializeEncodingIntoPadding for dynamic padding. To check what it looks like with MaterializePadEncodingTypeConverter collapsed into MaterializeEncodingTypeConverter you can view this branch instead: https://github.com/iree-org/iree/compare/main...jtuyls:materialize-encoding-into-padding-convert-type?expand=1. Second note that while the type conversion for `EncodingNopLayoutAttr` was previously combined with the common implementation for `CPUEncodingLayoutAttr`, `VMVXEncodingLayoutAttr` and `GPUEncodingLayoutAttr`, this PR provides a minimal standalone implementation for clarity on what's going on. `CPUEncodingLayoutAttr`, `VMVXEncodingLayoutAttr` and `GPUEncodingLayoutAttr` still share the same implementation as they did previously through the `convertType` implementation in HostSerializableEncodingAttrInterfaceExternalModelBase. `EncodingNopLayoutAttr` now implements both IREE::Encoding::EncodingLayoutResolverAttrInterface and IREE::Encoding::SerializableEncodingAttrInterface to go down the same path as the above attributes, but provides its own implementation. Signed-off-by: Jorn Tuyls <[email protected]>
Adds the
convertTypeinterface method toSerializableEncodingAttrInterface. This is the first stage for collapsing MaterializeEncodingIntoPadding into MaterializeEncoding, see #20160.Note that this removes the need for MaterializePadEncodingTypeConverter if the
convertTypemethod is implemented forPadEncodingLayoutAttr, however, this is intentionally left out of the PR as @MaheshRavishankar is looking at adjusting the MaterializeEncodingIntoPadding for dynamic padding. To check what it looks like with MaterializePadEncodingTypeConverter collapsed into MaterializeEncodingTypeConverter you can view this branch instead: https://github.com/iree-org/iree/compare/main...jtuyls:materialize-encoding-into-padding-convert-type?expand=1.Second note that while the type conversion for
EncodingNopLayoutAttrwas previously combined with the common implementation forCPUEncodingLayoutAttr,VMVXEncodingLayoutAttrandGPUEncodingLayoutAttr, this PR provides a minimal standalone implementation for clarity on what's going on.CPUEncodingLayoutAttr,VMVXEncodingLayoutAttrandGPUEncodingLayoutAttrstill share the same implementation as they did previously through theconvertTypeimplementation in HostSerializableEncodingAttrInterfaceExternalModelBase.EncodingNopLayoutAttrnow implements both IREE::Encoding::EncodingLayoutResolverAttrInterface and IREE::Encoding::SerializableEncodingAttrInterface to go down the same path as the above attributes, but provides its own implementation.