Commit c87f5621 authored by Paul's avatar Paul
Browse files

Formatting

parent fa485ae6
...@@ -58,19 +58,20 @@ struct loader ...@@ -58,19 +58,20 @@ struct loader
auto last = std::prev(p.end(), trim); auto last = std::prev(p.end(), trim);
p.remove_instructions(last, p.end()); p.remove_instructions(last, p.end());
} }
if (optimize) if(optimize)
migraphx::run_passes(p, { migraphx::run_passes(p,
migraphx::eliminate_identity{}, {
migraphx::dead_code_elimination{}, migraphx::eliminate_identity{},
migraphx::simplify_algebra{}, migraphx::dead_code_elimination{},
migraphx::dead_code_elimination{}, migraphx::simplify_algebra{},
migraphx::simplify_reshapes{}, migraphx::dead_code_elimination{},
migraphx::dead_code_elimination{}, migraphx::simplify_reshapes{},
migraphx::propagate_constant{}, migraphx::dead_code_elimination{},
migraphx::dead_code_elimination{}, migraphx::propagate_constant{},
migraphx::eliminate_pad{}, migraphx::dead_code_elimination{},
migraphx::dead_code_elimination{}, migraphx::eliminate_pad{},
}); migraphx::dead_code_elimination{},
});
return p; return p;
} }
}; };
......
...@@ -190,7 +190,7 @@ auto pop_back_args(Ts&&... xs) ...@@ -190,7 +190,7 @@ auto pop_back_args(Ts&&... xs)
}; };
} }
template<class T> template <class T>
auto always(T x) auto always(T x)
{ {
return [=](auto&&...) { return x; }; return [=](auto&&...) { return x; };
......
...@@ -242,7 +242,7 @@ void find_matches(program& p, Ms&&... ms) ...@@ -242,7 +242,7 @@ void find_matches(program& p, Ms&&... ms)
struct lazy_and struct lazy_and
{ {
template<class F, class G> template <class F, class G>
bool operator()(F f, G g) const bool operator()(F f, G g) const
{ {
return f() and g(); return f() and g();
...@@ -251,7 +251,7 @@ struct lazy_and ...@@ -251,7 +251,7 @@ struct lazy_and
struct lazy_or struct lazy_or
{ {
template<class F, class G> template <class F, class G>
bool operator()(F f, G g) const bool operator()(F f, G g) const
{ {
return f() or g(); return f() or g();
...@@ -266,12 +266,9 @@ struct folder ...@@ -266,12 +266,9 @@ struct folder
{ {
return make_bf_matcher([=](matcher_context& ctx, instruction_ref ins) { return make_bf_matcher([=](matcher_context& ctx, instruction_ref ins) {
Op op; Op op;
auto matched = [&](auto m) { auto matched = [&](auto m) { return [&] { return ctx.matched(m, ins); }; };
return [&]{ return ctx.matched(m, ins); }; bool matches =
}; fold([&](auto x, auto y) { return op(always(x), matched(y)); })(Start, ms...);
bool matches = fold([&](auto x, auto y) {
return op(always(x), matched(y));
})(Start, ms...);
if(matches == Matches) if(matches == Matches)
return ins; return ins;
return ctx.not_found(); return ctx.not_found();
...@@ -286,13 +283,10 @@ struct folder ...@@ -286,13 +283,10 @@ struct folder
Op op; Op op;
bool matches = Start; bool matches = Start;
select(start, [&](auto ins) { select(start, [&](auto ins) {
auto matched = [&](auto m) { auto matched = [&](auto m) { return [&] { return ctx.matched(m, ins); }; };
return [&]{ return ctx.matched(m, ins); };
};
auto fold_match = [&] { auto fold_match = [&] {
return fold([&](auto x, auto y) { return fold([&](auto x, auto y) { return op(always(x), matched(y)); })(
return op(always(x), matched(y)); Start, ms...);
})(Start, ms...);
}; };
matches = op(always(matches), fold_match); matches = op(always(matches), fold_match);
}); });
......
...@@ -214,11 +214,7 @@ void simplify_reshapes::apply(program& p) const ...@@ -214,11 +214,7 @@ void simplify_reshapes::apply(program& p) const
// Skip possible dead instructions // Skip possible dead instructions
if(ins->outputs().empty() and ins != end) if(ins->outputs().empty() and ins != end)
continue; continue;
match::find_matches(p, match::find_matches(p, ins, find_nop_reshapes{}, find_reshaper{}, find_transpose{}
ins,
find_nop_reshapes{},
find_reshaper{},
find_transpose{}
// find_concat_transpose{} // find_concat_transpose{}
); );
} }
......
...@@ -232,10 +232,10 @@ struct find_triadd ...@@ -232,10 +232,10 @@ struct find_triadd
void apply(program& p, match::matcher_result r) const void apply(program& p, match::matcher_result r) const
{ {
auto add_ins = r.instructions["add"]; auto add_ins = r.instructions["add"];
auto input_ins = r.instructions["input"]; auto input_ins = r.instructions["input"];
auto ins = r.result; auto ins = r.result;
auto args = add_ins->inputs(); auto args = add_ins->inputs();
assert(add_ins != input_ins); assert(add_ins != input_ins);
auto is_broadcasted = [](auto arg) { return arg->get_shape().broadcasted(); }; auto is_broadcasted = [](auto arg) { return arg->get_shape().broadcasted(); };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment