| 165 | } |
| 166 | |
| 167 | void 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 |
| 190 | void KernelMatrix::get_dot_product_csr_csr(const SyncArray<int> &idx, SyncArray<kernel_type> &dot_product) const { |
| 191 | SyncArray<kernel_type> ws_val; |
nothing calls this directly
no test coverage detected