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
11acd6be
Commit
11acd6be
authored
Mar 27, 2019
by
Khalique
Browse files
formatting
parent
b3de1cfa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
src/pad_rewrite.cpp
src/pad_rewrite.cpp
+4
-1
test/pad_rewrite_test.cpp
test/pad_rewrite_test.cpp
+15
-15
No files found.
src/pad_rewrite.cpp
View file @
11acd6be
...
@@ -28,7 +28,10 @@ void pad_rewrite::apply(program& p) const
...
@@ -28,7 +28,10 @@ void pad_rewrite::apply(program& p) const
}
}
template
<
class
T
>
template
<
class
T
>
void
pad_rewrite
::
update_op
(
T
,
const
instruction_ref
&
input
,
const
instruction_ref
&
ins
,
program
&
p
)
const
void
pad_rewrite
::
update_op
(
T
,
const
instruction_ref
&
input
,
const
instruction_ref
&
ins
,
program
&
p
)
const
{
{
auto
pad_op
=
any_cast
<
op
::
pad
>
(
input
->
get_operator
());
auto
pad_op
=
any_cast
<
op
::
pad
>
(
input
->
get_operator
());
if
(
!
pad_op
.
symmetric
())
if
(
!
pad_op
.
symmetric
())
...
...
test/pad_rewrite_test.cpp
View file @
11acd6be
...
@@ -15,7 +15,8 @@ struct pad_rewrite_target
...
@@ -15,7 +15,8 @@ struct pad_rewrite_target
migraphx
::
context
get_context
()
const
{
return
{};
}
migraphx
::
context
get_context
()
const
{
return
{};
}
};
};
migraphx
::
instruction_ref
create_im2col
(
migraphx
::
instruction_ref
&
l_img
,
size_t
channels
,
migraphx
::
program
&
p
)
migraphx
::
instruction_ref
create_im2col
(
migraphx
::
instruction_ref
&
l_img
,
size_t
channels
,
migraphx
::
program
&
p
)
{
{
size_t
f
[
2
]
=
{
1
,
1
};
size_t
f
[
2
]
=
{
1
,
1
};
std
::
vector
<
int32_t
>
weights
(
channels
*
f
[
0
]
*
f
[
1
]);
std
::
vector
<
int32_t
>
weights
(
channels
*
f
[
0
]
*
f
[
1
]);
...
@@ -25,7 +26,8 @@ migraphx::instruction_ref create_im2col(migraphx::instruction_ref& l_img, size_t
...
@@ -25,7 +26,8 @@ migraphx::instruction_ref create_im2col(migraphx::instruction_ref& l_img, size_t
return
p
.
add_instruction
(
migraphx
::
op
::
im2col
{},
l_img
,
l_weights
);
return
p
.
add_instruction
(
migraphx
::
op
::
im2col
{},
l_img
,
l_weights
);
}
}
migraphx
::
instruction_ref
create_conv
(
migraphx
::
instruction_ref
&
l_img
,
size_t
channels
,
migraphx
::
program
&
p
)
migraphx
::
instruction_ref
create_conv
(
migraphx
::
instruction_ref
&
l_img
,
size_t
channels
,
migraphx
::
program
&
p
)
{
{
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
...
@@ -45,7 +47,7 @@ TEST_CASE(rewrite_test)
...
@@ -45,7 +47,7 @@ TEST_CASE(rewrite_test)
migraphx
::
shape
s_img
{
migraphx
::
shape
::
int32_type
,
{
1
,
channels
,
img_dim
[
0
],
img_dim
[
1
]}};
migraphx
::
shape
s_img
{
migraphx
::
shape
::
int32_type
,
{
1
,
channels
,
img_dim
[
0
],
img_dim
[
1
]}};
auto
l_img
=
p
.
add_literal
(
migraphx
::
literal
{
s_img
,
input
});
auto
l_img
=
p
.
add_literal
(
migraphx
::
literal
{
s_img
,
input
});
auto
padded_img
=
p
.
add_instruction
(
migraphx
::
op
::
pad
{{
0
,
0
,
1
,
1
,
0
,
0
,
1
,
1
}},
l_img
);
auto
padded_img
=
p
.
add_instruction
(
migraphx
::
op
::
pad
{{
0
,
0
,
1
,
1
,
0
,
0
,
1
,
1
}},
l_img
);
auto
l0
=
create_im2col
(
padded_img
,
channels
,
p
);
auto
l0
=
create_im2col
(
padded_img
,
channels
,
p
);
auto
l1
=
create_conv
(
padded_img
,
channels
,
p
);
auto
l1
=
create_conv
(
padded_img
,
channels
,
p
);
...
@@ -53,9 +55,8 @@ TEST_CASE(rewrite_test)
...
@@ -53,9 +55,8 @@ TEST_CASE(rewrite_test)
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
l0
,
l1
,
l2
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
l0
,
l1
,
l2
);
p
.
compile
(
pad_rewrite_target
{});
p
.
compile
(
pad_rewrite_target
{});
EXPECT
(
std
::
none_of
(
p
.
begin
(),
p
.
end
(),
[](
const
migraphx
::
instruction
&
ins
)
{
EXPECT
(
std
::
none_of
(
return
ins
.
name
()
==
"pad"
;
p
.
begin
(),
p
.
end
(),
[](
const
migraphx
::
instruction
&
ins
)
{
return
ins
.
name
()
==
"pad"
;
}));
}));
}
}
TEST_CASE
(
rewrite_test_asymmetric
)
TEST_CASE
(
rewrite_test_asymmetric
)
...
@@ -68,14 +69,13 @@ TEST_CASE(rewrite_test_asymmetric)
...
@@ -68,14 +69,13 @@ TEST_CASE(rewrite_test_asymmetric)
migraphx
::
shape
s_img
{
migraphx
::
shape
::
int32_type
,
{
1
,
channels
,
img_dim
[
0
],
img_dim
[
1
]}};
migraphx
::
shape
s_img
{
migraphx
::
shape
::
int32_type
,
{
1
,
channels
,
img_dim
[
0
],
img_dim
[
1
]}};
auto
l_img
=
p
.
add_literal
(
migraphx
::
literal
{
s_img
,
input
});
auto
l_img
=
p
.
add_literal
(
migraphx
::
literal
{
s_img
,
input
});
auto
padded_img
=
p
.
add_instruction
(
migraphx
::
op
::
pad
{{
0
,
0
,
0
,
0
,
0
,
0
,
2
,
2
}},
l_img
);
auto
padded_img
=
p
.
add_instruction
(
migraphx
::
op
::
pad
{{
0
,
0
,
0
,
0
,
0
,
0
,
2
,
2
}},
l_img
);
create_im2col
(
padded_img
,
channels
,
p
);
create_im2col
(
padded_img
,
channels
,
p
);
p
.
compile
(
pad_rewrite_target
{});
p
.
compile
(
pad_rewrite_target
{});
EXPECT
(
std
::
any_of
(
p
.
begin
(),
p
.
end
(),
[](
const
migraphx
::
instruction
&
ins
)
{
EXPECT
(
std
::
any_of
(
return
ins
.
name
()
==
"pad"
;
p
.
begin
(),
p
.
end
(),
[](
const
migraphx
::
instruction
&
ins
)
{
return
ins
.
name
()
==
"pad"
;
}));
}));
}
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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