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

[WIP] Support Alias V2 #1276

Closed
wants to merge 0 commits into from
Closed

Conversation

eedalong
Copy link
Collaborator

No description provided.

return operand;
}

struct LhloAliasOpRewriter
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the difference with ArgsMutationOp rewrite pass? I prefer using or extend args-mutation op instead of a new AliasOp.

struct LhloArgsMutationOpRewriter
: public OpRewritePattern<lmhlo_disc::ArgsMutationOp> {
explicit LhloArgsMutationOpRewriter(MLIRContext* context)
: OpRewritePattern(context) {}
LogicalResult matchAndRewrite(lmhlo_disc::ArgsMutationOp lhloOp,
PatternRewriter& rewriter) const override {
auto op = lhloOp.getOperation();
auto operands = op->getOperands();
Value value = backtraceOperand<memref::ReinterpretCastOp>(operands[0]);
value.replaceAllUsesWith(operands[1]);
rewriter.eraseOp(op);
return success();
}
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a WIP version, in the formal version, we need to add inc_ref && dealloc pair for safe memory reuse. But here since we are reusing module input, we can be sure these input tensors are alive during DISC execution.

Copy link
Collaborator Author

@eedalong eedalong Jan 18, 2024

Choose a reason for hiding this comment

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

Yeah, extending ArgsMutationOp is definitely Ok. But when we try to reuse buffer which is not one of the op input, we might want a better name to represent this kind of situation.

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