From de42fe8fd584cca4a804e6e6f178f14b169d33c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=9F=E9=A3=9E=E8=B7=83?= <34468585+zhaify@users.noreply.github.com> Date: Wed, 19 Jun 2019 05:51:56 -0400 Subject: [PATCH] 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 --- .../analyzer_int8_image_classification_tester.cc | 2 +- paddle/fluid/inference/tests/api/tester_helper.h | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc b/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc index fbf67d93378..ae78e07304f 100644 --- a/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc @@ -138,7 +138,7 @@ void SetInput(std::vector> *inputs, } } -TEST(Analyzer_int8_resnet50, quantization) { +TEST(Analyzer_int8_image_classification, quantization) { AnalysisConfig cfg; SetConfig(&cfg); diff --git a/paddle/fluid/inference/tests/api/tester_helper.h b/paddle/fluid/inference/tests/api/tester_helper.h index eb786196a88..05936458cef 100644 --- a/paddle/fluid/inference/tests/api/tester_helper.h +++ b/paddle/fluid/inference/tests/api/tester_helper.h @@ -336,14 +336,20 @@ void PredictionRun(PaddlePredictor *predictor, #ifdef WITH_GPERFTOOLS ProfilerStart("paddle_inference.prof"); #endif + int predicted_num = 0; if (!FLAGS_zero_copy) { - run_timer.tic(); for (int i = 0; i < iterations; i++) { + run_timer.tic(); for (int j = 0; j < num_times; j++) { 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 { for (int i = 0; i < iterations; i++) { ConvertPaddleTensorToZeroCopyTensor(predictor, inputs[i]); @@ -352,8 +358,14 @@ void PredictionRun(PaddlePredictor *predictor, predictor->ZeroCopyRun(); } elapsed_time += run_timer.toc(); + + predicted_num += FLAGS_batch_size; + if (predicted_num % 100 == 0) { + LOG(INFO) << predicted_num << " samples"; + } } } + #ifdef WITH_GPERFTOOLS ProfilerStop(); #endif -- GitLab