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
5f52c066
Commit
5f52c066
authored
May 02, 2019
by
Khalique
Browse files
add test case for depthwise_conv
parent
e4f95696
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
src/tf/tf.cpp
src/tf/tf.cpp
+5
-1
test/tf/depthwise_conv_test.pb
test/tf/depthwise_conv_test.pb
+0
-0
test/tf/tf_test.cpp
test/tf/tf_test.cpp
+24
-0
No files found.
src/tf/tf.cpp
View file @
5f52c066
...
@@ -369,7 +369,6 @@ struct tf_parser
...
@@ -369,7 +369,6 @@ struct tf_parser
}
}
auto
weights
=
args
[
1
];
auto
weights
=
args
[
1
];
// check if weights are from a constant
// check if weights are from a constant
if
(
weights
->
name
()
!=
"@param"
)
if
(
weights
->
name
()
!=
"@param"
)
{
{
if
(
is_nhwc
)
if
(
is_nhwc
)
...
@@ -381,8 +380,13 @@ struct tf_parser
...
@@ -381,8 +380,13 @@ struct tf_parser
weights
=
prog
.
add_instruction
(
op
::
transpose
{{
3
,
2
,
0
,
1
}},
args
[
1
]);
weights
=
prog
.
add_instruction
(
op
::
transpose
{{
3
,
2
,
0
,
1
}},
args
[
1
]);
}
}
}
}
std
::
vector
<
int64_t
>
new_weights_shape
;
std
::
vector
<
int64_t
>
new_weights_shape
;
copy
(
weights
->
get_shape
().
lens
(),
std
::
back_inserter
(
new_weights_shape
));
copy
(
weights
->
get_shape
().
lens
(),
std
::
back_inserter
(
new_weights_shape
));
// weight format is (out_channels, in_channels, h, w), but in depthwise_conv,
// out_channels is equal to the multiplier. Adjust by inserting a reshape and
// setting in_channels to 1
int64_t
multiplier
=
new_weights_shape
[
0
];
int64_t
multiplier
=
new_weights_shape
[
0
];
int64_t
out_channels
=
num_channels
*
multiplier
;
int64_t
out_channels
=
num_channels
*
multiplier
;
new_weights_shape
[
0
]
=
out_channels
;
new_weights_shape
[
0
]
=
out_channels
;
...
...
test/tf/depthwise_conv_test.pb
0 → 100644
View file @
5f52c066
File added
test/tf/tf_test.cpp
View file @
5f52c066
...
@@ -119,6 +119,30 @@ TEST_CASE(conv_test)
...
@@ -119,6 +119,30 @@ TEST_CASE(conv_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
depthwiseconv_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
std
::
vector
<
float
>
weight_data
(
3
*
3
*
3
*
1
);
std
::
fill
(
weight_data
.
begin
(),
weight_data
.
end
(),
1.0
f
);
auto
l1
=
p
.
add_literal
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
3
,
3
,
1
}},
weight_data
);
migraphx
::
op
::
convolution
op
;
op
.
padding_mode
=
migraphx
::
op
::
padding_mode_t
::
same
;
op
.
stride
=
{
1
,
1
};
op
.
dilation
=
{
1
,
1
};
op
.
group
=
3
;
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
3
,
1
,
2
}},
l1
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
1
,
3
,
0
,
2
}},
l2
);
auto
l4
=
p
.
add_instruction
(
migraphx
::
op
::
reshape
{{
3
,
1
,
3
,
3
}},
l3
);
p
.
add_instruction
(
op
,
l0
,
l4
);
auto
prog
=
migraphx
::
parse_tf
(
"depthwise_conv_test.pb"
,
true
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
identity_test
)
TEST_CASE
(
identity_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
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