* @brief Predict on samples in the sample block * @param _head_partition_id id of head partition * @param _tail_partition_id id of tail partition */
| 1562 | * @param _tail_partition_id id of tail partition |
| 1563 | */ |
| 1564 | virtual void predict(int _head_partition_id, int _tail_partition_id) { |
| 1565 | CUDA_CHECK(cudaSetDevice(device_id)); |
| 1566 | load_partition(_head_partition_id, _tail_partition_id); |
| 1567 | |
| 1568 | auto &samples = solver->predict_pool[head_partition_id][tail_partition_id]; |
| 1569 | auto &indexes = solver->sample_indexes[head_partition_id][tail_partition_id]; |
| 1570 | log_frequency = solver->log_frequency; |
| 1571 | size_t num_sample = samples.size(); |
| 1572 | int num_batch = (num_sample + batch_size - 1) / batch_size; |
| 1573 | for (size_t i = 0; i < num_batch; i++) { |
| 1574 | int actual_size = std::min(size_t(batch_size), num_sample - i * batch_size); |
| 1575 | batch.copy(&samples[i * batch_size], actual_size * kSampleSize); |
| 1576 | logits.resize(actual_size); |
| 1577 | predict_batch(solver->predict_batch_id++); |
| 1578 | for (int j = 0; j < actual_size; j++) { |
| 1579 | size_t index = indexes[i * batch_size + j]; |
| 1580 | solver->results[index] = logits[j]; |
| 1581 | } |
| 1582 | } |
| 1583 | logits.reallocate(0); |
| 1584 | } |
| 1585 | |
| 1586 | /** Predict a single batch */ |
| 1587 | virtual void predict_batch(int batch_id) { |
nothing calls this directly
no test coverage detected