Skip to content

Commit

Permalink
Add raft::void_op functor (#1136)
Browse files Browse the repository at this point in the history
Follow up on PR #1049. Adds a void_op functor for lambdas that are unused.

Authors:
  - Allard Hendriksen (https://github.com/ahendriksen)

Approvers:
  - Louis Sugy (https://github.com/Nyrio)
  - Artem M. Chirkin (https://github.com/achirkin)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1136
  • Loading branch information
Allard Hendriksen authored Jan 12, 2023
1 parent d86610d commit bbe0755
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
10 changes: 9 additions & 1 deletion cpp/include/raft/core/operators.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,14 @@ struct identity_op {
}
};

struct void_op {
template <typename... UnusedArgs>
constexpr RAFT_INLINE_FUNCTION void operator()(UnusedArgs...) const
{
return;
}
};

template <typename OutT>
struct cast_op {
template <typename InT, typename... UnusedArgs>
Expand Down
8 changes: 2 additions & 6 deletions cpp/include/raft/distance/detail/canberra.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,11 +81,7 @@ static void canberraImpl(const DataT* x,
};

// epilogue operation lambda for final value calculation
auto epilog_lambda = [] __device__(AccT acc[KPolicy::AccRowsPerTh][KPolicy::AccColsPerTh],
DataT * regxn,
DataT * regyn,
IdxT gridStrideX,
IdxT gridStrideY) { return; };
auto epilog_lambda = raft::void_op();

if (isRowMajor) {
auto canberraRowMajor = pairwiseDistanceMatKernel<false,
Expand Down
9 changes: 3 additions & 6 deletions cpp/include/raft/distance/detail/chebyshev.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
*/

#pragma once
#include <raft/core/operators.hpp>
#include <raft/distance/detail/pairwise_distance_base.cuh>

namespace raft {
Expand Down Expand Up @@ -77,11 +78,7 @@ static void chebyshevImpl(const DataT* x,
};

// epilogue operation lambda for final value calculation
auto epilog_lambda = [] __device__(AccT acc[KPolicy::AccRowsPerTh][KPolicy::AccColsPerTh],
DataT * regxn,
DataT * regyn,
IdxT gridStrideX,
IdxT gridStrideY) { return; };
auto epilog_lambda = raft::void_op();

if (isRowMajor) {
auto chebyshevRowMajor = pairwiseDistanceMatKernel<false,
Expand Down
8 changes: 2 additions & 6 deletions cpp/include/raft/distance/detail/l1.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2022, NVIDIA CORPORATION.
* Copyright (c) 2018-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -76,11 +76,7 @@ static void l1Impl(const DataT* x,
};

// epilogue operation lambda for final value calculation
auto epilog_lambda = [] __device__(AccT acc[KPolicy::AccRowsPerTh][KPolicy::AccColsPerTh],
DataT * regxn,
DataT * regyn,
IdxT gridStrideX,
IdxT gridStrideY) { return; };
auto epilog_lambda = raft::void_op();

if (isRowMajor) {
auto l1RowMajor = pairwiseDistanceMatKernel<false,
Expand Down

0 comments on commit bbe0755

Please sign in to comment.