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

Support mhlo.custom_call op processing #1283

Merged
merged 5 commits into from
Mar 4, 2024

Conversation

eedalong
Copy link
Collaborator

@eedalong eedalong commented Feb 29, 2024

We convert mhlo.custom_call to mhlo_disc.custom_call_v2 and do tuple expansion during this conversion.

@eedalong eedalong force-pushed the support_mhlo_custom_call branch 6 times, most recently from c874bd7 to c49104e Compare February 29, 2024 07:01
@eedalong eedalong changed the title Support mhlo custom call Support mhlo.custom_call op processing Feb 29, 2024
}
}

if (!input_placements.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why erase the back char?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why erase the back char?

d,d,d, ---> d,d,d, remove the last ','

hloOp->setAttr("device", rewriter.getStringAttr("x"));
hloOp->setAttr("input_layouts", rewriter.getStringAttr("*"));
hloOp->setAttr("output_layouts", rewriter.getStringAttr("*"));
hloOp->setAttr("expected_input_layouts", rewriter.getStringAttr("*"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

input/output layouts should have the same operand number as input/output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

auto newCustomAttrs = DictionaryAttr::get(hloOp->getContext(), newAttrs);
hloOp->setAttr("custom_attrs", newCustomAttrs);

if (hloOp->getNumResults() == 1 &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

how do we deal with two results operand of tuple<>, Value ? Maybe we can return a failure message If we don't want to deal with this situation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@eedalong eedalong force-pushed the support_mhlo_custom_call branch 2 times, most recently from 9fe8d0d to a68bb67 Compare March 1, 2024 09:48
Copy link
Collaborator

@Yancey1989 Yancey1989 left a comment

Choose a reason for hiding this comment

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

LGTM

std::string input_placements, output_placements;
std::string input_layouts, output_layouts;
for (int i = 0; i < operands.size(); i++) {
input_placements += "d,";
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe absl::StrAppend can achieve better performance.

@eedalong eedalong merged commit 30cf3d3 into alibaba:main Mar 4, 2024
11 checks passed
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