Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
af00eea8
Unverified
Commit
af00eea8
authored
Apr 08, 2019
by
mvermeulen
Committed by
GitHub
Apr 08, 2019
Browse files
Merge pull request #223 from ROCmSoftwarePlatform/pack_op
Pack op
parents
4a3e493c
e737201f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
0 deletions
+59
-0
src/tf/tf.cpp
src/tf/tf.cpp
+18
-0
test/tf/pack_test.pb
test/tf/pack_test.pb
+19
-0
test/tf/tf_test.cpp
test/tf/tf_test.cpp
+22
-0
No files found.
src/tf/tf.cpp
View file @
af00eea8
...
@@ -119,6 +119,7 @@ struct tf_parser
...
@@ -119,6 +119,7 @@ struct tf_parser
add_mem_op
(
"FusedBatchNorm"
,
&
tf_parser
::
parse_batchnorm
);
add_mem_op
(
"FusedBatchNorm"
,
&
tf_parser
::
parse_batchnorm
);
add_mem_op
(
"MaxPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"MaxPool"
,
&
tf_parser
::
parse_pooling
);
add_mem_op
(
"Mean"
,
&
tf_parser
::
parse_mean
);
add_mem_op
(
"Mean"
,
&
tf_parser
::
parse_mean
);
add_mem_op
(
"Pack"
,
&
tf_parser
::
parse_pack
);
add_mem_op
(
"Pad"
,
&
tf_parser
::
parse_pad
);
add_mem_op
(
"Pad"
,
&
tf_parser
::
parse_pad
);
add_mem_op
(
"Reshape"
,
&
tf_parser
::
parse_reshape
);
add_mem_op
(
"Reshape"
,
&
tf_parser
::
parse_reshape
);
add_mem_op
(
"Softmax"
,
&
tf_parser
::
parse_softmax
);
add_mem_op
(
"Softmax"
,
&
tf_parser
::
parse_softmax
);
...
@@ -353,6 +354,23 @@ struct tf_parser
...
@@ -353,6 +354,23 @@ struct tf_parser
MIGRAPHX_THROW
(
"MIGraphX does not support mean outside of GlobalAvgPool transformation"
);
MIGRAPHX_THROW
(
"MIGraphX does not support mean outside of GlobalAvgPool transformation"
);
}
}
instruction_ref
parse_pack
(
const
std
::
string
&
,
const
attribute_map
&
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
// reinterpret as unsqueeze with concat
std
::
vector
<
instruction_ref
>
unsqueezed_args
;
int64_t
axis
=
0
;
if
(
contains
(
attributes
,
"axis"
))
axis
=
attributes
.
at
(
"axis"
).
i
();
std
::
transform
(
args
.
begin
(),
args
.
end
(),
std
::
back_inserter
(
unsqueezed_args
),
[
&
](
instruction_ref
arg
)
{
return
prog
.
add_instruction
(
op
::
unsqueeze
{{
axis
}},
arg
);
});
return
prog
.
add_instruction
(
op
::
concat
{
static_cast
<
size_t
>
(
axis
)},
unsqueezed_args
);
}
instruction_ref
instruction_ref
parse_pad
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_pad
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
...
...
test/tf/pack_test.pb
0 → 100644
View file @
af00eea8
.
0Placeholder*
shape:*
dtype0
.
1Placeholder*
dtype0*
shape:
.
2Placeholder*
dtype0*
shape:
4
pack1Pack012*
T0*
axis*
N"
\ No newline at end of file
test/tf/tf_test.cpp
View file @
af00eea8
...
@@ -129,6 +129,28 @@ TEST_CASE(identity_test)
...
@@ -129,6 +129,28 @@ TEST_CASE(identity_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
pack_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
}});
auto
l2
=
p
.
add_parameter
(
"2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
}});
std
::
vector
<
migraphx
::
instruction_ref
>
args
{
l0
,
l1
,
l2
};
std
::
vector
<
migraphx
::
instruction_ref
>
unsqueezed_args
;
int64_t
axis
=
1
;
std
::
transform
(
args
.
begin
(),
args
.
end
(),
std
::
back_inserter
(
unsqueezed_args
),
[
&
](
migraphx
::
instruction_ref
arg
)
{
return
p
.
add_instruction
(
migraphx
::
op
::
unsqueeze
{{
axis
}},
arg
);
});
p
.
add_instruction
(
migraphx
::
op
::
concat
{
static_cast
<
size_t
>
(
axis
)},
unsqueezed_args
);
auto
prog
=
migraphx
::
parse_tf
(
"pack_test.pb"
,
false
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
pooling_test
)
TEST_CASE
(
pooling_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