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
c3ac2363
Commit
c3ac2363
authored
Sep 11, 2022
by
Paul
Browse files
Rewrite div+sqrt
parent
d78bcdfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+19
-0
No files found.
src/simplify_algebra.cpp
View file @
c3ac2363
...
...
@@ -931,6 +931,24 @@ struct find_rsqrt
}
};
struct
find_div_sqrt
{
auto
matcher
()
const
{
auto
msqrt
=
match
::
skip_broadcasts
(
match
::
name
(
"sqrt"
)(
match
::
used_once
()).
bind
(
"sqrt"
));
return
match
::
name
(
"div"
)(
match
::
args
(
match
::
any
(),
msqrt
(
match
::
used_once
())));
}
void
apply
(
module
&
m
,
const
match
::
matcher_result
&
r
)
const
{
auto
ins
=
r
.
result
;
auto
sqrt_ins
=
r
.
instructions
[
"sqrt"
];
m
.
replace_instruction
(
sqrt_ins
,
make_op
(
"rsqrt"
),
sqrt_ins
->
inputs
());
m
.
replace_instruction
(
ins
,
make_op
(
"mul"
),
ins
->
inputs
());
}
};
static
bool
same_ops
(
const
std
::
vector
<
instruction_ref
>&
vec_ins
)
{
return
std
::
all_of
(
vec_ins
.
begin
(),
vec_ins
.
end
(),
[
&
](
auto
i
)
{
...
...
@@ -1099,6 +1117,7 @@ void simplify_algebra::apply(module& m) const
find_div_const
{},
find_sub_const
{},
find_rsqrt
{},
find_div_sqrt
{},
find_concat_op
{},
find_split_concat
{},
find_splits
{},
...
...
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