Commit 41e3b9f6 authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

fixup! Add support for division by zero errors

parent c2d4ceb0
......@@ -41,6 +41,8 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_TRACE_PASSES);
auto lit_broadcast() { return match::any_of(match::is_constant(), match::name("broadcast")); }
auto not_lit_broadcast() { return match::none_of(match::is_constant(), match::name("broadcast")); }
auto op_lit_broadcast(std::string op, std::string x, std::string y)
......@@ -856,10 +858,13 @@ struct find_zero_div_const
auto matcher() const { return match::name("div")(match::arg(1)(match::has_value(0.0f))); }
void apply [[noreturn]] (const module& m, const match::matcher_result& r) const
{
if(enabled(MIGRAPHX_TRACE_PASSES{}))
{
m.debug_print();
std::cout << "ERROR:DIV_BY_ZERO: ";
m.debug_print(r.result);
}
MIGRAPHX_THROW("ERROR: Matched division by zero in pass");
}
};
......
......@@ -906,7 +906,7 @@ TEST_CASE(simplify_div_zero_const)
}
catch(const std::runtime_error& e)
{
std::cerr << e.what() << std::endl;
(void)e;
result = true;
}
EXPECT(result);
......
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