diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7bb458c44a..bb771d5e26 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -304,16 +304,7 @@ if(RAFT_COMPILE_LIBRARY) src/distance/specializations/detail/inner_product_double_double_double_int.cu src/distance/specializations/detail/jensen_shannon_float_float_float_int.cu src/distance/specializations/detail/jensen_shannon_double_double_double_int.cu - src/distance/specializations/detail/kernels/gram_matrix_base_double.cu - src/distance/specializations/detail/kernels/gram_matrix_base_float.cu - src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu - src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu - # These are somehow missing a kernel definition which is causing a compile error. - # src/distance/specializations/detail/kernels/rbf_kernel_double.cu - # src/distance/specializations/detail/kernels/rbf_kernel_float.cu src/neighbors/brute_force_knn_int64_t_float.cu - src/distance/specializations/detail/kernels/tanh_kernel_double.cu - src/distance/specializations/detail/kernels/tanh_kernel_float.cu src/distance/specializations/detail/kl_divergence_float_float_float_int.cu src/distance/specializations/detail/kl_divergence_double_double_double_int.cu src/distance/specializations/detail/l1_float_float_float_int.cu @@ -332,6 +323,14 @@ if(RAFT_COMPILE_LIBRARY) src/distance/specializations/fused_l2_nn_double_int64.cu src/distance/specializations/fused_l2_nn_float_int.cu src/distance/specializations/fused_l2_nn_float_int64.cu + src/distance/specializations/kernels/gram_matrix_base_double.cu + src/distance/specializations/kernels/gram_matrix_base_float.cu + src/distance/specializations/kernels/polynomial_kernel_double_int.cu + src/distance/specializations/kernels/polynomial_kernel_float_int.cu + src/distance/specializations/kernels/rbf_kernel_double.cu + src/distance/specializations/kernels/rbf_kernel_float.cu + src/distance/specializations/kernels/tanh_kernel_double.cu + src/distance/specializations/kernels/tanh_kernel_float.cu src/matrix/specializations/detail/select_k_float_uint32_t.cu src/matrix/specializations/detail/select_k_float_int64_t.cu src/matrix/specializations/detail/select_k_half_uint32_t.cu diff --git a/cpp/include/raft/distance/kernels.cuh b/cpp/include/raft/distance/kernels.cuh index 86f9f82406..86a2107f82 100644 --- a/cpp/include/raft/distance/kernels.cuh +++ b/cpp/include/raft/distance/kernels.cuh @@ -16,17 +16,9 @@ #pragma once -#include -#include +#include +#include #include #include #include - -namespace raft::distance::kernels { - -// TODO: Need to expose formal APIs for this that are more consistent w/ other APIs in RAFT -using raft::distance::kernels::detail::GramMatrixBase; -using raft::distance::kernels::detail::KernelFactory; - -}; // end namespace raft::distance::kernels diff --git a/cpp/include/raft/distance/detail/kernels/gram_matrix.cuh b/cpp/include/raft/distance/kernels/gram_matrix.cuh similarity index 99% rename from cpp/include/raft/distance/detail/kernels/gram_matrix.cuh rename to cpp/include/raft/distance/kernels/gram_matrix.cuh index f03f746161..bdd02be1b1 100644 --- a/cpp/include/raft/distance/detail/kernels/gram_matrix.cuh +++ b/cpp/include/raft/distance/kernels/gram_matrix.cuh @@ -20,14 +20,12 @@ #include #include #include -//#include -#include -#include - #include #include +#include +#include -namespace raft::distance::kernels::detail { +namespace raft::distance::kernels { template using dense_input_matrix_view_t = raft::device_matrix_view; @@ -507,4 +505,4 @@ class GramMatrixBase { } }; -}; // end namespace raft::distance::kernels::detail +}; // end namespace raft::distance::kernels diff --git a/cpp/include/raft/distance/detail/kernels/kernel_factory.cuh b/cpp/include/raft/distance/kernels/kernel_factory.cuh similarity index 95% rename from cpp/include/raft/distance/detail/kernels/kernel_factory.cuh rename to cpp/include/raft/distance/kernels/kernel_factory.cuh index 7c74e231d7..9999b29d85 100644 --- a/cpp/include/raft/distance/detail/kernels/kernel_factory.cuh +++ b/cpp/include/raft/distance/kernels/kernel_factory.cuh @@ -21,7 +21,7 @@ #include #include -namespace raft::distance::kernels::detail { +namespace raft::distance::kernels { template class KernelFactory { @@ -61,4 +61,4 @@ class KernelFactory { } }; -}; // end namespace raft::distance::kernels::detail +}; // end namespace raft::distance::kernels diff --git a/cpp/include/raft/distance/detail/kernels/kernel_matrices.cuh b/cpp/include/raft/distance/kernels/kernel_matrices.cuh similarity index 99% rename from cpp/include/raft/distance/detail/kernels/kernel_matrices.cuh rename to cpp/include/raft/distance/kernels/kernel_matrices.cuh index 785c66a3a2..5bf011bd7a 100644 --- a/cpp/include/raft/distance/detail/kernels/kernel_matrices.cuh +++ b/cpp/include/raft/distance/kernels/kernel_matrices.cuh @@ -23,7 +23,7 @@ #include #include -namespace raft::distance::kernels::detail { +namespace raft::distance::kernels { /** Epiloge function for polynomial kernel without padding. * Calculates output = (gain*in + offset)^exponent @@ -738,4 +738,4 @@ class RBFKernel : public GramMatrixBase { } }; -}; // end namespace raft::distance::kernels::detail +}; // end namespace raft::distance::kernels diff --git a/cpp/include/raft/distance/specializations/detail/kernels.cuh b/cpp/include/raft/distance/specializations/detail/kernels.cuh deleted file mode 100644 index 75c9c023e8..0000000000 --- a/cpp/include/raft/distance/specializations/detail/kernels.cuh +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -extern template class raft::distance::kernels::detail::GramMatrixBase; -extern template class raft::distance::kernels::detail::GramMatrixBase; - -extern template class raft::distance::kernels::detail::PolynomialKernel; -extern template class raft::distance::kernels::detail::PolynomialKernel; - -extern template class raft::distance::kernels::detail::TanhKernel; -extern template class raft::distance::kernels::detail::TanhKernel; - -// These are somehow missing a kernel definition which is causing a compile error -// extern template class raft::distance::kernels::detail::RBFKernel; -// extern template class raft::distance::kernels::detail::RBFKernel; \ No newline at end of file diff --git a/cpp/include/raft/distance/specializations/distance.cuh b/cpp/include/raft/distance/specializations/distance.cuh index a34f696e9e..c2324a24cd 100644 --- a/cpp/include/raft/distance/specializations/distance.cuh +++ b/cpp/include/raft/distance/specializations/distance.cuh @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -32,3 +31,4 @@ #include #include #include +#include diff --git a/cpp/include/raft/distance/specializations/kernels.cuh b/cpp/include/raft/distance/specializations/kernels.cuh new file mode 100644 index 0000000000..f213aeaf9a --- /dev/null +++ b/cpp/include/raft/distance/specializations/kernels.cuh @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +extern template class raft::distance::kernels::GramMatrixBase; +extern template class raft::distance::kernels::GramMatrixBase; + +extern template class raft::distance::kernels::PolynomialKernel; +extern template class raft::distance::kernels::PolynomialKernel; + +extern template class raft::distance::kernels::TanhKernel; +extern template class raft::distance::kernels::TanhKernel; + +extern template class raft::distance::kernels::RBFKernel; +extern template class raft::distance::kernels::RBFKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_double.cu b/cpp/src/distance/specializations/kernels/gram_matrix_base_double.cu similarity index 83% rename from cpp/src/distance/specializations/detail/kernels/gram_matrix_base_double.cu rename to cpp/src/distance/specializations/kernels/gram_matrix_base_double.cu index 7c80eb29d0..c86bb2796f 100644 --- a/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_double.cu +++ b/cpp/src/distance/specializations/kernels/gram_matrix_base_double.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::GramMatrixBase; \ No newline at end of file +template class raft::distance::kernels::GramMatrixBase; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_float.cu b/cpp/src/distance/specializations/kernels/gram_matrix_base_float.cu similarity index 83% rename from cpp/src/distance/specializations/detail/kernels/gram_matrix_base_float.cu rename to cpp/src/distance/specializations/kernels/gram_matrix_base_float.cu index d777e73dc9..6c160f7e9a 100644 --- a/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_float.cu +++ b/cpp/src/distance/specializations/kernels/gram_matrix_base_float.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::GramMatrixBase; \ No newline at end of file +template class raft::distance::kernels::GramMatrixBase; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu b/cpp/src/distance/specializations/kernels/polynomial_kernel_double_int.cu similarity index 82% rename from cpp/src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu rename to cpp/src/distance/specializations/kernels/polynomial_kernel_double_int.cu index 28306d0c21..ae08ae9fef 100644 --- a/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu +++ b/cpp/src/distance/specializations/kernels/polynomial_kernel_double_int.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::PolynomialKernel; \ No newline at end of file +template class raft::distance::kernels::PolynomialKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu b/cpp/src/distance/specializations/kernels/polynomial_kernel_float_int.cu similarity index 82% rename from cpp/src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu rename to cpp/src/distance/specializations/kernels/polynomial_kernel_float_int.cu index 6609de69ac..7bcbe645e9 100644 --- a/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu +++ b/cpp/src/distance/specializations/kernels/polynomial_kernel_float_int.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::PolynomialKernel; \ No newline at end of file +template class raft::distance::kernels::PolynomialKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/rbf_kernel_double.cu b/cpp/src/distance/specializations/kernels/rbf_kernel_double.cu similarity index 83% rename from cpp/src/distance/specializations/detail/kernels/rbf_kernel_double.cu rename to cpp/src/distance/specializations/kernels/rbf_kernel_double.cu index 7ea4b60e09..411c4b879f 100644 --- a/cpp/src/distance/specializations/detail/kernels/rbf_kernel_double.cu +++ b/cpp/src/distance/specializations/kernels/rbf_kernel_double.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::RBFKernel; \ No newline at end of file +template class raft::distance::kernels::RBFKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/rbf_kernel_float.cu b/cpp/src/distance/specializations/kernels/rbf_kernel_float.cu similarity index 84% rename from cpp/src/distance/specializations/detail/kernels/rbf_kernel_float.cu rename to cpp/src/distance/specializations/kernels/rbf_kernel_float.cu index 423613dcd1..0a1ed92f4e 100644 --- a/cpp/src/distance/specializations/detail/kernels/rbf_kernel_float.cu +++ b/cpp/src/distance/specializations/kernels/rbf_kernel_float.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::RBFKernel; \ No newline at end of file +template class raft::distance::kernels::RBFKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/tanh_kernel_double.cu b/cpp/src/distance/specializations/kernels/tanh_kernel_double.cu similarity index 83% rename from cpp/src/distance/specializations/detail/kernels/tanh_kernel_double.cu rename to cpp/src/distance/specializations/kernels/tanh_kernel_double.cu index ab818db73b..7b58343367 100644 --- a/cpp/src/distance/specializations/detail/kernels/tanh_kernel_double.cu +++ b/cpp/src/distance/specializations/kernels/tanh_kernel_double.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::TanhKernel; \ No newline at end of file +template class raft::distance::kernels::TanhKernel; \ No newline at end of file diff --git a/cpp/src/distance/specializations/detail/kernels/tanh_kernel_float.cu b/cpp/src/distance/specializations/kernels/tanh_kernel_float.cu similarity index 83% rename from cpp/src/distance/specializations/detail/kernels/tanh_kernel_float.cu rename to cpp/src/distance/specializations/kernels/tanh_kernel_float.cu index f7825e577a..8cc73bb81f 100644 --- a/cpp/src/distance/specializations/detail/kernels/tanh_kernel_float.cu +++ b/cpp/src/distance/specializations/kernels/tanh_kernel_float.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include -template class raft::distance::kernels::detail::TanhKernel; \ No newline at end of file +template class raft::distance::kernels::TanhKernel; \ No newline at end of file