From 640f05feba2c4b54e55c205bce646bfa323bb1e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=83=81=EA=B7=9C/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 9 Aug 2018 10:21:39 +0900 Subject: [PATCH] Introduce BUILD_TFLITE_BENCHMARK_MODEL option (#2226) Related Issue: #1760, #1696 `tflite_benchmark_model` is a tool for profiling a given model. The tools is under development in tensorflow upstream. It was not shipped in v1.9.0 release. Thus I made `tflite_benchmark_model` work for tflite interpreter by chery-picking needed patches. (#2212) This patch is a part of full changes. It only introduces build option. By default, tflite_benchmark_model will not be built. To build tflite_benchmark_model tool, use ``` $ OPTIONS='-DBUILD_PURE_ARM_COMPUTE=ON -DBUILD_TFLITE_BENCHMARK_MODEL=ON' \ CROSS_BUILD=1 TARGET_ARCH=armv7l make all install ``` Signed-off-by: Sanggyu Lee --- cmake/CfgOptionFlags.cmake | 1 + externals/CMakeLists.txt | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/cmake/CfgOptionFlags.cmake b/cmake/CfgOptionFlags.cmake index fa2f700..1a9d724 100644 --- a/cmake/CfgOptionFlags.cmake +++ b/cmake/CfgOptionFlags.cmake @@ -10,6 +10,7 @@ option(BUILD_LABS "Build lab projects" ON) option(BUILD_ANDROID_NN_RUNTIME_TEST "Build Android NN Runtime Test" ON) option(BUILD_DETECTION_APP "Build detection example app" OFF) option(BUILD_NNAPI_QUICKCHECK "Build NN API Quickcheck tools" OFF) +option(BUILD_TFLITE_BENCHMARK_MODEL "Build tflite benchmark model" OFF) if("${TARGET_ARCH}" STREQUAL "armv7l" AND NOT "${TARGET_OS}" STREQUAL "tizen") set(BUILD_PURE_ARM_COMPUTE ON) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 9c99c01..26cc1b4 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -39,6 +39,15 @@ list(APPEND TFLITE_SRCS ${TFLITE_KERNEL_SRCS}) list(APPEND TFLITE_SRCS "${TFLITE_DEPEND_DIR}/farmhash/src/farmhash.cc") +# Profiling +if(BUILD_TFLITE_BENCHMARK_MODEL) + file(GLOB TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/*.cc") + file(GLOB TFLITE_PROFILING_TESTS "${TENSORFLOW_LITE_BASE}/profiling/*test*.cc") + list(REMOVE_ITEM TFLITE_PROFILING_SRCS ${TFLITE_PROFILING_TESTS}) + list(APPEND TFLITE_PROFILING_SRCS "${TENSORFLOW_BASE}/tensorflow/core/util/stats_calculator.cc") + list(APPEND TFLITE_SRCS ${TFLITE_PROFILING_SRCS}) +endif() + list(APPEND TFLITE_INCLUDES "${TFLITE_DEPEND_DIR}/") list(APPEND TFLITE_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow") list(APPEND TFLITE_INCLUDES "${TFLITE_DEPEND_DIR}/gemmlowp") @@ -77,6 +86,9 @@ endif() add_library(tensorflow-lite ${TFLITE_SRCS}) target_include_directories(tensorflow-lite PUBLIC ${TFLITE_INCLUDES}) target_compile_definitions(tensorflow-lite PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK") +if(BUILD_TFLITE_BENCHMARK_MODEL) + target_compile_definitions(tensorflow-lite PUBLIC "TFLITE_PROFILING_ENABLED") +endif() target_link_libraries(tensorflow-lite eigen3 ${LIB_PTHREAD} dl) if("${TARGET_OS}" STREQUAL "android") -- 2.7.4