Skip to content

Commit

Permalink
Add raft::no_op functor
Browse files Browse the repository at this point in the history
This makes it easier to see if a lambda is unused.
  • Loading branch information
ahendriksen committed Jan 11, 2023
1 parent d86610d commit 1445a6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 8 additions & 0 deletions cpp/include/raft/core/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ struct identity_op {
}
};

struct no_op {
template <typename Type, typename... UnusedArgs>
constexpr RAFT_INLINE_FUNCTION void operator()(const Type& in, UnusedArgs...) const
{
return;
}
};

template <typename OutT>
struct cast_op {
template <typename InT, typename... UnusedArgs>
Expand Down
6 changes: 1 addition & 5 deletions cpp/include/raft/distance/detail/canberra.cuh
Original file line number Diff line number Diff line change
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::no_op();

if (isRowMajor) {
auto canberraRowMajor = pairwiseDistanceMatKernel<false,
Expand Down
7 changes: 2 additions & 5 deletions cpp/include/raft/distance/detail/chebyshev.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

namespace raft {
namespace distance {
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::no_op();

if (isRowMajor) {
auto chebyshevRowMajor = pairwiseDistanceMatKernel<false,
Expand Down
6 changes: 1 addition & 5 deletions cpp/include/raft/distance/detail/l1.cuh
Original file line number Diff line number Diff line change
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::no_op();

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

0 comments on commit 1445a6b

Please sign in to comment.