Skip to content
Merged
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
16 changes: 4 additions & 12 deletions paddle/fluid/pir/dialect/operator/ir/manual_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,19 @@ bool AddNOpInferSymbolicShape(pir::Operation *op,
"should be larger than 0. But received X's dimensions %d.",
inputs_shape.size()));
symbol::TensorShapeOrDataDimExprs candidate_shape = inputs_shape.front();
size_t candidate_idx = 0;
for (size_t i = 1; i < inputs_shape.size(); ++i) {
// 0D tensor
if (inputs_shape[i].shape().size() == 0) {
continue;
}
if (candidate_shape.shape().size() == 0) {
candidate_shape = inputs_shape[i];
candidate_idx = i;
continue;
}
PADDLE_ENFORCE_EQ(candidate_shape,
inputs_shape[i],
common::errors::InvalidArgument(
"The input tensor X of AddNOp must"
" have same shape. But received X[%d]'s shape = "
"[%s], X[%d]'s shape = [%s].",
candidate_idx,
candidate_shape,
i,
inputs_shape[i]));
for (size_t j = 0; j < candidate_shape.shape().size(); ++j) {
infer_context->AddEqualCstr(candidate_shape.shape()[j],
inputs_shape[i].shape()[j]);
}
}
infer_context->SetShapeOrDataForValue(
op->result(0), symbol::ShapeOrDataDimExprs{candidate_shape});
Expand Down