提交 363f4646 编写于 作者: Z zhaoyangstar

[Compile] Enable time profile option in tiny_publish, test=develop

上级 ebcdb28b
......@@ -191,6 +191,8 @@ if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
include(external/gtest) # download, build, install gtest
include(ccache) # set ccache for compilation
include(external/protobuf) # download, build, install protobuf
elseif (LITE_WITH_PROFILE)
include(external/gflags) # download, build, install gflags
endif()
# for opencl
......
......@@ -140,6 +140,8 @@ if (NOT LITE_ON_TINY_PUBLISH)
add_subdirectory(mir)
add_subdirectory(profile)
add_subdirectory(arena)
elseif (LITE_WITH_PROFILE)
add_subdirectory(profile)
endif()
# for mobile, unnecessary to compile the following testings.
......
......@@ -5,5 +5,5 @@ endif()
lite_cc_library(basic_profiler SRCS basic_profiler.cc DEPS gflags)
lite_cc_test(test_basic_profiler SRCS basic_profiler_test.cc DEPS basic_profiler)
lite_cc_library(lite_profiler SRCS profiler.cc DEPS context)
lite_cc_library(lite_profiler SRCS profiler.cc DEPS context gflags)
lite_cc_test(test_lite_timer SRCS test_timer.cc DEPS lite_profiler)
......@@ -127,14 +127,16 @@ std::string Profiler::Summary(Type type, bool concise, size_t w) {
// Title.
if (concise) {
ss << "Timing cycle = " << units_.front().Timer(type)->LapTimes().Size()
<< std::endl;
<< "\n";
ss << "===== Concise " << TypeStr.find(type)->second
<< " Profiler Summary: " << name_ << ", Exclude " << w
<< " warm-ups =====" << std::endl;
<< " warm-ups ====="
<< "\n";
} else {
ss << "===== Detailed " << TypeStr.find(type)->second
<< " Profiler Summary: " << name_ << ", Exclude " << w
<< " warm-ups =====" << std::endl;
<< " warm-ups ====="
<< "\n";
}
ss << setw(20) << left << "OperatorType"
<< " " << setw(30) << left << "KerneAttr(Place)"
......@@ -169,7 +171,7 @@ std::string Profiler::Summary(Type type, bool concise, size_t w) {
<< " " << setw(12) << left << "LocalWorkSize";
}
#endif
ss << std::endl;
ss << "\n";
// Profile information.
if (concise) {
......@@ -248,7 +250,7 @@ std::string Profiler::Summary(Type type, bool concise, size_t w) {
<< item.second.cl_max
<< " " << left << fixed << setprecision(2) << cl_percent << "% ";
#endif
ss << std::endl;
ss << "\n";
// clang-format on
}
} else {
......@@ -310,7 +312,7 @@ std::string Profiler::Summary(Type type, bool concise, size_t w) {
<< unit.Character().global_work_size << " " << setw(12) << left
<< fixed << unit.Character().local_work_size;
#endif
ss << std::endl;
ss << "\n";
}
}
return ss.str();
......
......@@ -110,6 +110,10 @@ function make_tiny_publish_so {
local lang=$3
local android_stl=$4
if [ ${WITH_PROFILE} == "ON" ]; then
prepare_thirdparty
fi
cur_dir=$(pwd)
build_dir=$cur_dir/build.lite.${os}.${abi}.${lang}
if [ -d $build_dir ]
......@@ -134,6 +138,7 @@ function make_tiny_publish_so {
-DLITE_ON_TINY_PUBLISH=ON \
-DANDROID_STL_TYPE=$android_stl \
-DLITE_BUILD_EXTRA=$BUILD_EXTRA \
-DLITE_WITH_PROFILE=${WITH_PROFILE} \
-DLITE_WITH_CV=$BUILD_CV \
-DLITE_BUILD_TAILOR=$BUILD_TAILOR \
-DLITE_OPTMODEL_DIR=$OPTMODEL_DIR \
......
......@@ -32,6 +32,8 @@ MEDIATEK_APU_SDK_ROOT="$(pwd)/apu_ddk" # Download APU SDK from https://paddlelit
WITH_OPENCL=OFF
# options of adding training ops
WITH_TRAIN=OFF
# options of time profile
WITH_PROFILE=OFF
# num of threads used during compiling..
readonly NUM_PROC=${LITE_BUILD_THREADS:-4}
#####################################################################################################
......@@ -146,6 +148,10 @@ function make_tiny_publish_so {
prepare_opencl_source_code $workspace $build_dir
fi
# 3rd party is needed when profile option is ON
if [ "${WITH_PROFILE}" == "ON" ]; then
prepare_thirdparty
fi
local cmake_mutable_options="
-DLITE_BUILD_EXTRA=$WITH_EXTRA \
......@@ -155,6 +161,7 @@ function make_tiny_publish_so {
-DLITE_OPTMODEL_DIR=$OPTMODEL_DIR \
-DLITE_WITH_JAVA=$WITH_JAVA \
-DLITE_WITH_CV=$WITH_CV \
-DLITE_WITH_PROFILE=$WITH_PROFILE \
-DLITE_WITH_NPU=$WITH_HUAWEI_KIRIN_NPU \
-DNPU_DDK_ROOT=$HUAWEI_KIRIN_NPU_SDK_ROOT \
-DLITE_WITH_APU=$WITH_MEDIATEK_APU \
......@@ -329,6 +336,11 @@ function main {
WITH_STRIP="${i#*=}"
shift
;;
# ON or OFF, default OFF
--with_profile=*)
WITH_PROFILE="${i#*=}"
shift
;;
# string, absolute path to optimized model dir
--opt_model_dir=*)
OPTMODEL_DIR="${i#*=}"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册