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

[CINN] Delele some redundant code #69031

Merged
merged 2 commits into from
Oct 30, 2024
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
4 changes: 0 additions & 4 deletions paddle/cinn/ir/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ namespace cinn {
namespace ir {

void Module::Builder::AddFunction(ir::LoweredFunc func) {
optim::Simplify(&(func->body));
optim::SimplifyForLoops(&(func->body));
optim::SimplifyBlocks(&(func->body));
func->body = optim::Optimize(func->body, module_->target);
module_->functions.push_back(func);
}

Comment on lines 26 to 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥删除啊,删了之后和AddFunctionWithoutOptim一样了,相当于是把Add的功能清晰化了?但是外面又没有补充优化的函数

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想是不是把AddFunctionWithoutOptim也删了,要做什么优化由持有Function的人来做,不是由Module来做

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,感觉可以下个PR改一下,Module Module::Builder::Build()那里的优化也最好可以提出来

Expand Down
10 changes: 0 additions & 10 deletions paddle/cinn/optim/optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,14 @@ Expr Optimize(Expr e,

auto copied = ir::ir_utils::IRCopy(e);

FoldCINNCallArguments(&copied);
TransformPolyForToFor(&copied);
ReplaceConstParamToInteger(&copied);
// Simplify already contains CastSimplify
Simplify(&copied);
ReplaceCrossThreadReduction(&copied);
VLOG(4) << "After Optimize ReplaceCrossThreadReduction:" << copied;
ReplaceCrossBlockReduction(&copied);
VLOG(4) << "After Optimize ReplaceCrossBlockReduction:" << copied;
UnrollLoop(&copied);
VLOG(4) << "After Optimize UnrollLoop:" << copied;

VectorizeLoops(&copied, target);
VLOG(4) << "After Optimize VectorizeLoops:" << copied;
cinn::common::DefaultDeviceTarget().arch.Match(
[&](std::variant<common::UnknownArch, common::X86Arch, common::ARMArch>) {
},
Expand Down Expand Up @@ -120,10 +114,6 @@ Expr Optimize(Expr e,

ir::Module Optimize(const ir::Module& module, const Target& target) {
auto copied = ir::ir_utils::IRCopy(Expr(module));
ReplaceCrossThreadReduction(&copied);
UnrollLoop(&copied);
VectorizeLoops(&copied, Target());
VLOG(10) << "After VectorizeLoops:" << copied.as_module_ref();
RemoveScheduleBlock(&copied);
VLOG(10) << "After RemoveScheduleBlock:" << copied.as_module_ref();
LowerFunctionCallBindVars(&copied);
Expand Down