Skip to content

Commit

Permalink
【CINN】Remove if_simplify and rewrite block_simplify (#56307)
Browse files Browse the repository at this point in the history
* remove if_simplify and rewrite block_simplify

* delete unused if_simplify
  • Loading branch information
Courtesy-Xs authored Aug 16, 2023
1 parent f272d69 commit d0224b8
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 184 deletions.
2 changes: 0 additions & 2 deletions paddle/cinn/optim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gather_srcs(
buffer_assign.cc
replace_const_param_to_integer.cc
cast_simplify.cc
if_simplify.cc
lower_intrin.cc
cast_bool_to_int8.cc
collect_undefined_vars.cc
Expand Down Expand Up @@ -60,7 +59,6 @@ cinn_cc_test(test_optimize SRCS optimize_test.cc DEPS cinncore)
cinn_cc_test(test_cache_read_write_replace SRCS
cache_read_write_replace_test.cc DEPS cinncore)
cinn_cc_test(test_cast_simplify SRCS cast_simplify_test.cc DEPS cinncore)
cinn_cc_test(test_if_simplify SRCS if_simplify_test.cc DEPS cinncore)
cinn_cc_test(test_remove_schedule_block SRCS remove_schedule_block_test.cc DEPS
cinncore)
cinn_cc_test(test_unroll_loops SRCS unroll_loops_test.cc DEPS cinncore)
57 changes: 0 additions & 57 deletions paddle/cinn/optim/if_simplify.cc

This file was deleted.

22 changes: 0 additions & 22 deletions paddle/cinn/optim/if_simplify.h

This file was deleted.

72 changes: 0 additions & 72 deletions paddle/cinn/optim/if_simplify_test.cc

This file was deleted.

27 changes: 1 addition & 26 deletions paddle/cinn/optim/ir_simplify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ struct SimplifyBlocksMutator : public ir::IRMutator<> {
*expr = node->stmts[0];
Visit(expr, expr);
} else {
for (auto& s : node->stmts) {
Visit(&s, &s);
}
std::vector<Expr> stmts;
for (auto& s : node->stmts) {
if (s.As<ir::Block>()) {
Expand All @@ -311,35 +308,13 @@ struct SimplifyBlocksMutator : public ir::IRMutator<> {
stmts.push_back(inner_stmt);
}
} else {
IRMutator<>::Visit(&s, &s);
stmts.push_back(s);
}
}
expr->As<ir::Block>()->stmts = stmts;
}
}

void Visit(const IfThenElse* op, Expr* expr) override {
if (op->condition.As<ir::UIntImm>()) {
if (op->condition.as_bool() == false) {
VLOG(6) << "Simplify ir::IfThenElse false block";
if (expr->As<IfThenElse>()->false_case.defined()) {
*expr = expr->As<IfThenElse>()->false_case;
} else {
*expr = ir::Block::Make({});
}
} else {
if (expr->As<IfThenElse>()->true_case.defined()) {
VLOG(6) << "Simplify ir::IfThenElse true block";
*expr = expr->As<IfThenElse>()->true_case;
} else {
*expr = ir::Block::Make({});
}
}
ir::IRMutator<ir::Expr*>::Visit(expr, expr);
return;
}
ir::IRMutator<ir::Expr*>::Visit(op, expr);
}
};

struct SimplifyForLoopsMutator : public ir::IRMutator<> {
Expand Down
5 changes: 0 additions & 5 deletions paddle/cinn/optim/optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "paddle/cinn/optim/eliminate_broadcast_in_forloop.h"
#include "paddle/cinn/optim/extern_call_process.h"
#include "paddle/cinn/optim/fold_cinn_call_arguments.h"
#include "paddle/cinn/optim/if_simplify.h"
#include "paddle/cinn/optim/insert_debug_log_callee.h"
#include "paddle/cinn/optim/ir_simplify.h"
#include "paddle/cinn/optim/lower_function_call_bind_vars.h"
Expand Down Expand Up @@ -79,10 +78,6 @@ Expr Optimize(Expr e,
Simplify(&copied);
VLOG(10) << "After Optimize Simplify:" << copied;

// TODO(LiuYang): I attends to remove this part code, I integate it into
// ifthenelse part IfSimplify(&copied); VLOG(10) << "After Optimize
// IfSimplify:" << copied;

if (runtime_debug_info) {
LOG(WARNING) << "Turn on runtime debug information output";
InsertDebugLogCallee(&copied);
Expand Down

0 comments on commit d0224b8

Please sign in to comment.