forked from rapidsai/cuml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use chebyshev, canberra, hellinger and minkowski distance metrics (ra…
…pidsai#3990) This PR relies on RAFT PR rapidsai/raft#276 which adds these distance metrics support. Authors: - Mahesh Doijade (https://github.com/mdoijade) Approvers: - Dante Gama Dessavre (https://github.com/dantegd) - Corey J. Nolet (https://github.com/cjnolet) - AJ Schmidt (https://github.com/ajschmidt8) URL: rapidsai#3990
- Loading branch information
Showing
29 changed files
with
944 additions
and
115 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,74 @@ | ||
|
||
/* | ||
* 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 <cuml/metrics/metrics.hpp> | ||
#include <raft/distance/distance.cuh> | ||
#include <raft/handle.hpp> | ||
|
||
namespace ML { | ||
|
||
namespace Metrics { | ||
void pairwise_distance_canberra(const raft::handle_t &handle, const double *x, | ||
const double *y, double *dist, int m, int n, | ||
int k, raft::distance::DistanceType metric, | ||
bool isRowMajor, double metric_arg) { | ||
//Allocate workspace | ||
raft::mr::device::buffer<char> workspace(handle.get_device_allocator(), | ||
handle.get_stream(), 1); | ||
|
||
//Call the distance function | ||
/* raft::distance::pairwise_distance(x, y, dist, m, n, k, workspace, metric, | ||
handle.get_stream(), isRowMajor, | ||
metric_arg);*/ | ||
|
||
switch (metric) { | ||
case raft::distance::DistanceType::Canberra: | ||
raft::distance::pairwise_distance_impl< | ||
double, int, raft::distance::DistanceType::Canberra>( | ||
x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); | ||
break; | ||
default: | ||
THROW("Unknown or unsupported distance metric '%d'!", (int)metric); | ||
} | ||
} | ||
|
||
void pairwise_distance_canberra(const raft::handle_t &handle, const float *x, | ||
const float *y, float *dist, int m, int n, | ||
int k, raft::distance::DistanceType metric, | ||
bool isRowMajor, float metric_arg) { | ||
//Allocate workspace | ||
raft::mr::device::buffer<char> workspace(handle.get_device_allocator(), | ||
handle.get_stream(), 1); | ||
|
||
//Call the distance function | ||
/* raft::distance::pairwise_distance(x, y, dist, m, n, k, workspace, metric, | ||
handle.get_stream(), isRowMajor, | ||
metric_arg);*/ | ||
|
||
switch (metric) { | ||
case raft::distance::DistanceType::Canberra: | ||
raft::distance::pairwise_distance_impl< | ||
float, int, raft::distance::DistanceType::Canberra>( | ||
x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); | ||
break; | ||
default: | ||
THROW("Unknown or unsupported distance metric '%d'!", (int)metric); | ||
} | ||
} | ||
|
||
} // 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,37 @@ | ||
|
||
/* | ||
* 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_canberra(const raft::handle_t &handle, const double *x, | ||
const double *y, double *dist, int m, int n, | ||
int k, raft::distance::DistanceType metric, | ||
bool isRowMajor, double metric_arg); | ||
|
||
void pairwise_distance_canberra(const raft::handle_t &handle, const float *x, | ||
const float *y, float *dist, int m, int n, | ||
int k, raft::distance::DistanceType metric, | ||
bool isRowMajor, float metric_arg); | ||
|
||
} // namespace Metrics | ||
} // namespace ML |
Oops, something went wrong.