Skip to content

Commit

Permalink
finalize move
Browse files Browse the repository at this point in the history
  • Loading branch information
mfoerste4 committed Dec 3, 2024
1 parent e05e5b1 commit 8ee9e98
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ if(BUILD_SHARED_LIBS)
src/neighbors/nn_descent_int8.cu
src/neighbors/nn_descent_uint8.cu
src/neighbors/reachability.cu
src/neighbors/quantization.cu
src/neighbors/refine/detail/refine_device_float_float.cu
src/neighbors/refine/detail/refine_device_half_float.cu
src/neighbors/refine/detail/refine_device_int8_t_float.cu
Expand All @@ -458,6 +457,7 @@ if(BUILD_SHARED_LIBS)
src/neighbors/vamana_serialize_float.cu
src/neighbors/vamana_serialize_uint8.cu
src/neighbors/vamana_serialize_int8.cu
src/preprocessing/quantization.cu
src/selection/select_k_float_int64_t.cu
src/selection/select_k_float_int32_t.cu
src/selection/select_k_float_uint32_t.cu
Expand Down
5 changes: 2 additions & 3 deletions cpp/include/cuvs/preprocessing/quantization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#pragma once

#include <cuvs/neighbors/common.hpp>
#include <raft/core/device_mdarray.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/handle.hpp>
Expand All @@ -25,7 +24,7 @@

#include <cuda_fp16.h>

namespace cuvs::neighbors::quantization {
namespace cuvs::preprocessing::quantization {

/**
* @brief ScalarQuantizer parameters.
Expand Down Expand Up @@ -192,4 +191,4 @@ class ScalarQuantizer {
T max_;
};

} // namespace cuvs::neighbors::quantization
} // namespace cuvs::preprocessing::quantization
6 changes: 3 additions & 3 deletions cpp/src/preprocessing/detail/quantization.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <cuvs/neighbors/quantization.hpp>
#include <cuvs/preprocessing/quantization.hpp>
#include <raft/core/operators.hpp>
#include <raft/linalg/unary_op.cuh>
#include <raft/random/rng.cuh>
Expand All @@ -25,7 +25,7 @@
#include <thrust/sort.h>
#include <thrust/system/omp/execution_policy.h>

namespace cuvs::neighbors::detail {
namespace cuvs::preprocessing::detail {

template <class T>
_RAFT_HOST_DEVICE bool fp_equals(const T& a, const T& b)
Expand Down Expand Up @@ -214,4 +214,4 @@ raft::host_matrix<T, int64_t> inverse_scalar_transform(
return out;
}

} // namespace cuvs::neighbors::detail
} // namespace cuvs::preprocessing::detail
8 changes: 4 additions & 4 deletions cpp/src/preprocessing/quantization.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "./detail/quantization.cuh"

#include <cuvs/neighbors/quantization.hpp>
#include <cuvs/preprocessing/quantization.hpp>

namespace cuvs::neighbors::quantization {
namespace cuvs::preprocessing::quantization {

template <typename T, typename QuantI>
void ScalarQuantizer<T, QuantI>::train(raft::resources const& res,
Expand Down Expand Up @@ -126,12 +126,12 @@ _RAFT_HOST_DEVICE T ScalarQuantizer<T, QuantI>::max() const
}

#define CUVS_INST_QUANTIZATION(T, QuantI) \
template struct cuvs::neighbors::quantization::ScalarQuantizer<T, QuantI>;
template struct cuvs::preprocessing::quantization::ScalarQuantizer<T, QuantI>;

CUVS_INST_QUANTIZATION(double, int8_t);
CUVS_INST_QUANTIZATION(float, int8_t);
CUVS_INST_QUANTIZATION(half, int8_t);

#undef CUVS_INST_QUANTIZATION

} // namespace cuvs::neighbors::quantization
} // namespace cuvs::preprocessing::quantization
17 changes: 5 additions & 12 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,8 @@ endfunction()

if(BUILD_TESTS)
ConfigureTest(
NAME
NEIGHBORS_TEST
PATH
neighbors/brute_force.cu
neighbors/brute_force_prefiltered.cu
neighbors/sparse_brute_force.cu
neighbors/refine.cu
neighbors/quantization.cu
GPUS
1
PERCENT
100
NAME NEIGHBORS_TEST PATH neighbors/brute_force.cu neighbors/brute_force_prefiltered.cu
neighbors/sparse_brute_force.cu neighbors/refine.cu GPUS 1 PERCENT 100
)

ConfigureTest(
Expand Down Expand Up @@ -223,6 +213,9 @@ if(BUILD_TESTS)
PERCENT
100
)

ConfigureTest(NAME PREPROCESSING_TEST PATH preprocessing/quantization.cu GPUS 1 PERCENT 100)

ConfigureTest(
NAME STATS_TEST PATH stats/trustworthiness.cu stats/silhouette_score.cu GPUS 1 PERCENT 100
)
Expand Down
12 changes: 6 additions & 6 deletions cpp/test/preprocessing/quantization.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
*/

#include "../test_utils.cuh"
#include <cuvs/neighbors/quantization.hpp>
#include <cuvs/preprocessing/quantization.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/linalg/transpose.cuh>
#include <raft/matrix/init.cuh>
#include <raft/stats/stddev.cuh>
#include <thrust/execution_policy.h>
#include <thrust/sort.h>

namespace cuvs::neighbors::quantization {
namespace cuvs::preprocessing::quantization {

template <typename T>
struct QuantizationInputs {
cuvs::neighbors::quantization::sq_params quantization_params;
cuvs::preprocessing::quantization::sq_params quantization_params;
int rows;
int cols;
T min = T(-1.0);
Expand Down Expand Up @@ -105,7 +105,7 @@ class QuantizationTest : public ::testing::TestWithParam<QuantizationInputs<T>>
size_t print_size = std::min(input_.size(), 20ul);

// train quantizer_1 on device
cuvs::neighbors::quantization::ScalarQuantizer<T, QuantI> quantizer_1;
cuvs::preprocessing::quantization::ScalarQuantizer<T, QuantI> quantizer_1;
quantizer_1.train(handle, params_.quantization_params, dataset);
std::cerr << "Q1: trained = " << quantizer_1.is_trained()
<< ", min = " << (double)quantizer_1.min() << ", max = " << (double)quantizer_1.max()
Expand Down Expand Up @@ -160,7 +160,7 @@ class QuantizationTest : public ::testing::TestWithParam<QuantizationInputs<T>>
}

// train quantizer_2 on host
cuvs::neighbors::quantization::ScalarQuantizer<T, QuantI> quantizer_2;
cuvs::preprocessing::quantization::ScalarQuantizer<T, QuantI> quantizer_2;
quantizer_2.train(handle, params_.quantization_params, dataset_h);
std::cerr << "Q2: trained = " << quantizer_2.is_trained()
<< ", min = " << (double)quantizer_2.min() << ", max = " << (double)quantizer_2.max()
Expand Down Expand Up @@ -274,4 +274,4 @@ INSTANTIATE_TEST_CASE_P(QuantizationTest,
QuantizationTest_half_int8t,
::testing::ValuesIn(inputs<half>));

} // namespace cuvs::neighbors::quantization
} // namespace cuvs::preprocessing::quantization

0 comments on commit 8ee9e98

Please sign in to comment.