Skip to content

Commit 741cb33

Browse files
committed
test multithreading
1 parent a53e8a8 commit 741cb33

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

paddle/fluid/inference/api/helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ static void PrintTime(int batch_size, int repeat, int num_threads, int tid,
160160
double latency, int epoch = 1) {
161161
LOG(INFO) << "====== batch_size: " << batch_size << ", repeat: " << repeat
162162
<< ", threads: " << num_threads << ", thread id: " << tid
163-
<< ", latency: " << latency << "ms ======";
163+
<< ", latency: " << latency << "ms, fps: " << 1 / (latency / 1000.f)
164+
<< " ======";
164165
if (epoch > 1) {
165166
int samples = batch_size * epoch;
166167
LOG(INFO) << "====== sample number: " << samples

paddle/fluid/inference/tests/api/tester_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void TestMultiThreadPrediction(
139139
}
140140
for (int tid = 0; tid < num_threads; ++tid) {
141141
threads.emplace_back([&, tid]() {
142+
platform::set_cur_thread_id(static_cast<int>(tid) + 1);
142143
// Each thread should have local inputs and outputs.
143144
// The inputs of each thread are all the same.
144145
std::vector<std::vector<PaddleTensor>> inputs_tid = inputs;

0 commit comments

Comments
 (0)