MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / init_f

Method init_f

src/thundersvm/solver/csmosolver.cpp:189–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void CSMOSolver::init_f(const SyncArray<float_type> &alpha, const SyncArray<int> &y, const KernelMatrix &k_mat,
190 SyncArray<float_type> &f_val) const {
191 //todo auto set batch size
192 int batch_size = 100;
193 vector<int> idx_vec;
194 vector<float_type> alpha_diff_vec;
195 const int *y_data = y.host_data();
196 const float_type *alpha_data = alpha.host_data();
197 for (int i = 0; i < alpha.size(); ++i) {
198 if (alpha_data[i] != 0) {
199 idx_vec.push_back(i);
200 alpha_diff_vec.push_back(-alpha_data[i] * y_data[i]);
201 }
202 if (idx_vec.size() > batch_size || (i == alpha.size() - 1 && !idx_vec.empty())) {
203 SyncArray<int> idx(idx_vec.size());
204 SyncArray<float_type> alpha_diff(idx_vec.size());
205 idx.copy_from(idx_vec.data(), idx_vec.size());
206 alpha_diff.copy_from(alpha_diff_vec.data(), idx_vec.size());
207 SyncArray<kernel_type> kernel_rows(idx.size() * k_mat.n_instances());
208 k_mat.get_rows(idx, kernel_rows);
209 update_f(f_val, alpha_diff, kernel_rows, k_mat.n_instances());
210 idx_vec.clear();
211 alpha_diff_vec.clear();
212 }
213 }
214}
215
216void
217CSMOSolver::smo_kernel(const SyncArray<int> &y, SyncArray<float_type> &f_val, SyncArray<float_type> &alpha,

Callers

nothing calls this directly

Calls 9

update_fFunction · 0.85
copy_fromMethod · 0.80
dataMethod · 0.80
get_rowsMethod · 0.80
clearMethod · 0.80
host_dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
n_instancesMethod · 0.45

Tested by

no test coverage detected