From 6b53c0ca4c7669e552a40712240e67b827bb130b Mon Sep 17 00:00:00 2001 From: Yuan Shuai Date: Fri, 3 Apr 2020 09:43:53 -0500 Subject: [PATCH] [LITE][PROFILER] Split precision profiler from performance profiler (#3305) * split precision profiler from performance profiler. test=develop --- CMakeLists.txt | 2 +- cmake/configure.cmake | 7 ++++--- lite/core/program.cc | 10 +++------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 377e58d3ac..d40491f3ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ lite_option(LITE_WITH_OPENCL "Enable OpenCL support in lite" OFF) lite_option(LITE_WITH_FPGA "Enable FPGA support in lite" OFF) lite_option(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK "Enable light-weight framework" OFF) lite_option(LITE_WITH_PROFILE "Enable profile mode in lite framework" OFF) -lite_option(LITE_WITH_PRECISION_PROFILE "Enable precision profile in profile mode ON in lite" OFF IF LITE_WITH_PROFILE) +lite_option(LITE_WITH_PRECISION_PROFILE "Enable precision profile in profile mode ON in lite" OFF) lite_option(LITE_SHUTDOWN_LOG "Shutdown log system or not." OFF) lite_option(LITE_ON_TINY_PUBLISH "Publish tiny predictor lib." OFF) lite_option(LITE_ON_MODEL_OPTIMIZE_TOOL "Build the model optimize tool" OFF) diff --git a/cmake/configure.cmake b/cmake/configure.cmake index d38c78f62f..0d60c57868 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -152,9 +152,10 @@ endif() if (LITE_WITH_PROFILE) add_definitions("-DLITE_WITH_PROFILE") - if (LITE_WITH_PRECISION_PROFILE) - add_definitions("-DLITE_WITH_PRECISION_PROFILE") - endif() +endif() + +if (LITE_WITH_PRECISION_PROFILE) + add_definitions("-DLITE_WITH_PRECISION_PROFILE") endif() if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) diff --git a/lite/core/program.cc b/lite/core/program.cc index 7284c3983c..ff900c0e23 100644 --- a/lite/core/program.cc +++ b/lite/core/program.cc @@ -20,7 +20,7 @@ #include "lite/operators/conditional_block_op.h" #include "lite/operators/subgraph_op.h" #include "lite/operators/while_op.h" -#ifdef LITE_WITH_PROFILE +#ifdef LITE_WITH_PRECISION_PROFILE #include "lite/core/profile/precision_profiler.h" #endif @@ -136,12 +136,10 @@ void RuntimeProgram::UpdateVarsOfProgram(cpp::ProgramDesc* desc) { } void RuntimeProgram::Run() { -#ifdef LITE_WITH_PROFILE #ifdef LITE_WITH_PRECISION_PROFILE auto inst_precision_profiler = paddle::lite::profile::PrecisionProfiler(); std::string precision_profiler_summary = inst_precision_profiler.GetSummaryHeader(); -#endif #endif for (auto& inst : instructions_) { @@ -149,21 +147,19 @@ void RuntimeProgram::Run() { if (inst.is_feed_fetch_op()) continue; #endif inst.Run(); -#ifdef LITE_WITH_PROFILE #ifdef LITE_WITH_PRECISION_PROFILE #ifndef LITE_WITH_FPGA precision_profiler_summary += inst_precision_profiler.GetInstPrecision(&inst); #endif #endif // LITE_WITH_PRECISION_PROFILE -#endif // LITE_WITH_PROFILE } #ifdef LITE_WITH_PROFILE LOG(INFO) << "\n" << profiler_.Summary(profile::Type::kDispatch, false, 0); +#endif #ifdef LITE_WITH_PRECISION_PROFILE LOG(INFO) << "\n" << precision_profiler_summary; -#endif // LITE_WITH_PRECISION_PROFILE -#endif // LITE_WITH_PROFILE +#endif } void Program::Build(const cpp::ProgramDesc& prog) { -- GitLab