-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hamming, jensen-shannon, kl-divergence, correlation and russellra…
…o distance metrics (#4155) -- This PR depends on RAFT PR - rapidsai/raft#306 -- Adds cpp & python interfaces for these distance metrics with pytest support for each of them. -- also remove redundant commented code in canberra distance metric Authors: - Mahesh Doijade (https://github.com/mdoijade) Approvers: - Corey J. Nolet (https://github.com/cjnolet) URL: #4155
- Loading branch information
Showing
27 changed files
with
675 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
/* | ||
* Copyright (c) 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. | ||
* 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 <raft/distance/distance.cuh> | ||
#include <raft/handle.hpp> | ||
#include <rmm/device_uvector.hpp> | ||
#include "pairwise_distance_correlation.cuh" | ||
|
||
namespace ML { | ||
|
||
namespace Metrics { | ||
void pairwise_distance_correlation(const raft::handle_t& handle, | ||
const double* x, | ||
const double* y, | ||
double* dist, | ||
int m, | ||
int n, | ||
int k, | ||
bool isRowMajor, | ||
double metric_arg) | ||
{ | ||
// Allocate workspace | ||
rmm::device_uvector<char> workspace(1, handle.get_stream()); | ||
|
||
// Call the distance function | ||
raft::distance:: | ||
pairwise_distance_impl<double, int, raft::distance::DistanceType::CorrelationExpanded>( | ||
x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); | ||
} | ||
|
||
void pairwise_distance_correlation(const raft::handle_t& handle, | ||
const float* x, | ||
const float* y, | ||
float* dist, | ||
int m, | ||
int n, | ||
int k, | ||
bool isRowMajor, | ||
float metric_arg) | ||
{ | ||
// Allocate workspace | ||
rmm::device_uvector<char> workspace(1, handle.get_stream()); | ||
|
||
// Call the distance function | ||
raft::distance:: | ||
pairwise_distance_impl<float, int, raft::distance::DistanceType::CorrelationExpanded>( | ||
x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); | ||
} | ||
|
||
} // namespace Metrics | ||
} // namespace ML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
/* | ||
* Copyright (c) 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. | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <raft/distance/distance.cuh> | ||
#include <raft/handle.hpp> | ||
|
||
namespace ML { | ||
|
||
namespace Metrics { | ||
void pairwise_distance_correlation(const raft::handle_t& handle, | ||
const double* x, | ||
const double* y, | ||
double* dist, | ||
int m, | ||
int n, | ||
int k, | ||
bool isRowMajor, | ||
double metric_arg); | ||
|
||
void pairwise_distance_correlation(const raft::handle_t& handle, | ||
const float* x, | ||
const float* y, | ||
float* dist, | ||
int m, | ||
int n, | ||
int k, | ||
bool isRowMajor, | ||
float metric_arg); | ||
|
||
} // namespace Metrics | ||
} // namespace ML |
Oops, something went wrong.