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
09cee914
Commit
09cee914
authored
Feb 25, 2019
by
Shucai Xiao
Browse files
simplify the gpu gather implementation
parent
b466ceb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
src/targets/gpu/device/gather.cpp
src/targets/gpu/device/gather.cpp
+12
-21
No files found.
src/targets/gpu/device/gather.cpp
View file @
09cee914
...
@@ -23,28 +23,19 @@ argument gather(hipStream_t stream,
...
@@ -23,28 +23,19 @@ argument gather(hipStream_t stream,
const
auto
*
indices_ptr
=
device_cast
(
indices
.
data
());
const
auto
*
indices_ptr
=
device_cast
(
indices
.
data
());
auto
*
out_ptr
=
device_cast
(
output
.
data
());
auto
*
out_ptr
=
device_cast
(
output
.
data
());
const
auto
*
in_ptr
=
device_cast
(
input
.
data
());
const
auto
*
in_ptr
=
device_cast
(
input
.
data
());
if
(
output_shape
.
scalar
())
auto
&
input_shape
=
args
[
0
].
get_shape
();
{
auto
lens
=
input_shape
.
lens
();
gs_launch
(
stream
,
1
)(
lens
[
axis_index
]
=
args
[
1
].
get_shape
().
elements
();
[
=
](
auto
i
)
{
out_ptr
[
i
]
=
in_ptr
[
static_cast
<
int
>
(
indices_ptr
[
0
])];
});
migraphx
::
shape
out_comp_shape
{
output_shape
.
type
(),
lens
};
}
visit_tensor_size
(
out_comp_shape
.
lens
().
size
(),
[
&
](
auto
n_out_dim
)
{
else
hip_tensor_descriptor
<
n_out_dim
>
desc_input
(
input_shape
);
{
hip_tensor_descriptor
<
n_out_dim
>
desc_output
(
out_comp_shape
);
// if indices are a scalar, output has one dim smaller than input
gs_launch
(
stream
,
nelements
)([
=
](
auto
ii
)
{
auto
&
input_shape
=
args
[
0
].
get_shape
();
auto
in_idx
=
desc_output
.
multi
(
ii
);
auto
lens
=
input_shape
.
lens
();
in_idx
[
axis_index
]
=
indices_ptr
[
in_idx
[
axis_index
]];
lens
[
axis_index
]
=
args
[
1
].
get_shape
().
elements
();
out_ptr
[
ii
]
=
in_ptr
[
desc_input
.
linear
(
in_idx
)];
migraphx
::
shape
out_comp_shape
{
output_shape
.
type
(),
lens
};
visit_tensor_size
(
out_comp_shape
.
lens
().
size
(),
[
&
](
auto
n_out_dim
)
{
hip_tensor_descriptor
<
n_out_dim
>
desc_input
(
input_shape
);
hip_tensor_descriptor
<
n_out_dim
>
desc_output
(
out_comp_shape
);
gs_launch
(
stream
,
nelements
)([
=
](
auto
ii
)
{
auto
in_idx
=
desc_output
.
multi
(
ii
);
in_idx
[
axis_index
]
=
indices_ptr
[
in_idx
[
axis_index
]];
out_ptr
[
ii
]
=
in_ptr
[
desc_input
.
linear
(
in_idx
)];
});
});
});
}
}
);
});
});
});
});
...
...
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