Skip to content
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

[Encoding][DT][NFC] Simplify the codes for EncodingAttr creation. #19147

Merged
merged 7 commits into from
Nov 14, 2024

Conversation

hanhanW
Copy link
Contributor

@hanhanW hanhanW commented Nov 14, 2024

We've developed few builders for the EncodingAttr; the method takes
non-attribute types. We can use the builders to avoid C++ structures to
MLIR attributes conversion.

We've developed few builders for the EncodingAttr; the method takes
non-attribute types. We can use the builders to avoid C++ structures to
MLIR attributes conversion.

Signed-off-by: hanhanW <[email protected]>
@hanhanW hanhanW changed the title Simplify code nfc [Encoding][DT][NFC] Simplify the codes for EncodingAttr creation. Nov 14, 2024
@hanhanW hanhanW enabled auto-merge (squash) November 14, 2024 00:47
Comment on lines +78 to +81
std::optional<AffineMap> newBcastMap;
if (encoding.getBcastMap()) {
newBcastMap = encoding.getBcastMap().getValue();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only part of this PR that, instead of simplifying code, adds more complex code. Why can't we continue to just pass encoding.getBcastMap() to IREE::Encoding::EncodingAttr::get like in the existing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is because encoding.getBcastMap() returns an attribute (i.e., AffineMapAttr), while the builder requires C++ structured/builtin types (i.e., std::optional<AffineMap>). Instead of having the logic here, I think we can add an std::optional<AffineMap> getBcastMapValue() method to the encoding attribute. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I like the idea, but really don't favor adding extraClassDeclarations. Can this be a plain global C++ function instead (not declared in .td, not member)? Otherwise, feel free to just drop that commit, I don't want to make this PR hard to merge and I liked the original form very much already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try to put it to a better state when I start poking the broadcast map things. I don't really know what methods could be useful and we can revisit later (when we have more needs). Revert the commits for now.

@hanhanW hanhanW merged commit 4c0fd90 into iree-org:main Nov 14, 2024
36 checks passed
@hanhanW hanhanW deleted the simplify-code-nfc branch November 14, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants