-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[PIR] Reconstruct the Verify system #58052
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f1ad83c
refine verify of if op
zhangbo9674 37bbb60
fix
zhangbo9674 a0d9087
fix
zhangbo9674 01e0f0a
fix
zhangbo9674 a44df42
refine
zhangbo9674 f1938c6
fix
zhangbo9674 038b27e
fix
zhangbo9674 0aa3e05
fix
zhangbo9674 ecccac6
fix
zhangbo9674 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,45 @@ void IfOp::Print(pir::IrPrinter &printer) { | |
} | ||
os << "\n }"; | ||
} | ||
void IfOp::Verify() {} | ||
void IfOp::Verify() { | ||
if ((*this)->region(0).empty() && (*this)->region(1).empty()) { | ||
LOG(WARNING) | ||
<< "The true and false block of IfOp has not been initialized yet. " | ||
"Please manually call Verify after completion the above content for " | ||
"verification: op->dyn_cast<padding::dialect:IfOp>().Verify()"; | ||
return; | ||
} | ||
|
||
PADDLE_ENFORCE_EQ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true_region和false_region的size可以不相等。 |
||
(*this)->region(0).size(), | ||
(*this)->region(1).size(), | ||
phi::errors::PreconditionNotMet("The size %d of true_region must be " | ||
"equal to the size %d of false_region.", | ||
(*this)->region(0).size(), | ||
(*this)->region(1).size())); | ||
if ((*this)->num_results() != 0) { | ||
auto *true_last_op = (*this)->region(0).front()->back(); | ||
auto *false_last_op = (*this)->region(1).front()->back(); | ||
PADDLE_ENFORCE_EQ(true_last_op->isa<pir::YieldOp>(), | ||
true, | ||
phi::errors::PreconditionNotMet( | ||
"The last of true block must be YieldOp")); | ||
PADDLE_ENFORCE_EQ(true_last_op->num_operands(), | ||
(*this)->num_results(), | ||
phi::errors::PreconditionNotMet( | ||
"The size of last of true block op's input must be " | ||
"equal to IfOp's outputs num.")); | ||
PADDLE_ENFORCE_EQ(false_last_op->isa<pir::YieldOp>(), | ||
true, | ||
phi::errors::PreconditionNotMet( | ||
"The last of false block must be YieldOp")); | ||
PADDLE_ENFORCE_EQ(false_last_op->num_operands(), | ||
(*this)->num_results(), | ||
phi::errors::PreconditionNotMet( | ||
"The size of last of false block op's input must be " | ||
"equal to IfOp's outputs num.")); | ||
} | ||
} | ||
|
||
void WhileOp::Build(pir::Builder &builder, // NOLINT | ||
pir::OperationArgument &argument, // NOLINT | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在operation::create里面是调用了verify函数的。而create的时候,region都是空的。也就是说这个warning是一定会进入的。