Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Fix failing Hellinger gtest #3549

Merged
merged 5 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cpp/test/prims/sparse/dist_coo_spmv.cu
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class SparseDistanceCOOSPMVTest
CUDA_CHECK(cudaStreamCreate(&stream));

CUSPARSE_CHECK(cusparseCreate(&cusparseHandle));
CUSPARSE_CHECK(cusparseSetStream(cusparseHandle, stream));

make_data();

Expand Down Expand Up @@ -227,7 +228,8 @@ const std::vector<SparseDistanceCOOSPMVInputs<int, float>> inputs_i32_f = {
{1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f},
{5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
5.0},
raft::distance::DistanceType::InnerProduct},
raft::distance::DistanceType::InnerProduct,
0.0},
{2,
{0, 2, 4, 6, 8},
{0, 1, 0, 1, 0, 1, 0, 1}, // indices
Expand All @@ -251,7 +253,8 @@ const std::vector<SparseDistanceCOOSPMVInputs<int, float>> inputs_i32_f = {
1832.0,
0.0,
},
raft::distance::DistanceType::L2Unexpanded},
raft::distance::DistanceType::L2Unexpanded,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -364,7 +367,8 @@ const std::vector<SparseDistanceCOOSPMVInputs<int, float>> inputs_i32_f = {
6.903282911791188,
7.0,
0.0},
raft::distance::DistanceType::Canberra},
raft::distance::DistanceType::Canberra,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -591,7 +595,8 @@ const std::vector<SparseDistanceCOOSPMVInputs<int, float>> inputs_i32_f = {
0.5079750812968089,
0.8429599432532096,
0.0},
raft::distance::DistanceType::Linf},
raft::distance::DistanceType::Linf,
0.0},

{4,
{0, 1, 1, 2, 4},
Expand All @@ -616,7 +621,8 @@ const std::vector<SparseDistanceCOOSPMVInputs<int, float>> inputs_i32_f = {
0.84454,
0.0,
},
raft::distance::DistanceType::L1}
raft::distance::DistanceType::L1,
0.0}

};

Expand Down
12 changes: 8 additions & 4 deletions cpp/test/prims/sparse/dist_csr_spmv.cu
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ const std::vector<SparseDistanceCSRSPMVInputs<int, float>> inputs_i32_f = {
1832.0,
0.0,
},
raft::distance::DistanceType::L2Unexpanded},
raft::distance::DistanceType::L2Unexpanded,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -350,7 +351,8 @@ const std::vector<SparseDistanceCSRSPMVInputs<int, float>> inputs_i32_f = {
6.903282911791188,
7.0,
0.0},
raft::distance::DistanceType::Canberra},
raft::distance::DistanceType::Canberra,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -577,7 +579,8 @@ const std::vector<SparseDistanceCSRSPMVInputs<int, float>> inputs_i32_f = {
0.5079750812968089,
0.8429599432532096,
0.0},
raft::distance::DistanceType::Linf},
raft::distance::DistanceType::Linf,
0.0},

{4,
{0, 1, 1, 2, 4},
Expand All @@ -602,7 +605,8 @@ const std::vector<SparseDistanceCSRSPMVInputs<int, float>> inputs_i32_f = {
0.84454,
0.0,
},
raft::distance::DistanceType::L1}
raft::distance::DistanceType::L1,
0.0}

};

Expand Down
87 changes: 47 additions & 40 deletions cpp/test/prims/sparse/distance.cu
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class SparseDistanceTest
CUDA_CHECK(cudaStreamCreate(&stream));

CUSPARSE_CHECK(cusparseCreate(&cusparseHandle));
CUSPARSE_CHECK(cusparseSetStream(cusparseHandle, stream));

make_data();

Expand Down Expand Up @@ -131,13 +132,9 @@ class SparseDistanceTest
void compare() {
// skip Hellinger test due to sporadic CI issue
cjnolet marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/rapidsai/cuml/issues/3477
if (params.metric == raft::distance::DistanceType::HellingerExpanded) {
GTEST_SKIP();
} else {
ASSERT_TRUE(devArrMatch(out_dists_ref, out_dists,
params.out_dists_ref_h.size(),
CompareApprox<value_t>(1e-3)));
}
ASSERT_TRUE(devArrMatch(out_dists_ref, out_dists,
params.out_dists_ref_h.size(),
CompareApprox<value_t>(1e-3)));
}

protected:
Expand Down Expand Up @@ -178,14 +175,16 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
1832.0,
0.0,
},
raft::distance::DistanceType::L2Expanded},
raft::distance::DistanceType::L2Expanded,
0.0},
{2,
{0, 2, 4, 6, 8},
{0, 1, 0, 1, 0, 1, 0, 1},
{1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f, 1.0f, 2.0f},
{5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
5.0},
raft::distance::DistanceType::InnerProduct},
raft::distance::DistanceType::InnerProduct,
0.0},
{2,
{0, 2, 4, 6, 8},
{0, 1, 0, 1, 0, 1, 0, 1}, // indices
Expand All @@ -209,7 +208,8 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
1832.0,
0.0,
},
raft::distance::DistanceType::L2Unexpanded},
raft::distance::DistanceType::L2Unexpanded,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -239,7 +239,8 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
0.67676228, 0.24558392, 0.76064776, 0.51360432, 0., 1.,
0.76978799, 0.78021386, 1., 0.84923694, 0.73155632, 0.99166225,
0.61547536, 0.68185144, 1., 0.},
raft::distance::DistanceType::CosineExpanded},
raft::distance::DistanceType::CosineExpanded,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -349,7 +350,8 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
0.75,
1.0,
0.0},
raft::distance::DistanceType::JaccardExpanded},
raft::distance::DistanceType::JaccardExpanded,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -462,7 +464,8 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
6.903282911791188,
7.0,
0.0},
raft::distance::DistanceType::Canberra},
raft::distance::DistanceType::Canberra,
0.0},

{10,
{0, 5, 11, 15, 20, 27, 32, 36, 43, 47, 50},
Expand Down Expand Up @@ -689,33 +692,10 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
0.5079750812968089,
0.8429599432532096,
0.0},
raft::distance::DistanceType::Linf},
raft::distance::DistanceType::Linf,
0.0},

{4,
{0, 1, 1, 2, 4},
{3, 2, 0, 1}, // indices
{0.99296, 0.42180, 0.11687, 0.305869},
{
// dense output
0.0,
0.99296,
1.41476,
1.415707,
0.99296,
0.0,
0.42180,
0.42274,
1.41476,
0.42180,
0.0,
0.84454,
1.41570,
0.42274,
0.84454,
0.0,
},
raft::distance::DistanceType::L1},
{10,
{15,
{0, 5, 8, 9, 15, 20, 26, 31, 34, 38, 45},
{0, 1, 5, 6, 9, 1, 4, 14, 7, 3, 4, 7, 9, 11, 14,
0, 3, 7, 8, 12, 0, 2, 5, 7, 8, 14, 4, 9, 10, 11,
Expand Down Expand Up @@ -754,7 +734,34 @@ const std::vector<SparseDistanceInputs<int, float>> inputs_i32_f = {
1.00000000e+00, 8.05419635e-01, 9.53789212e-01, 8.07933016e-01,
7.40428532e-01, 7.95485011e-01, 8.51370877e-01, 1.49011612e-08},
// Dataset is L1 normalized into pdfs
raft::distance::DistanceType::HellingerExpanded}};
raft::distance::DistanceType::HellingerExpanded,
0.0},

{4,
{0, 1, 1, 2, 4},
{3, 2, 0, 1}, // indices
{0.99296, 0.42180, 0.11687, 0.305869},
{
// dense output
0.0,
0.99296,
1.41476,
1.415707,
0.99296,
0.0,
0.42180,
0.42274,
1.41476,
0.42180,
0.0,
0.84454,
1.41570,
0.42274,
0.84454,
0.0,
},
raft::distance::DistanceType::L1,
0.0}};

typedef SparseDistanceTest<int, float> SparseDistanceTestF;
TEST_P(SparseDistanceTestF, Result) { compare(); }
Expand Down
3 changes: 2 additions & 1 deletion cpp/test/prims/sparse/knn.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, NVIDIA CORPORATION.
* Copyright (c) 2018-2021, 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 @@ -163,6 +163,7 @@ const std::vector<SparseKNNInputs<int, float>> inputs_i32_f = {
{0, 3, 1, 0, 2, 0, 3, 0}, // inds
2,
2,
2,
ML::MetricType::METRIC_L2}};
typedef SparseKNNTest<int, float> KNNTestF;
TEST_P(KNNTestF, Result) { compare(); }
Expand Down