File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
paddle/fluid/inference/tests/api Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -207,19 +207,17 @@ void TestMultiThreadPrediction(
207
207
int batch_size = FLAGS_batch_size;
208
208
int num_times = FLAGS_repeat;
209
209
std::vector<std::thread> threads;
210
- std::vector<std::unique_ptr<PaddlePredictor>> predictors;
211
- predictors.emplace_back (CreateTestPredictor (config, use_analysis));
212
- for (int tid = 1 ; tid < num_threads; ++tid) {
213
- predictors.emplace_back (predictors.front ()->Clone ());
214
- }
210
+ auto main_predictor = CreateTestPredictor (config, use_analysis);
215
211
216
212
size_t total_time{0 };
217
213
for (int tid = 0 ; tid < num_threads; ++tid) {
218
214
threads.emplace_back ([&, tid]() {
219
215
// Each thread should have local inputs and outputs.
220
216
// The inputs of each thread are all the same.
221
217
std::vector<PaddleTensor> outputs_tid;
222
- auto &predictor = predictors[tid];
218
+ // To ensure the thread binding correctly,
219
+ // please clone inside the threadpool.
220
+ auto predictor = main_predictor->Clone ();
223
221
#ifdef PADDLE_WITH_MKLDNN
224
222
if (use_analysis) {
225
223
static_cast <AnalysisPredictor *>(predictor.get ())
You can’t perform that action at this time.
0 commit comments