From 1445a6b8487449c22f92e08c9ae1526c4bc55eb7 Mon Sep 17 00:00:00 2001 From: Allard Hendriksen Date: Wed, 11 Jan 2023 18:10:45 +0100 Subject: [PATCH] Add raft::no_op functor This makes it easier to see if a lambda is unused. --- cpp/include/raft/core/operators.hpp | 8 ++++++++ cpp/include/raft/distance/detail/canberra.cuh | 6 +----- cpp/include/raft/distance/detail/chebyshev.cuh | 7 ++----- cpp/include/raft/distance/detail/l1.cuh | 6 +----- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cpp/include/raft/core/operators.hpp b/cpp/include/raft/core/operators.hpp index de521cc945..fae355a2a1 100644 --- a/cpp/include/raft/core/operators.hpp +++ b/cpp/include/raft/core/operators.hpp @@ -40,6 +40,14 @@ struct identity_op { } }; +struct no_op { + template + constexpr RAFT_INLINE_FUNCTION void operator()(const Type& in, UnusedArgs...) const + { + return; + } +}; + template struct cast_op { template diff --git a/cpp/include/raft/distance/detail/canberra.cuh b/cpp/include/raft/distance/detail/canberra.cuh index 90ed3940e1..9b5eb93a97 100644 --- a/cpp/include/raft/distance/detail/canberra.cuh +++ b/cpp/include/raft/distance/detail/canberra.cuh @@ -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 +#include namespace raft { namespace distance { @@ -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