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

Method get_dot_product

src/thundersvm/kernelmatrix.cpp:167–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void KernelMatrix::get_dot_product(const DataSet::node2d &instances, SyncArray<kernel_type> &dot_product) const {
168 SyncArray<kernel_type> dense_ins(instances.size() * n_features_);
169 dense_ins.mem_set(0);
170 kernel_type *dense_ins_data = dense_ins.host_data();
171 for (int i = 0; i < instances.size(); ++i) {
172 kernel_type sum = 0;
173 for (int j = 0; j < instances[i].size(); ++j) {
174 if (instances[i][j].index < n_features_) {
175 //col major for cuSPARSE, row major for Eigen
176#ifdef USE_CUDA
177 dense_ins_data[instances[i][j].index * instances.size() + i] = instances[i][j].value;
178#else
179 dense_ins_data[i * n_features_ + instances[i][j].index] = instances[i][j].value;
180#endif
181 sum += instances[i][j].value * instances[i][j].value;
182 } else {
183// LOG(WARNING)<<"the number of features in testing set is larger than training set";
184 }
185 }
186 }
187 dns_csr_mul(dense_ins, instances.size(), dot_product);
188}
189#ifndef USE_CUDA
190void KernelMatrix::get_dot_product_csr_csr(const SyncArray<int> &idx, SyncArray<kernel_type> &dot_product) const {
191 SyncArray<kernel_type> ws_val;

Callers

nothing calls this directly

Calls 4

dns_csr_mulFunction · 0.85
mem_setMethod · 0.80
sizeMethod · 0.45
host_dataMethod · 0.45

Tested by

no test coverage detected