22 #include <raft/core/handle.hpp>
24 #include <rmm/device_scalar.hpp>
25 #include <rmm/device_uvector.hpp>
44 template <
typename math_t>
69 available_sorted(0, stream),
70 cub_storage(0, stream),
72 f_idx_sorted(0, stream),
76 ws_idx_sorted(0, stream),
77 ws_idx_selected(0, stream),
78 ws_idx_save(0, stream),
79 ws_priority(0, stream),
80 ws_priority_sorted(0, stream),
81 d_num_selected(stream)
83 n_train = (svmType ==
EPSILON_SVR) ? n_rows * 2 : n_rows;
97 if (n_ws == 0 || n_ws > n_train) { n_ws = n_train; }
98 n_ws = std::min(1024, n_ws);
139 math_t* f, math_t* alpha, math_t* y,
const math_t* C,
int n_already_selected = 0);
159 void Select(math_t* f, math_t* alpha, math_t* y,
const math_t* C)
161 if (n_ws >= n_train) {
181 raft::copy(idx.data(), ws_idx_save.data() + 2 * nc, 2 * nc, stream);
189 raft::copy(ws_idx_save.data(), idx.data(), n_ws, stream);
213 const raft::handle_t& handle;
216 bool firstcall =
true;
226 rmm::device_uvector<int> f_idx;
227 rmm::device_uvector<int> f_idx_sorted;
229 rmm::device_uvector<int> idx_tmp;
230 rmm::device_uvector<math_t> f_sorted;
232 rmm::device_uvector<bool> available;
233 rmm::device_uvector<bool> available_sorted;
236 rmm::device_uvector<int> idx;
237 rmm::device_uvector<int> ws_idx_sorted;
238 rmm::device_uvector<int> ws_idx_selected;
239 rmm::device_uvector<int> ws_idx_save;
241 rmm::device_uvector<int> ws_priority;
242 rmm::device_uvector<int> ws_priority_sorted;
244 rmm::device_scalar<int> d_num_selected;
245 std::size_t cub_bytes = 0;
246 rmm::device_uvector<char> cub_storage;
248 void AllocateBuffers();
264 int GatherAvailable(
int n_already_selected,
int n_needed,
bool copy_front);
278 template <
typename select_op>
279 int SelectPrevWs(
int n_needed,
int n_already_selected, select_op op);
Definition: workingset.h:45
int GetSize()
Definition: workingset.h:105
void Select(math_t *f, math_t *alpha, math_t *y, const math_t *C)
Select working set indices.
Definition: workingset.h:159
WorkingSet(const raft::handle_t &handle, cudaStream_t stream, int n_rows=0, int n_ws=0, SvmType svmType=C_SVC)
Manage a working set.
Definition: workingset.h:59
bool FIFO_strategy
Workspace selection strategy, note that only FIFO is tested so far
Definition: workingset.h:48
void SetSize(int n_train, int n_ws=0)
Set the size of the working set and allocate buffers accordingly.
Definition: workingset.h:95
~WorkingSet()
Definition: workingset.h:87
void SimpleSelect(math_t *f, math_t *alpha, math_t *y, const math_t *C, int n_already_selected=0)
Select new elements for a working set.
int * GetIndices()
Return a device pointer to the the working set indices.
Definition: workingset.h:112
int PrioritySelect(math_t *alpha, const math_t *C, int nc)
Select elements from the previous working set based on their priority.
#define CUML_LOG_DEBUG(fmt,...)
Definition: logger.hpp:198
SvmType
Definition: svm_parameter.h:21
@ EPSILON_SVR
Definition: svm_parameter.h:21
@ C_SVC
Definition: svm_parameter.h:21
Definition: dbscan.hpp:30
const_agnostic_same_t< T, U > copy(buffer< T > &dst, buffer< U > const &src, typename buffer< T >::index_type dst_offset, typename buffer< U >::index_type src_offset, typename buffer< T >::index_type size, cuda_stream stream)
Definition: buffer.hpp:327