Commit c3edd50e authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Revert "Remove check for div zero, push this to be detected in a seperate pass"

This reverts commit fcc84214.
parent f0e84612
......@@ -851,6 +851,20 @@ struct find_div_const
}
};
struct find_zero_div_const
{
auto matcher() const
{
return match::name("div")(
match::arg(1)(match::skip_broadcasts_converts(match::has_value(0.0f))));
}
[[noreturn]] void apply(module&, const match::matcher_result&) const
{
MIGRAPHX_THROW("ERROR: Matched division by zero in pass");
}
};
struct find_unit_ops
{
auto matcher() const
......@@ -1118,6 +1132,7 @@ void simplify_algebra::apply(module& m) const
find_unit_ops{},
find_neg_unit_ops{},
find_zero_ops{},
find_zero_div_const{},
find_div_const{},
find_sub_const{},
find_rsqrt{},
......
......@@ -1096,6 +1096,28 @@ TEST_CASE(simplify_sub_neg_zero_const_vec)
EXPECT(m1 == m2);
}
TEST_CASE(simplify_div_zero_const)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", {migraphx::shape::int32_type, {1}});
auto unit = m1.add_literal(0);
m1.add_instruction(migraphx::make_op("div"), x, unit);
}
bool result = false;
try
{
run_pass(m1);
}
catch(const std::runtime_error& e)
{
(void)e;
result = true;
}
EXPECT(result);
}
TEST_CASE(simplify_sub_const)
{
migraphx::module m1;
......
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