未验证 提交 1d9b2a45 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #14508 from luotao1/warm_up_multi_thread

add warm up in TestMultiThreadPrediction
...@@ -222,7 +222,23 @@ void TestMultiThreadPrediction( ...@@ -222,7 +222,23 @@ void TestMultiThreadPrediction(
// The inputs of each thread are all the same. // The inputs of each thread are all the same.
std::vector<PaddleTensor> outputs_tid; std::vector<PaddleTensor> outputs_tid;
auto &predictor = predictors[tid]; auto &predictor = predictors[tid];
LOG(INFO) << "running thread " << tid;
// warmup run
LOG(INFO) << "Running thread " << tid << ", warm up run...";
{
Timer warmup_timer;
warmup_timer.tic();
predictor->Run(inputs[0], outputs, batch_size);
PrintTime(batch_size, 1, num_threads, tid, warmup_timer.toc(), 1);
#if !defined(_WIN32)
if (FLAGS_profile) {
paddle::platform::ResetProfiler();
}
#endif
}
LOG(INFO) << "Thread " << tid << " run " << num_times << " times...";
{
Timer timer; Timer timer;
timer.tic(); timer.tic();
for (int i = 0; i < num_times; i++) { for (int i = 0; i < num_times; i++) {
...@@ -235,6 +251,7 @@ void TestMultiThreadPrediction( ...@@ -235,6 +251,7 @@ void TestMultiThreadPrediction(
total_time += time; total_time += time;
PrintTime(batch_size, num_times, num_threads, tid, time / num_times, PrintTime(batch_size, num_times, num_threads, tid, time / num_times,
inputs.size()); inputs.size());
}
}); });
} }
for (int i = 0; i < num_threads; ++i) { for (int i = 0; i < num_threads; ++i) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册