Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
e2db5e20
Commit
e2db5e20
authored
Oct 04, 2018
by
Paul
Browse files
Use matchers for fusion
parent
17129c88
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/targets/gpu/fuse_ops.cpp
src/targets/gpu/fuse_ops.cpp
+13
-9
No files found.
src/targets/gpu/fuse_ops.cpp
View file @
e2db5e20
#include <migraph/gpu/fuse_ops.hpp>
#include <migraph/
iterator_fo
r.hpp>
#include <migraph/
matche
r.hpp>
#include <migraph/gpu/device/add_relu.hpp>
#include <migraph/instruction.hpp>
...
...
@@ -22,20 +22,24 @@ struct hip_add_relu
}
};
void
fuse_ops
::
apply
(
program
&
p
)
const
struct
match_add_relu
{
for
(
auto
ins
:
iterator_for
(
p
))
auto
matcher
()
const
{
return
match
::
name
(
"gpu::relu"
)(
match
::
args
(
match
::
name
(
"gpu::add"
).
bind
(
"add"
)));
}
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
{
if
(
ins
->
name
()
!=
"gpu::relu"
)
continue
;
auto
add_ins
=
ins
->
inputs
().
front
();
if
(
add_ins
->
name
()
!=
"gpu::add"
)
continue
;
auto
add_ins
=
r
.
instructions
[
"add"
];
auto
ins
=
r
.
result
;
auto
args
=
add_ins
->
inputs
();
// Use the allocation from the relu operator
args
.
back
()
=
ins
->
inputs
().
back
();
p
.
replace_instruction
(
ins
,
hip_add_relu
{},
args
);
}
};
void
fuse_ops
::
apply
(
program
&
p
)
const
{
match
::
find_matches
(
p
,
match_add_relu
{});
}
}
// namespace gpu
...
...
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