Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
41e3b9f6
Commit
41e3b9f6
authored
Jun 30, 2022
by
Ted Themistokleous
Browse files
fixup! Add support for division by zero errors
parent
c2d4ceb0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+8
-3
test/simplify_algebra_test.cpp
test/simplify_algebra_test.cpp
+1
-1
No files found.
src/simplify_algebra.cpp
View file @
41e3b9f6
...
@@ -41,6 +41,8 @@
...
@@ -41,6 +41,8 @@
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
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
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
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
)
auto
op_lit_broadcast
(
std
::
string
op
,
std
::
string
x
,
std
::
string
y
)
...
@@ -856,10 +858,13 @@ struct find_zero_div_const
...
@@ -856,10 +858,13 @@ struct find_zero_div_const
auto
matcher
()
const
{
return
match
::
name
(
"div"
)(
match
::
arg
(
1
)(
match
::
has_value
(
0.0
f
)));
}
auto
matcher
()
const
{
return
match
::
name
(
"div"
)(
match
::
arg
(
1
)(
match
::
has_value
(
0.0
f
)));
}
void
apply
[[
noreturn
]]
(
const
module
&
m
,
const
match
::
matcher_result
&
r
)
const
void
apply
[[
noreturn
]]
(
const
module
&
m
,
const
match
::
matcher_result
&
r
)
const
{
if
(
enabled
(
MIGRAPHX_TRACE_PASSES
{}))
{
{
m
.
debug_print
();
m
.
debug_print
();
std
::
cout
<<
"ERROR:DIV_BY_ZERO: "
;
std
::
cout
<<
"ERROR:DIV_BY_ZERO: "
;
m
.
debug_print
(
r
.
result
);
m
.
debug_print
(
r
.
result
);
}
MIGRAPHX_THROW
(
"ERROR: Matched division by zero in pass"
);
MIGRAPHX_THROW
(
"ERROR: Matched division by zero in pass"
);
}
}
};
};
...
...
test/simplify_algebra_test.cpp
View file @
41e3b9f6
...
@@ -906,7 +906,7 @@ TEST_CASE(simplify_div_zero_const)
...
@@ -906,7 +906,7 @@ TEST_CASE(simplify_div_zero_const)
}
}
catch
(
const
std
::
runtime_error
&
e
)
catch
(
const
std
::
runtime_error
&
e
)
{
{
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
(
void
)
e
;
result
=
true
;
result
=
true
;
}
}
EXPECT
(
result
);
EXPECT
(
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment