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
e4441183
Commit
e4441183
authored
Aug 24, 2018
by
Paul
Browse files
Add a pass to fuse add and relu
parent
6f96cf7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+1
-0
src/targets/gpu/fuse_ops.cpp
src/targets/gpu/fuse_ops.cpp
+41
-0
src/targets/gpu/include/migraph/gpu/fuse_ops.hpp
src/targets/gpu/include/migraph/gpu/fuse_ops.hpp
+21
-0
src/targets/gpu/target.cpp
src/targets/gpu/target.cpp
+3
-0
No files found.
src/targets/gpu/CMakeLists.txt
View file @
e4441183
...
@@ -22,6 +22,7 @@ target_include_directories(migraph_device PRIVATE $<BUILD_INTERFACE:${CMAKE_CURR
...
@@ -22,6 +22,7 @@ target_include_directories(migraph_device PRIVATE $<BUILD_INTERFACE:${CMAKE_CURR
add_library
(
migraph_gpu
add_library
(
migraph_gpu
eliminate_allocation.cpp
eliminate_allocation.cpp
eliminate_workspace.cpp
eliminate_workspace.cpp
fuse_ops.cpp
hip.cpp
hip.cpp
target.cpp
target.cpp
lowering.cpp
lowering.cpp
...
...
src/targets/gpu/fuse_ops.cpp
0 → 100644
View file @
e4441183
#include <migraph/gpu/fuse_ops.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/gpu/device/add_relu.hpp>
#include <migraph/instruction.hpp>
namespace
migraph
{
namespace
gpu
{
struct
hip_add_relu
{
std
::
string
name
()
const
{
return
"hip::add_relu"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
}.
has
(
3
).
standard
();
return
inputs
.
front
();
}
argument
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
{
device
::
add_relu
(
args
.
at
(
0
),
args
.
at
(
1
),
args
.
at
(
2
));
return
args
.
at
(
2
);
}
};
void
fuse_ops
::
apply
(
program
&
p
)
const
{
assert
(
ctx
!=
nullptr
);
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
!=
"gpu::relu"
)
continue
;
auto
add_ins
=
ins
->
arguments
.
front
();
if
(
add_ins
->
op
.
name
()
!=
"gpu::add"
)
continue
;
p
.
replace_instruction
(
ins
,
hip_add_relu
{},
add_ins
->
arguments
);
}
}
}
// namespace gpu
}
// namespace migraph
src/targets/gpu/include/migraph/gpu/fuse_ops.hpp
0 → 100644
View file @
e4441183
#ifndef MIGRAPH_GUARD_RTGLIB_FUSE_OPS_HPP
#define MIGRAPH_GUARD_RTGLIB_FUSE_OPS_HPP
#include <migraph/program.hpp>
#include <migraph/gpu/context.hpp>
namespace
migraph
{
namespace
gpu
{
struct
fuse_ops
{
std
::
string
name
()
const
{
return
"gpu::fuse_ops"
;
}
void
apply
(
program
&
p
)
const
;
};
}
// namespace gpu
}
// namespace migraph
#endif
src/targets/gpu/target.cpp
View file @
e4441183
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <migraph/gpu/context.hpp>
#include <migraph/gpu/context.hpp>
#include <migraph/gpu/eliminate_workspace.hpp>
#include <migraph/gpu/eliminate_workspace.hpp>
#include <migraph/gpu/eliminate_allocation.hpp>
#include <migraph/gpu/eliminate_allocation.hpp>
#include <migraph/gpu/fuse_ops.hpp>
#include <migraph/check_context.hpp>
#include <migraph/check_context.hpp>
#include <migraph/auto_contiguous.hpp>
#include <migraph/auto_contiguous.hpp>
#include <migraph/dead_code_elimination.hpp>
#include <migraph/dead_code_elimination.hpp>
...
@@ -24,6 +25,8 @@ std::vector<pass> target::get_passes(migraph::context& gctx) const
...
@@ -24,6 +25,8 @@ std::vector<pass> target::get_passes(migraph::context& gctx) const
simplify_reshapes
{},
simplify_reshapes
{},
dead_code_elimination
{},
dead_code_elimination
{},
lowering
{
ctx
},
lowering
{
ctx
},
fuse_ops
{},
dead_code_elimination
{},
eliminate_workspace
{},
eliminate_workspace
{},
eliminate_contiguous
{},
eliminate_contiguous
{},
dead_code_elimination
{},
dead_code_elimination
{},
...
...
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