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 f95f976
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 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
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::no_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::no_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::no_op();

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

0 comments on commit f95f976

Please sign in to comment.