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
05e60c54
"src/include/gridwise_implicit_gemm_convolution.cuh" did not exist on "059711633041b73ac3ed3c3b287eee8667092f3f"
Commit
05e60c54
authored
Aug 09, 2021
by
Paul
Browse files
Add nhwc pass
parent
a4f8d30b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
0 deletions
+68
-0
src/CMakeLists.txt
src/CMakeLists.txt
+1
-0
src/include/migraphx/layout_nhwc.hpp
src/include/migraphx/layout_nhwc.hpp
+24
-0
src/layout_nhwc.cpp
src/layout_nhwc.cpp
+39
-0
src/simplify_reshapes.cpp
src/simplify_reshapes.cpp
+1
-0
src/targets/cpu/target.cpp
src/targets/cpu/target.cpp
+3
-0
No files found.
src/CMakeLists.txt
View file @
05e60c54
...
@@ -31,6 +31,7 @@ add_library(migraphx
...
@@ -31,6 +31,7 @@ add_library(migraphx
insert_pad.cpp
insert_pad.cpp
instruction.cpp
instruction.cpp
json.cpp
json.cpp
layout_nhwc.cpp
load_save.cpp
load_save.cpp
make_op.cpp
make_op.cpp
module.cpp
module.cpp
...
...
src/include/migraphx/layout_nhwc.hpp
0 → 100755
View file @
05e60c54
#ifndef MIGRAPHX_GUARD_MIGRAPHX_LAYOUT_NHWC_HPP
#define MIGRAPHX_GUARD_MIGRAPHX_LAYOUT_NHWC_HPP
#include <string>
#include <migraphx/instruction_ref.hpp>
#include <migraphx/config.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
module
;
/**
* Transform convolutions to nhwc
*/
struct
layout_nhwc
{
std
::
string
name
()
const
{
return
"layout_nhwc"
;
}
void
apply
(
module
&
m
)
const
;
};
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif // MIGRAPHX_GUARD_MIGRAPHX_LAYOUT_NHWC_HPP
src/layout_nhwc.cpp
0 → 100755
View file @
05e60c54
#include <migraphx/layout_nhwc.hpp>
#include <migraphx/module.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/dead_code_elimination.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
void
transform_convolutions
(
module
&
m
)
{
for
(
auto
ins
:
iterator_for
(
m
))
{
if
(
ins
->
name
()
!=
"convolution"
)
continue
;
if
(
ins
->
get_shape
().
lens
().
size
()
!=
4
)
continue
;
auto
args
=
ins
->
inputs
();
std
::
transform
(
args
.
begin
(),
args
.
end
(),
args
.
begin
(),
[
&
](
auto
&
i
)
{
return
m
.
insert_instruction
(
ins
,
make_op
(
"layout"
,
{{
"permutation"
,
{
0
,
2
,
3
,
1
}}}),
i
);
});
auto
conv
=
m
.
insert_instruction
(
ins
,
ins
->
get_operator
(),
args
);
auto
c
=
m
.
insert_instruction
(
ins
,
make_op
(
"contiguous"
),
conv
);
m
.
replace_instruction
(
ins
,
c
);
}
}
void
layout_nhwc
::
apply
(
module
&
m
)
const
{
transform_convolutions
(
m
);
dead_code_elimination
{}.
apply
(
m
);
eliminate_contiguous
{
"contiguous"
}.
apply
(
m
);
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/simplify_reshapes.cpp
View file @
05e60c54
...
@@ -110,6 +110,7 @@ struct find_nop_reshapes
...
@@ -110,6 +110,7 @@ struct find_nop_reshapes
reshapes
.
insert
(
"broadcast"
);
reshapes
.
insert
(
"broadcast"
);
reshapes
.
insert
(
"concat"
);
reshapes
.
insert
(
"concat"
);
reshapes
.
insert
(
"convert"
);
reshapes
.
insert
(
"convert"
);
reshapes
.
insert
(
"layout"
);
reshapes
.
insert
(
"multibroadcast"
);
reshapes
.
insert
(
"multibroadcast"
);
reshapes
.
insert
(
"pad"
);
reshapes
.
insert
(
"pad"
);
reshapes
.
insert
(
"slice"
);
reshapes
.
insert
(
"slice"
);
...
...
src/targets/cpu/target.cpp
View file @
05e60c54
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <migraphx/eliminate_data_type.hpp>
#include <migraphx/eliminate_data_type.hpp>
#include <migraphx/eliminate_identity.hpp>
#include <migraphx/eliminate_identity.hpp>
#include <migraphx/eliminate_pad.hpp>
#include <migraphx/eliminate_pad.hpp>
#include <migraphx/layout_nhwc.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/register_target.hpp>
...
@@ -65,6 +66,8 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
...
@@ -65,6 +66,8 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
dead_code_elimination
{},
dead_code_elimination
{},
simplify_algebra
{},
simplify_algebra
{},
simplify_reshapes
{},
simplify_reshapes
{},
layout_nhwc
{},
simplify_reshapes
{},
simplify_algebra
{},
simplify_algebra
{},
auto_contiguous
{},
auto_contiguous
{},
simplify_reshapes
{},
simplify_reshapes
{},
...
...
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