-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
106 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
/* Helper functions for testing functions in the .cu files from Python. */ | ||
|
||
#include <vector> | ||
|
||
namespace search { | ||
#ifdef HAVE_CUDA | ||
/* The filter_kenerls.cu functions. */ | ||
extern "C" void SigmaGFilteredIndicesCU(float *values, int num_values, float sgl0, float sgl1, float sg_coeff, | ||
float width, int *idx_array, int *min_keep_idx, int *max_keep_idx); | ||
#endif | ||
|
||
/* Used for testing SigmaGFilteredIndicesCU for python | ||
* | ||
* Return the list of indices from the values array such that those elements | ||
* pass the sigmaG filtering defined by percentiles [sgl0, sgl1] with coefficient | ||
* sigma_g_coeff and a multiplicative factor of width. | ||
* | ||
* The vector values is passed by value to create a local copy which will be modified by | ||
* SigmaGFilteredIndicesCU. | ||
*/ | ||
std::vector<int> sigmaGFilteredIndices(std::vector<float> values, float sgl0, float sgl1, float sigma_g_coeff, | ||
float width) { | ||
int num_values = values.size(); | ||
std::vector<int> idx_array(num_values, 0); | ||
int min_keep_idx = 0; | ||
int max_keep_idx = num_values - 1; | ||
|
||
#ifdef HAVE_CUDA | ||
SigmaGFilteredIndicesCU(values.data(), num_values, sgl0, sgl1, sigma_g_coeff, width, idx_array.data(), | ||
&min_keep_idx, &max_keep_idx); | ||
#else | ||
throw std::runtime_error("Non-GPU SigmaGFilteredIndicesCU is not implemented."); | ||
#endif | ||
|
||
// Copy the result into a vector and return it. | ||
std::vector<int> result; | ||
for (int i = min_keep_idx; i <= max_keep_idx; ++i) { | ||
result.push_back(idx_array[i]); | ||
} | ||
return result; | ||
} | ||
|
||
} /* namespace search */ |
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