Commit 86c464ca authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Remove addition matcher and roll in with div/mul unit matchers

Add handling for zero addition operations into the find_unit_ops() matcher functor.
parent 8ddb505a
...@@ -859,33 +859,18 @@ struct find_unit_ops ...@@ -859,33 +859,18 @@ struct find_unit_ops
match::either_arg(0, 1)(match::has_value(1.0f), match::any().bind("x"))); match::either_arg(0, 1)(match::has_value(1.0f), match::any().bind("x")));
auto div_1 = auto div_1 =
match::name("div")(match::args(match::any().bind("x"), match::has_value(1.0f))); match::name("div")(match::args(match::any().bind("x"), match::has_value(1.0f)));
return match::any_of(mul_1, div_1); auto add_0 = match::name("add")(
}
void apply(module& m, const match::matcher_result& r) const
{
auto ins = r.result;
auto c_in = r.instructions["x"];
m.replace_instruction(ins, c_in);
}
};
struct find_zero_add_const
{
auto matcher() const
{
return match::name("add")(
match::either_arg(0, 1)(match::has_value(0.0f), match::any().bind("x"))); match::either_arg(0, 1)(match::has_value(0.0f), match::any().bind("x")));
return match::any_of(mul_1, div_1, add_0);
} }
void apply(module& m, const match::matcher_result& r) const void apply(module& m, const match::matcher_result& r) const
{ {
auto ins = r.result; auto ins = r.result;
auto x_in = r.instructions["x"]; auto c_in = r.instructions["x"];
m.replace_instruction(ins, x_in); m.replace_instruction(ins, c_in);
} }
}; };
...@@ -1101,7 +1086,6 @@ void simplify_algebra::apply(module& m) const ...@@ -1101,7 +1086,6 @@ void simplify_algebra::apply(module& m) const
match::find_matches(m, match::find_matches(m,
find_inner_broadcast{}, find_inner_broadcast{},
find_double_add_lit_broadcast{}, find_double_add_lit_broadcast{},
find_zero_add_const{},
find_add_lit_broadcast{}, find_add_lit_broadcast{},
find_add_convs{}, find_add_convs{},
find_conv_dot_horiz_fusion{}, find_conv_dot_horiz_fusion{},
......
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