Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,13 @@ bool Transpose_OpInferSymbolicShape(

bool SqueezeOpInferSymbolicShape(
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis) {
IR_ENFORCE(op->num_operands() == 2,
"SqueezeOpInferSymbolicShape ONLY support num_operands() == 2 "
"now, but got %d operands",
op->num_operands());
PADDLE_ENFORCE_EQ(
op->num_operands(),
2,
phi::errors::InvalidArgument(
"SqueezeOpInferSymbolicShape ONLY support num_operands() == 2 "
"now, but got %d operands",
op->num_operands()));

auto x_shape_or_data =
shape_analysis->GetShapeOrDataForValue(op->operand_source(0));
Expand Down Expand Up @@ -993,10 +996,13 @@ bool UniqueConsecutiveOpInferSymbolicShape(

bool UnsqueezeOpInferSymbolicShape(
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis) {
IR_ENFORCE(op->num_operands() == 2,
"UnsqueezeOp InferSymbolicShape ONLY support num_operands() == 2 "
"now, but got %d operands",
op->num_operands());
PADDLE_ENFORCE_EQ(
op->num_operands(),
2,
phi::errors::InvalidArgument(
"UnsqueezeOp InferSymbolicShape ONLY support num_operands() == 2 "
"now, but got %d operands",
op->num_operands()));

auto x_shape_or_data =
shape_analysis->GetShapeOrDataForValue(op->operand_source(0));
Expand Down
16 changes: 12 additions & 4 deletions paddle/fluid/pir/dialect/operator/ir/api_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ namespace dialect {
ApiBuilder::ApiBuilder()
: ctx_(pir::IrContext::Instance()),
builder_(std::make_shared<pir::Builder>(ctx_)) {
IR_ENFORCE(builder_ != nullptr, "api builder construct error!");
PADDLE_ENFORCE_NE(
builder_,
nullptr,
phi::errors::InvalidArgument("api builder construct error!"));
}

void ApiBuilder::SetProgram(pir::Program* program) {
IR_ENFORCE(program != nullptr, "argument of program is nullptr");
PADDLE_ENFORCE_NE(
program,
nullptr,
phi::errors::InvalidArgument("argument of program is nullptr"));
builder_->SetInsertionPointToBlockEnd(program->block());
}

Expand All @@ -50,8 +56,10 @@ void ApiBuilder::SetParameter(const std::string& name,
}

void ApiBuilder::LoadInsertionPoint() {
IR_ENFORCE(!insertion_point_stack_.empty(),
"insertion_point_stack_ is empty.");
PADDLE_ENFORCE_EQ(
!insertion_point_stack_.empty(),
true,
phi::errors::InvalidArgument("insertion_point_stack_ is empty."));
builder_->set_insertion_point(insertion_point_stack_.top());
insertion_point_stack_.pop();
}
Expand Down
Loading