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
2863aa3e
Commit
2863aa3e
authored
Aug 12, 2021
by
Paul
Browse files
Formatting
parent
632f819e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
src/layout_nhwc.cpp
src/layout_nhwc.cpp
+8
-9
No files found.
src/layout_nhwc.cpp
100755 → 100644
View file @
2863aa3e
...
...
@@ -12,17 +12,17 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
template
<
class
Predicate
>
template
<
class
Predicate
>
std
::
vector
<
instruction_ref
>
find_lasts
(
const
module
&
m
,
Predicate
pred
)
{
std
::
vector
<
instruction_ref
>
result
;
fix
([
&
](
auto
self
,
auto
ins
)
{
if
(
pred
(
ins
))
if
(
pred
(
ins
))
{
result
.
push_back
(
ins
);
return
;
}
for
(
auto
input
:
ins
->
inputs
())
for
(
auto
input
:
ins
->
inputs
())
self
(
input
);
})(
std
::
prev
(
m
.
end
()));
return
result
;
...
...
@@ -30,18 +30,17 @@ std::vector<instruction_ref> find_lasts(const module& m, Predicate pred)
void
preserve_output_layout
(
module
&
m
)
{
std
::
vector
<
instruction_ref
>
outputs
=
find_lasts
(
m
,
[](
auto
ins
)
{
return
ins
->
get_shape
().
lens
().
size
()
==
4
;
});
for
(
auto
output
:
outputs
)
std
::
vector
<
instruction_ref
>
outputs
=
find_lasts
(
m
,
[](
auto
ins
)
{
return
ins
->
get_shape
().
lens
().
size
()
==
4
;
});
for
(
auto
output
:
outputs
)
{
auto
permutation
=
find_permutation
(
output
->
get_shape
());
auto
layout
=
m
.
insert_instruction
(
std
::
next
(
output
),
make_op
(
"layout"
,
{{
"permutation"
,
permutation
}}),
output
);
auto
layout
=
m
.
insert_instruction
(
std
::
next
(
output
),
make_op
(
"layout"
,
{{
"permutation"
,
permutation
}}),
output
);
m
.
replace_instruction
(
output
,
layout
);
}
}
void
transform_convolutions
(
module
&
m
)
{
for
(
auto
ins
:
iterator_for
(
m
))
...
...
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