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
834255a3
Commit
834255a3
authored
Feb 24, 2019
by
Shucai Xiao
Browse files
clang format
parent
26ce057d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+9
-7
No files found.
src/include/migraphx/operators.hpp
View file @
834255a3
...
@@ -779,25 +779,27 @@ struct gather
...
@@ -779,25 +779,27 @@ struct gather
argument
result
{
output_shape
};
argument
result
{
output_shape
};
// negative axis means counting dimensions from back
// negative axis means counting dimensions from back
auto
data_shape
=
args
[
0
].
get_shape
();
auto
data_shape
=
args
[
0
].
get_shape
();
int
axis_index
=
(
axis
<
0
)
?
(
data_shape
.
lens
().
size
()
+
axis
)
:
axis
;
int
axis_index
=
(
axis
<
0
)
?
(
data_shape
.
lens
().
size
()
+
axis
)
:
axis
;
// max dimension in axis
// max dimension in axis
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
data
)
{
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
data
)
{
std
::
vector
<
std
::
size_t
>
vec_indices
;
std
::
vector
<
std
::
size_t
>
vec_indices
;
args
[
1
].
visit
([
&
](
auto
indices
)
{
vec_indices
.
assign
(
indices
.
begin
(),
indices
.
end
());
});
args
[
1
].
visit
(
if
(
output_shape
.
scalar
())
[
&
](
auto
indices
)
{
vec_indices
.
assign
(
indices
.
begin
(),
indices
.
end
());
});
if
(
output_shape
.
scalar
())
{
{
output
[
0
]
=
data
[
vec_indices
.
front
()];
output
[
0
]
=
data
[
vec_indices
.
front
()];
}
}
else
else
{
{
auto
out_lens
=
data_shape
.
lens
();
auto
out_lens
=
data_shape
.
lens
();
out_lens
[
axis_index
]
=
vec_indices
.
size
();
out_lens
[
axis_index
]
=
vec_indices
.
size
();
migraphx
::
shape
out_comp_shape
{
output_shape
.
type
(),
out_lens
};
migraphx
::
shape
out_comp_shape
{
output_shape
.
type
(),
out_lens
};
shape_for_each
(
out_comp_shape
,
[
&
](
const
auto
&
out_idx
)
{
shape_for_each
(
out_comp_shape
,
[
&
](
const
auto
&
out_idx
)
{
auto
data_idx
=
out_idx
;
auto
data_idx
=
out_idx
;
data_idx
[
axis_index
]
=
vec_indices
[
data_idx
[
axis_index
]];
data_idx
[
axis_index
]
=
vec_indices
[
data_idx
[
axis_index
]];
//output(out_idx.begin(), out_idx.end()) = data(data_idx.begin(), data_idx.end());
// output(out_idx.begin(), out_idx.end()) = data(data_idx.begin(),
// data_idx.end());
output
[
out_comp_shape
.
index
(
out_idx
)]
=
data
(
data_idx
.
begin
(),
data_idx
.
end
());
output
[
out_comp_shape
.
index
(
out_idx
)]
=
data
(
data_idx
.
begin
(),
data_idx
.
end
());
});
});
}
}
...
...
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