提交 de42fe8f 编写于 作者: 翟飞跃 提交者: Tao Luo

Change int8v2 CAPI unit test name and add log in the prediction stage (#18200)

* fix issue 18111;test=develop

* fix timer;test=develop

* refine code;test=develop
上级 802ea509
...@@ -138,7 +138,7 @@ void SetInput(std::vector<std::vector<PaddleTensor>> *inputs, ...@@ -138,7 +138,7 @@ void SetInput(std::vector<std::vector<PaddleTensor>> *inputs,
} }
} }
TEST(Analyzer_int8_resnet50, quantization) { TEST(Analyzer_int8_image_classification, quantization) {
AnalysisConfig cfg; AnalysisConfig cfg;
SetConfig(&cfg); SetConfig(&cfg);
......
...@@ -336,14 +336,20 @@ void PredictionRun(PaddlePredictor *predictor, ...@@ -336,14 +336,20 @@ void PredictionRun(PaddlePredictor *predictor,
#ifdef WITH_GPERFTOOLS #ifdef WITH_GPERFTOOLS
ProfilerStart("paddle_inference.prof"); ProfilerStart("paddle_inference.prof");
#endif #endif
int predicted_num = 0;
if (!FLAGS_zero_copy) { if (!FLAGS_zero_copy) {
run_timer.tic();
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
run_timer.tic();
for (int j = 0; j < num_times; j++) { for (int j = 0; j < num_times; j++) {
predictor->Run(inputs[i], &(*outputs)[i], FLAGS_batch_size); predictor->Run(inputs[i], &(*outputs)[i], FLAGS_batch_size);
} }
elapsed_time += run_timer.toc();
predicted_num += FLAGS_batch_size;
if (predicted_num % 100 == 0) {
LOG(INFO) << predicted_num << " samples";
}
} }
elapsed_time = run_timer.toc();
} else { } else {
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
ConvertPaddleTensorToZeroCopyTensor(predictor, inputs[i]); ConvertPaddleTensorToZeroCopyTensor(predictor, inputs[i]);
...@@ -352,8 +358,14 @@ void PredictionRun(PaddlePredictor *predictor, ...@@ -352,8 +358,14 @@ void PredictionRun(PaddlePredictor *predictor,
predictor->ZeroCopyRun(); predictor->ZeroCopyRun();
} }
elapsed_time += run_timer.toc(); elapsed_time += run_timer.toc();
predicted_num += FLAGS_batch_size;
if (predicted_num % 100 == 0) {
LOG(INFO) << predicted_num << " samples";
}
} }
} }
#ifdef WITH_GPERFTOOLS #ifdef WITH_GPERFTOOLS
ProfilerStop(); ProfilerStop();
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册