rproj_c.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <raft/core/handle.hpp>
20 
21 #include <rmm/device_uvector.hpp>
22 
23 namespace ML {
24 
37 struct paramsRPROJ {
38  int n_samples;
41  double eps;
43  double density;
46 };
47 
49 
50 template <typename math_t>
51 struct rand_mat {
52  rand_mat(cudaStream_t stream)
53  : dense_data(0, stream),
54  indices(0, stream),
55  indptr(0, stream),
56  sparse_data(0, stream),
57  stream(stream),
58  type(unset)
59  {
60  }
61 
62  ~rand_mat() { this->reset(); }
63 
64  // For dense matrices
65  rmm::device_uvector<math_t> dense_data;
66 
67  // For sparse CSC matrices
68  rmm::device_uvector<int> indices;
69  rmm::device_uvector<int> indptr;
70  rmm::device_uvector<math_t> sparse_data;
71 
72  cudaStream_t stream;
73 
75 
76  void reset()
77  {
78  this->dense_data.release();
79  this->indices.release();
80  this->indptr.release();
81  this->sparse_data.release();
82  this->type = unset;
83  };
84 };
85 
86 template <typename math_t>
87 void RPROJfit(const raft::handle_t& handle, rand_mat<math_t>* random_matrix, paramsRPROJ* params);
88 
89 template <typename math_t>
90 void RPROJtransform(const raft::handle_t& handle,
91  math_t* input,
92  rand_mat<math_t>* random_matrix,
93  math_t* output,
95 
96 size_t johnson_lindenstrauss_min_dim(size_t n_samples, double eps);
97 
98 } // namespace ML
Definition: params.hpp:34
random_matrix_type
Definition: rproj_c.h:48
double density
Definition: rproj_c.h:43
int n_features
Definition: rproj_c.h:39
int n_samples
Definition: rproj_c.h:38
double eps
Definition: rproj_c.h:41
void RPROJtransform(const raft::handle_t &handle, math_t *input, rand_mat< math_t > *random_matrix, math_t *output, paramsRPROJ *params)
cudaStream_t stream
Definition: rproj_c.h:72
void RPROJfit(const raft::handle_t &handle, rand_mat< math_t > *random_matrix, paramsRPROJ *params)
rmm::device_uvector< math_t > dense_data
Definition: rproj_c.h:65
bool gaussian_method
Definition: rproj_c.h:42
rand_mat(cudaStream_t stream)
Definition: rproj_c.h:52
rmm::device_uvector< math_t > sparse_data
Definition: rproj_c.h:70
bool dense_output
Definition: rproj_c.h:44
void reset()
Definition: rproj_c.h:76
rmm::device_uvector< int > indptr
Definition: rproj_c.h:69
~rand_mat()
Definition: rproj_c.h:62
int random_state
Definition: rproj_c.h:45
size_t johnson_lindenstrauss_min_dim(size_t n_samples, double eps)
int n_components
Definition: rproj_c.h:40
random_matrix_type type
Definition: rproj_c.h:74
rmm::device_uvector< int > indices
Definition: rproj_c.h:68
@ unset
Definition: rproj_c.h:48
@ sparse
Definition: rproj_c.h:48
@ dense
Definition: rproj_c.h:48
Definition: dbscan.hpp:30
Definition: rproj_c.h:37
Definition: rproj_c.h:51