|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +#pragma once |
| 18 | +#include <raft/core/device_mdspan.hpp> |
| 19 | +#include <raft/core/resources.hpp> |
| 20 | +#include <raft/neighbors/cagra.cuh> |
| 21 | +#include <raft/neighbors/ivf_flat.cuh> |
| 22 | +#include <raft/neighbors/ivf_pq.cuh> |
| 23 | +#include <raft/neighbors/sample_filter.cuh> |
| 24 | + |
| 25 | +#include "common/raft/proto/raft_index_kind.hpp" |
| 26 | + |
| 27 | +namespace raft_proto { |
| 28 | +namespace detail { |
| 29 | +template <raft_proto::raft_index_kind K, typename T, typename IdxT> |
| 30 | +using index_instantiation = std::conditional_t< |
| 31 | + K == raft_proto::raft_index_kind::ivf_flat, raft::neighbors::ivf_flat::index<T, IdxT>, |
| 32 | + std::conditional_t< |
| 33 | + K == raft_proto::raft_index_kind::ivf_pq, raft::neighbors::ivf_pq::index<IdxT>, |
| 34 | + std::conditional_t<K == raft_proto::raft_index_kind::cagra, raft::neighbors::cagra::index<T, IdxT>, |
| 35 | + raft::neighbors::ivf_flat::index<T, IdxT>>>>; |
| 36 | +} // namespace detail |
| 37 | +} // namespace raft_proto |
| 38 | + |
| 39 | +#define RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ |
| 40 | + template void search_with_filtering<T, IdxT, raft::neighbors::filtering::bitset_filter<BitsetDataT, BitsetIdxT>>( \ |
| 41 | + raft::resources const&, search_params const&, \ |
| 42 | + raft_proto::detail::index_instantiation<raft_proto::raft_index_kind::index_type, T, IdxT> const&, \ |
| 43 | + raft::device_matrix_view<const T, InpIdxT>, raft::device_matrix_view<IdxT, InpIdxT>, \ |
| 44 | + raft::device_matrix_view<DistT, InpIdxT>, raft::neighbors::filtering::bitset_filter<BitsetDataT, BitsetIdxT>) |
| 45 | + |
| 46 | +#define RAFT_FILTERED_SEARCH_INSTANTIATION(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ |
| 47 | + namespace raft::neighbors::index_type { \ |
| 48 | + RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT); \ |
| 49 | + } |
| 50 | + |
| 51 | +#define RAFT_FILTERED_SEARCH_EXTERN(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ |
| 52 | + namespace raft::neighbors::index_type { \ |
| 53 | + RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT); \ |
| 54 | + } |
0 commit comments