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
db4df30b
Commit
db4df30b
authored
Jun 25, 2019
by
Khalique
Browse files
formatting
parent
68d5b22b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
src/tf/tf.cpp
src/tf/tf.cpp
+11
-8
test/tf/tf_test.cpp
test/tf/tf_test.cpp
+4
-4
No files found.
src/tf/tf.cpp
View file @
db4df30b
...
...
@@ -37,7 +37,8 @@ struct tf_parser
std
::
unordered_map
<
std
::
string
,
op_func
>
ops
;
std
::
vector
<
size_t
>
parse_axes
(
const
attribute_map
&
attributes
,
const
std
::
string
&
s
,
const
size_t
&
num_dims
)
const
std
::
vector
<
size_t
>
parse_axes
(
const
attribute_map
&
attributes
,
const
std
::
string
&
s
,
const
size_t
&
num_dims
)
const
{
auto
attrs
=
attributes
.
at
(
s
).
list
().
i
();
std
::
vector
<
size_t
>
axes
;
...
...
@@ -252,7 +253,8 @@ struct tf_parser
{
// get index for axis within args
size_t
axis_idx
=
attributes
.
at
(
"N"
).
i
();
size_t
axis
=
parse_axis
(
args
[
axis_idx
]
->
eval
().
at
<
int64_t
>
(),
args
[
0
]
->
get_shape
().
lens
().
size
());
size_t
axis
=
parse_axis
(
args
[
axis_idx
]
->
eval
().
at
<
int64_t
>
(),
args
[
0
]
->
get_shape
().
lens
().
size
());
op
::
concat
op
{
axis
};
// return only first N arguments (assuming last index is the axis value)
return
prog
.
add_instruction
(
...
...
@@ -471,14 +473,15 @@ struct tf_parser
return
prog
.
add_instruction
(
op
,
{
l0
,
new_weights
});
}
instruction_ref
parse_expanddims
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
instruction_ref
parse_expanddims
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
std
::
vector
<
size_t
>
input_dims
=
args
[
0
]
->
get_shape
().
lens
();
std
::
vector
<
int64_t
>
new_dims
(
input_dims
.
begin
(),
input_dims
.
end
());
std
::
vector
<
int64_t
>
new_dims
(
input_dims
.
begin
(),
input_dims
.
end
());
size_t
num_dims
=
input_dims
.
size
();
int32_t
dim
=
parse_axis
(
args
[
1
]
->
eval
().
at
<
int32_t
>
(),
num_dims
);
if
(
dim
<
0
)
int32_t
dim
=
parse_axis
(
args
[
1
]
->
eval
().
at
<
int32_t
>
(),
num_dims
);
if
(
dim
<
0
)
{
new_dims
.
insert
(
new_dims
.
begin
()
+
(
num_dims
+
dim
+
1
),
1
);
}
...
...
@@ -696,7 +699,7 @@ struct tf_parser
{
op
::
squeeze
op
;
auto
input_dims
=
args
[
0
]
->
get_shape
().
lens
();
auto
axes
=
parse_axes
(
attributes
,
"squeeze_dims"
,
input_dims
.
size
());
auto
axes
=
parse_axes
(
attributes
,
"squeeze_dims"
,
input_dims
.
size
());
copy
(
axes
,
std
::
back_inserter
(
op
.
axes
));
if
(
op
.
axes
.
empty
())
// no squeeze_dims provided, remove any dim that equals 1
...
...
test/tf/tf_test.cpp
View file @
db4df30b
...
...
@@ -149,12 +149,12 @@ TEST_CASE(depthwiseconv_test)
TEST_CASE
(
expanddims_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}});
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}});
p
.
add_literal
(
-
1
);
p
.
add_literal
(
0
);
p
.
add_instruction
(
migraphx
::
op
::
reshape
{{
2
,
3
,
4
,
1
}},
l0
);
p
.
add_instruction
(
migraphx
::
op
::
reshape
{{
1
,
2
,
3
,
4
}},
l0
);
p
.
add_instruction
(
migraphx
::
op
::
reshape
{{
2
,
3
,
4
,
1
}},
l0
);
p
.
add_instruction
(
migraphx
::
op
::
reshape
{{
1
,
2
,
3
,
4
}},
l0
);
auto
prog
=
migraphx
::
parse_tf
(
"expanddims_test.pb"
,
true
);
EXPECT
(
p
==
prog
);
...
...
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