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
bf6fc5f8
Commit
bf6fc5f8
authored
Jun 25, 2019
by
Shucai Xiao
Browse files
clang format
parent
d1672f1d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
32 deletions
+36
-32
src/targets/gpu/device/argmax.cpp
src/targets/gpu/device/argmax.cpp
+10
-11
src/targets/gpu/device/argmin.cpp
src/targets/gpu/device/argmin.cpp
+10
-11
src/targets/gpu/include/migraphx/gpu/device/reduce_opers.hpp
src/targets/gpu/include/migraphx/gpu/device/reduce_opers.hpp
+16
-10
No files found.
src/targets/gpu/device/argmax.cpp
View file @
bf6fc5f8
...
...
@@ -30,8 +30,7 @@ void argmax(hipStream_t stream, const argument& result, const argument& arg, int
block_size
*=
2
;
}
launch
(
stream
,
batch_shape
.
elements
()
*
block_size
,
block_size
)([
=
](
auto
idx
)
__device__
{
launch
(
stream
,
batch_shape
.
elements
()
*
block_size
,
block_size
)([
=
](
auto
idx
)
__device__
{
size_t
thr_idx
=
idx
.
local
;
size_t
blk_idx
=
idx
.
group
;
using
type
=
device_type
<
std
::
remove_cv_t
<
typename
decltype
(
output
)
::
value_type
>>
;
...
...
@@ -47,7 +46,7 @@ void argmax(hipStream_t stream, const argument& result, const argument& arg, int
lds_index
[
max_block_size
]
=
0
;
for
(
size_t
i
=
thr_idx
;
i
<
round_item_num
;
i
+=
block_size
)
{
if
(
i
<
batch_item_num
)
if
(
i
<
batch_item_num
)
{
data_idx
[
axis
]
=
i
;
lds_index
[
thr_idx
]
=
i
;
...
...
@@ -61,7 +60,7 @@ void argmax(hipStream_t stream, const argument& result, const argument& arg, int
remaining_item_num
-=
block_size
;
}
if
(
thr_idx
==
0
)
if
(
thr_idx
==
0
)
{
output
[
batch_idx
]
=
lds_index
[
max_block_size
];
}
...
...
src/targets/gpu/device/argmin.cpp
View file @
bf6fc5f8
...
...
@@ -30,8 +30,7 @@ void argmin(hipStream_t stream, const argument& result, const argument& arg, int
block_size
*=
2
;
}
launch
(
stream
,
batch_shape
.
elements
()
*
block_size
,
block_size
)([
=
](
auto
idx
)
__device__
{
launch
(
stream
,
batch_shape
.
elements
()
*
block_size
,
block_size
)([
=
](
auto
idx
)
__device__
{
size_t
thr_idx
=
idx
.
local
;
size_t
blk_idx
=
idx
.
group
;
using
type
=
device_type
<
std
::
remove_cv_t
<
typename
decltype
(
output
)
::
value_type
>>
;
...
...
@@ -47,7 +46,7 @@ void argmin(hipStream_t stream, const argument& result, const argument& arg, int
lds_index
[
max_block_size
]
=
0
;
for
(
size_t
i
=
thr_idx
;
i
<
round_item_num
;
i
+=
block_size
)
{
if
(
i
<
batch_item_num
)
if
(
i
<
batch_item_num
)
{
data_idx
[
axis
]
=
i
;
lds_index
[
thr_idx
]
=
i
;
...
...
@@ -61,7 +60,7 @@ void argmin(hipStream_t stream, const argument& result, const argument& arg, int
remaining_item_num
-=
block_size
;
}
if
(
thr_idx
==
0
)
if
(
thr_idx
==
0
)
{
output
[
batch_idx
]
=
lds_index
[
max_block_size
];
}
...
...
src/targets/gpu/include/migraphx/gpu/device/reduce_opers.hpp
View file @
bf6fc5f8
...
...
@@ -38,7 +38,12 @@ inline __device__ void reduce_max(T* data_ptr, size_t block_size, size_t thr_idx
}
template
<
class
T
>
inline
__device__
void
reduce_argmax
(
T
*
data_ptr
,
int64_t
*
index_ptr
,
size_t
block_size
,
size_t
thr_idx
,
size_t
item_num
,
size_t
max_index
)
inline
__device__
void
reduce_argmax
(
T
*
data_ptr
,
int64_t
*
index_ptr
,
size_t
block_size
,
size_t
thr_idx
,
size_t
item_num
,
size_t
max_index
)
{
while
(
true
)
{
...
...
@@ -46,7 +51,7 @@ inline __device__ void reduce_argmax(T* data_ptr, int64_t* index_ptr, size_t blo
auto
size
=
item_num
/
2
;
for
(
size_t
i
=
thr_idx
;
i
<
size
;
i
+=
block_size
)
{
if
(
data_ptr
[
i
]
<
data_ptr
[
i
+
stride
])
if
(
data_ptr
[
i
]
<
data_ptr
[
i
+
stride
])
{
data_ptr
[
i
]
=
data_ptr
[
i
+
stride
];
index_ptr
[
i
]
=
index_ptr
[
i
+
stride
];
...
...
@@ -61,7 +66,7 @@ inline __device__ void reduce_argmax(T* data_ptr, int64_t* index_ptr, size_t blo
if
(
thr_idx
==
0
)
{
if
(
data_ptr
[
max_index
]
<
data_ptr
[
0
])
if
(
data_ptr
[
max_index
]
<
data_ptr
[
0
])
{
data_ptr
[
max_index
]
=
data_ptr
[
0
];
index_ptr
[
max_index
]
=
index_ptr
[
0
];
...
...
@@ -72,7 +77,8 @@ inline __device__ void reduce_argmax(T* data_ptr, int64_t* index_ptr, size_t blo
}
template
<
class
T
>
inline
__device__
void
reduce_argmin
(
T
*
data_ptr
,
int64_t
*
index_ptr
,
size_t
block_size
,
size_t
thr_idx
,
size_t
item_num
)
inline
__device__
void
reduce_argmin
(
T
*
data_ptr
,
int64_t
*
index_ptr
,
size_t
block_size
,
size_t
thr_idx
,
size_t
item_num
)
{
size_t
min_index
=
item_num
;
while
(
true
)
...
...
@@ -81,7 +87,7 @@ inline __device__ void reduce_argmin(T* data_ptr, int64_t* index_ptr, size_t blo
auto
size
=
item_num
/
2
;
for
(
size_t
i
=
thr_idx
;
i
<
size
;
i
+=
block_size
)
{
if
(
data_ptr
[
i
]
>
data_ptr
[
i
+
stride
])
if
(
data_ptr
[
i
]
>
data_ptr
[
i
+
stride
])
{
data_ptr
[
i
]
=
data_ptr
[
i
+
stride
];
index_ptr
[
i
]
=
index_ptr
[
i
+
stride
];
...
...
@@ -96,7 +102,7 @@ inline __device__ void reduce_argmin(T* data_ptr, int64_t* index_ptr, size_t blo
if
(
thr_idx
==
0
)
{
if
(
data_ptr
[
min_index
]
>
data_ptr
[
0
])
if
(
data_ptr
[
min_index
]
>
data_ptr
[
0
])
{
data_ptr
[
min_index
]
=
data_ptr
[
0
];
index_ptr
[
min_index
]
=
index_ptr
[
0
];
...
...
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