Commit b222af2f authored by Shucai Xiao's avatar Shucai Xiao
Browse files

clang format

parent 9bf18316
......@@ -12,10 +12,7 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace device {
argument argmax(hipStream_t stream,
const argument& result,
const argument& arg,
int axis)
argument argmax(hipStream_t stream, const argument& result, const argument& arg, int axis)
{
auto lens = arg.get_shape().lens();
auto batch_lens = lens;
......@@ -32,7 +29,8 @@ argument argmax(hipStream_t stream,
// each block is for one batch
const size_t block_size = 1024;
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>>;
......@@ -43,7 +41,7 @@ argument argmax(hipStream_t stream,
MIGRAPHX_DEVICE_SHARED int64_t lds_index[block_size];
// load data to lds_data
size_t item_num = n_dims;
for (size_t i = thr_idx; i < n_dims; i += block_size)
for(size_t i = thr_idx; i < n_dims; i += block_size)
{
data_idx[axis] = i;
lds_index[thr_idx] = i;
......@@ -52,9 +50,10 @@ argument argmax(hipStream_t stream,
auto size = (item_num > block_size) ? block_size : item_num;
auto stride = (size + 1) / 2;
while (true)
while(true)
{
if (thr_idx + stride < size and lds_data[thr_idx] < lds_data[thr_idx + stride])
if(thr_idx + stride < size and
lds_data[thr_idx] < lds_data[thr_idx + stride])
{
lds_data[thr_idx] = lds_data[thr_idx + stride];
lds_index[thr_idx] = lds_index[thr_idx + stride];
......@@ -64,10 +63,11 @@ argument argmax(hipStream_t stream,
size = stride;
stride = (stride + 1) / 2;
if (size == 1) break;
if(size == 1)
break;
}
if (thr_idx == 0)
if(thr_idx == 0)
{
output_ptr[blk_idx] = lds_index[0];
}
......
......@@ -12,10 +12,7 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace device {
argument argmax(hipStream_t stream,
const argument& result,
const argument& arg,
int axis)
argument argmax(hipStream_t stream, const argument& result, const argument& arg, int axis)
{
auto lens = arg.get_shape().lens();
auto batch_lens = lens;
......@@ -32,7 +29,8 @@ argument argmax(hipStream_t stream,
// each block is for one batch
const size_t block_size = 1024;
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>>;
......@@ -43,7 +41,7 @@ argument argmax(hipStream_t stream,
MIGRAPHX_DEVICE_SHARED int64_t lds_index[block_size];
// load data to lds_data
size_t item_num = n_dims;
for (size_t i = thr_idx; i < n_dims; i += block_size)
for(size_t i = thr_idx; i < n_dims; i += block_size)
{
data_idx[axis] = i;
lds_index[thr_idx] = i;
......@@ -52,9 +50,10 @@ argument argmax(hipStream_t stream,
auto size = (item_num > block_size) ? block_size : item_num;
auto stride = (size + 1) / 2;
while (true)
while(true)
{
if (thr_idx + stride < size and lds_data[thr_idx] > lds_data[thr_idx + stride])
if(thr_idx + stride < size and
lds_data[thr_idx] > lds_data[thr_idx + stride])
{
lds_data[thr_idx] = lds_data[thr_idx + stride];
lds_index[thr_idx] = lds_index[thr_idx + stride];
......@@ -64,10 +63,11 @@ argument argmax(hipStream_t stream,
size = stride;
stride = (stride + 1) / 2;
if (size == 1) break;
if(size == 1)
break;
}
if (thr_idx == 0)
if(thr_idx == 0)
{
output_ptr[blk_idx] = lds_index[0];
}
......
......@@ -10,10 +10,7 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace device {
argument argmax(hipStream_t stream,
const argument& result,
const argument& arg,
int axis);
argument argmax(hipStream_t stream, const argument& result, const argument& arg, int axis);
} // namespace device
} // namespace gpu
......
......@@ -10,10 +10,7 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace device {
argument argmin(hipStream_t stream,
const argument& result,
const argument& arg,
int axis);
argument argmin(hipStream_t stream, const argument& result, const argument& arg, int axis);
} // namespace device
} // namespace gpu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment