Repository navigation
[TensorExt][NFC] Remove dependency on Encoding through ExternalModel - #20612
Conversation
Signed-off-by: Jorn Tuyls <[email protected]>
ea31bb9 to
7c78a13
Compare
| //===----------------------------------------------------------------------===// | ||
| // Type Interfaces | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| struct EncodingTypeExternalModel | ||
| : public IREE::Encoding::EncodingTypeInterface::ExternalModel< | ||
| EncodingTypeExternalModel, IREE::TensorExt::DispatchTensorType> { | ||
|
|
||
| Type getEncodingType(Type type) const { | ||
| auto dispatchTensorType = cast<IREE::TensorExt::DispatchTensorType>(type); | ||
| return dispatchTensorType.getBoundType(); | ||
| } | ||
|
|
||
| Type updateEncoding(Type type, Attribute encoding) const { | ||
| auto dispatchTensorType = cast<IREE::TensorExt::DispatchTensorType>(type); | ||
| return IREE::TensorExt::DispatchTensorType::get( | ||
| dispatchTensorType.getAccess(), dispatchTensorType.getShape(), | ||
| dispatchTensorType.getBoundElementType(), encoding); | ||
| } | ||
| }; |
There was a problem hiding this comment.
I feel that this should be implemented in EncodingExternalModels.cpp after I looked at other files, because the interface is defined in Encoding dialect. E.g., StreamExternalModels.cpp has all the implementation from other dialects for Stream interfaces.
@pashu123 is adding the file in #20567, and I think you can go ahead to create the file. The conflicts should be easy to fix, so you don't need to wait for each other.
There was a problem hiding this comment.
I don't think it's that consistent as other ExternalModels files seem to do it the other way around:
That way, you can keep track of all the interfaces attached to for example HAL ops/attributes and types in a single file instead of having them spread across different files, which is preferable imo as it makes it easier to look up and maintain the interfaces of ops. This is also more closely resembles the 'normal' way ops implement interfaces directly as the ops would reference the interface they implement and it's not the interfaces that reference the ops that should implement the interface.
There was a problem hiding this comment.
Yes, I see your point and I like the idea that it is easier to look up and maintain the interfaces for the ops.
…ree-org#20612) There is no strong dependency of `DispatchTensorType` on the Encoding dialect as the encoding can be just any attribute and is optional, so I don't think there's a need to have the TensorExt dialect explicitly depend on the Encoding just for the interface. Decoupling them would avoid potential circular dependency issues (I ran into that while working on iree-org#20160 (comment)), remove the need for other (potential) users of the TensorExt dialect to use the encoding and allow users to bring their own encoding interfaces while avoiding having to bring in the Encoding dialect. Signed-off-by: Jorn Tuyls <[email protected]>
…20612) There is no strong dependency of `DispatchTensorType` on the Encoding dialect as the encoding can be just any attribute and is optional, so I don't think there's a need to have the TensorExt dialect explicitly depend on the Encoding just for the interface. Decoupling them would avoid potential circular dependency issues (I ran into that while working on #20160 (comment)), remove the need for other (potential) users of the TensorExt dialect to use the encoding and allow users to bring their own encoding interfaces while avoiding having to bring in the Encoding dialect. Signed-off-by: Jorn Tuyls <[email protected]>
There is no strong dependency of
DispatchTensorTypeon the Encoding dialect as the encoding can be just any attribute and is optional, so I don't think there's a need to have the TensorExt dialect explicitly depend on the Encoding just for the interface. Decoupling them would avoid potential circular dependency issues (I ran into that while working on #20160 (comment)), remove the need for other (potential) users of the TensorExt dialect to use the encoding and allow users to bring their own encoding interfaces while avoiding having to bring in the Encoding dialect.