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
21bb2293
Commit
21bb2293
authored
Jul 18, 2019
by
Khalique
Browse files
change to use gather
parent
b9e0e0fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
src/tf/tf.cpp
src/tf/tf.cpp
+14
-12
No files found.
src/tf/tf.cpp
View file @
21bb2293
...
...
@@ -567,25 +567,27 @@ struct tf_parser
instruction_ref
parse_onehot
(
const
std
::
string
&
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
auto
indices
=
args
[
0
]
->
eval
().
get
<
int32_t
>
().
to_vector
();
int
depth
=
args
[
1
]
->
eval
().
at
<
int32_t
>
();
// auto indices = args[0]->eval().get<int32_t>().to_vector();
size_t
depth
=
static_cast
<
size_t
>
(
args
[
1
]
->
eval
().
at
<
int32_t
>
());
int64_t
axis
=
-
1
;
size_t
num_indices
=
indices
.
size
();
//
size_t num_indices = indices.size();
float
on_value
=
args
[
2
]
->
eval
().
at
<
float
>
();
float
off_value
=
args
[
3
]
->
eval
().
at
<
float
>
();
std
::
vector
<
float
>
depth_input
(
depth
*
depth
,
off_value
);
for
(
int
i
=
0
;
i
<
depth
;
i
++
)
{
depth_input
[
depth
*
i
+
i
]
=
on_value
;
}
if
(
contains
(
attributes
,
"axis"
))
axis
=
attributes
.
at
(
"axis"
).
i
();
if
(
axis
==
-
1
)
{
shape
s
{
shape
::
float_type
,
{
num_indices
,
static_cast
<
size_t
>
(
depth
)}};
std
::
vector
<
float
>
output
(
num_indices
*
depth
);
std
::
fill
(
output
.
begin
(),
output
.
end
(),
off_value
);
for
(
size_t
i
=
0
;
i
<
num_indices
;
i
++
)
{
if
(
indices
[
i
]
>=
0
and
indices
[
i
]
<
depth
)
output
.
at
(
depth
*
i
+
indices
[
i
])
=
on_value
;
}
return
prog
.
add_literal
(
s
,
output
);
shape
s
{
shape
::
float_type
,
{
depth
,
depth
}};
auto
l0
=
prog
.
add_literal
({
s
,
depth_input
});
return
prog
.
add_instruction
(
op
::
gather
{
0
},
{
l0
,
args
[
0
]});
}
MIGRAPHX_THROW
(
"MIGraphX does not support axis != -1"
);
}
...
...
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