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

【PIR OpTest Fix No.5】 fix test_tril_triu_op #59734

Merged
merged 5 commits into from
Dec 25, 2023
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
23 changes: 23 additions & 0 deletions paddle/fluid/ir_adaptor/translator/op_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,28 @@ struct TrilAndTriuOpTranscriber : public OpTranscriber {
}
};

struct TrilAndTriuGradOpTranscriber : public OpTranscriber {
pir::OpInfo LoopkUpOpInfo(pir::IrContext* ctx,
const OpDesc& op_desc) override {
bool lower = PADDLE_GET_CONST(bool, op_desc.GetAttr("lower"));
std::string target_op_name = "";
if (lower) {
target_op_name = "pd_op.tril_grad";
} else {
target_op_name = "pd_op.triu_grad";
}
const auto& op_info = ctx->GetRegisteredOpInfo(target_op_name);
if (!op_info) {
IR_THROW(
"Op tril_triu_grad should have corresponding OpInfo pd_op.tril_grad "
"or "
"pd_op.triu_grad.");
}

return op_info;
}
};

using ValueInfo =
std::tuple<std::vector<int64_t>, dialect::DenseTensorType, pir::OpResult>;

Expand Down Expand Up @@ -2988,6 +3010,7 @@ OpTranslator::OpTranslator() {
special_handlers["split"] = SplitOpTranscriber();
special_handlers["sum"] = AddNOpTranscriber();
special_handlers["tril_triu"] = TrilAndTriuOpTranscriber();
special_handlers["tril_triu_grad"] = TrilAndTriuGradOpTranscriber();
special_handlers["matrix_rank"] = MatrixRankOpTranscriber();
special_handlers["mul"] = MulOpTranscriber();
special_handlers["mul_grad"] = MulGradOpTranscriber();
Expand Down
1 change: 1 addition & 0 deletions test/white_list/pir_op_test_white_list
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ test_transpose_int8_mkldnn_op
test_transpose_op
test_triangular_solve_op
test_tril_indices_op
test_tril_triu_op
test_trilinear_interp_v2_op
test_triu_indices_op
test_trunc_op
Expand Down