Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
viclafargue committed Jul 12, 2023
1 parent cad88b3 commit 6cd1abc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 53 deletions.
20 changes: 10 additions & 10 deletions cpp/include/raft/neighbors/detail/ivf_flat_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ __global__ void reconstruct_list_data_kernel(T* out_vectors,
{
for (IdxT ix = threadIdx.x + blockDim.x * blockIdx.x; ix < len; ix += blockDim.x) {
const IdxT src_ix = std::holds_alternative<IdxT>(offset_or_indices)
? std::get<IdxT>(offset_or_indices) + ix
: std::get<const IdxT*>(offset_or_indices)[ix];
? std::get<IdxT>(offset_or_indices) + ix
: std::get<const IdxT*>(offset_or_indices)[ix];

using group_align = Pow2<kIndexGroupSize>;
using group_align = Pow2<kIndexGroupSize>;
const IdxT group_ix = group_align::div(src_ix);
const IdxT ingroup_ix = group_align::mod(src_ix) * veclen;

Expand All @@ -558,13 +558,13 @@ void reconstruct_list_data(raft::resources const& handle,
IdxT len = out_vectors.extent(0);
const dim3 block_dim(256);
const dim3 grid_dim(raft::div_rounding_up_safe<size_t>(len, block_dim.x));
reconstruct_list_data_kernel<T, IdxT><<<grid_dim, block_dim, 0, stream>>>(
(T*)out_vectors.data_handle(),
(T*)index.lists()[label]->data.data_handle(),
(IdxT)offset,
(IdxT)len,
(size_t)index.veclen(),
(IdxT)index.dim());
reconstruct_list_data_kernel<T, IdxT>
<<<grid_dim, block_dim, 0, stream>>>((T*)out_vectors.data_handle(),
(T*)index.lists()[label]->data.data_handle(),
(IdxT)offset,
(IdxT)len,
(size_t)index.veclen(),
(IdxT)index.dim());
}

} // namespace raft::neighbors::ivf_flat::detail
84 changes: 42 additions & 42 deletions cpp/src/raft_runtime/neighbors/ivf_flat_build.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,48 @@

namespace raft::runtime::neighbors::ivf_flat {

#define RAFT_INST_BUILD_EXTEND(T, IdxT) \
auto build(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index_params& params, \
raft::device_matrix_view<const T, IdxT, row_major> dataset) \
->raft::neighbors::ivf_flat::index<T, IdxT> \
{ \
return raft::neighbors::ivf_flat::build<T, IdxT>(handle, params, dataset); \
} \
auto extend(raft::resources const& handle, \
raft::device_matrix_view<const T, IdxT, row_major> new_vectors, \
std::optional<raft::device_vector_view<const IdxT, IdxT>> new_indices, \
const raft::neighbors::ivf_flat::index<T, IdxT>& orig_index) \
->raft::neighbors::ivf_flat::index<T, IdxT> \
{ \
return raft::neighbors::ivf_flat::extend<T, IdxT>( \
handle, new_vectors, new_indices, orig_index); \
} \
\
void build(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index_params& params, \
raft::device_matrix_view<const T, IdxT, row_major> dataset, \
raft::neighbors::ivf_flat::index<T, IdxT>& idx) \
{ \
idx = build(handle, params, dataset); \
} \
\
void extend(raft::resources const& handle, \
raft::device_matrix_view<const T, IdxT, row_major> new_vectors, \
std::optional<raft::device_vector_view<const IdxT, IdxT>> new_indices, \
raft::neighbors::ivf_flat::index<T, IdxT>* idx) \
{ \
raft::neighbors::ivf_flat::extend<T, IdxT>(handle, new_vectors, new_indices, idx); \
} \
\
void reconstruct_list_data(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index<T, IdxT>& idx, \
device_matrix_view<T, IdxT, row_major> out_vectors, \
IdxT label, \
IdxT offset) \
{ \
raft::neighbors::ivf_flat::reconstruct_list_data<T, IdxT>( \
handle, idx, out_vectors, label, offset); \
#define RAFT_INST_BUILD_EXTEND(T, IdxT) \
auto build(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index_params& params, \
raft::device_matrix_view<const T, IdxT, row_major> dataset) \
->raft::neighbors::ivf_flat::index<T, IdxT> \
{ \
return raft::neighbors::ivf_flat::build<T, IdxT>(handle, params, dataset); \
} \
auto extend(raft::resources const& handle, \
raft::device_matrix_view<const T, IdxT, row_major> new_vectors, \
std::optional<raft::device_vector_view<const IdxT, IdxT>> new_indices, \
const raft::neighbors::ivf_flat::index<T, IdxT>& orig_index) \
->raft::neighbors::ivf_flat::index<T, IdxT> \
{ \
return raft::neighbors::ivf_flat::extend<T, IdxT>( \
handle, new_vectors, new_indices, orig_index); \
} \
\
void build(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index_params& params, \
raft::device_matrix_view<const T, IdxT, row_major> dataset, \
raft::neighbors::ivf_flat::index<T, IdxT>& idx) \
{ \
idx = build(handle, params, dataset); \
} \
\
void extend(raft::resources const& handle, \
raft::device_matrix_view<const T, IdxT, row_major> new_vectors, \
std::optional<raft::device_vector_view<const IdxT, IdxT>> new_indices, \
raft::neighbors::ivf_flat::index<T, IdxT>* idx) \
{ \
raft::neighbors::ivf_flat::extend<T, IdxT>(handle, new_vectors, new_indices, idx); \
} \
\
void reconstruct_list_data(raft::resources const& handle, \
const raft::neighbors::ivf_flat::index<T, IdxT>& idx, \
device_matrix_view<T, IdxT, row_major> out_vectors, \
IdxT label, \
IdxT offset) \
{ \
raft::neighbors::ivf_flat::reconstruct_list_data<T, IdxT>( \
handle, idx, out_vectors, label, offset); \
}

RAFT_INST_BUILD_EXTEND(float, int64_t);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/neighbors/ann_ivf_flat.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger.hpp>
#include <raft/distance/distance_types.hpp>
#include <raft/neighbors/ivf_flat.cuh>
#include <raft/neighbors/detail/ivf_flat_build.cuh>
#include <raft/neighbors/ivf_flat.cuh>
#include <raft/random/rng.cuh>
#include <raft/spatial/knn/ann.cuh>
#include <raft/spatial/knn/knn.cuh>
Expand Down

0 comments on commit 6cd1abc

Please sign in to comment.