From 7be7fc096676271e31eb6e5c70d1a61d41b079c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 13 Dec 2018 10:35:01 +0900 Subject: [PATCH] Move libs/misc/profiling to libs/profiling (#3997) Move libs/misc/profiling to libs/profiling for profiling library Update cmake to link profiling library Update header path for profiling Update cmake for tensorflow build to support build with BUILD_TFLITE_BENCHMARK_MODEL option Signed-off-by: Hyeongseok Oh --- externals/CMakeLists.txt | 10 ++++++++++ libs/misc/CMakeLists.txt | 1 - libs/misc/src/profiling/.FORMATDENY | 0 libs/profiling/CMakeLists.txt | 5 +++++ .../util => profiling/include}/profiling/profile_buffer.h | 2 +- .../include/util => profiling/include}/profiling/profiler.h | 2 +- .../include/util => profiling/include}/profiling/profiling.h | 0 libs/{misc/include/util => profiling/include}/profiling/time.h | 0 .../src/profiling/time.cc => profiling/src/profiling/time.cpp} | 10 +++++++++- runtimes/pure_arm_compute/CMakeLists.txt | 6 ++---- runtimes/pure_arm_compute/src/execution.cc | 4 ++-- tools/tflite_benchmark_model/CMakeLists.txt | 3 ++- tools/tflite_benchmark_model/benchmark_tflite_model.cc | 2 +- 13 files changed, 33 insertions(+), 12 deletions(-) delete mode 100644 libs/misc/src/profiling/.FORMATDENY create mode 100644 libs/profiling/CMakeLists.txt rename libs/{misc/include/util => profiling/include}/profiling/profile_buffer.h (99%) rename libs/{misc/include/util => profiling/include}/profiling/profiler.h (99%) rename libs/{misc/include/util => profiling/include}/profiling/profiling.h (100%) rename libs/{misc/include/util => profiling/include}/profiling/time.h (100%) rename libs/{misc/src/profiling/time.cc => profiling/src/profiling/time.cpp} (81%) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 65c9cd9..52f0489 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -35,6 +35,16 @@ list(APPEND TFLITE_SRCS ${TFLITE_KERNEL_SRCS}) list(APPEND TFLITE_SRCS ${TFLITE_LIB_SRCS}) list(APPEND TFLITE_SRCS ${TFLITE_API_SRCS}) +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}) + + # We will use our won summarizer + list(REMOVE_ITEM TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/profile_summarizer.cc") + list(APPEND TFLITE_SRCS ${TFLITE_PROFILING_SRCS}) +endif(BUILD_TFLITE_BENCHMARK_MODEL) + list(APPEND TFLITE_SRCS "${TFLITE_DEPEND_DIR}/farmhash/src/farmhash.cc") list(APPEND TFLITE_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow") diff --git a/libs/misc/CMakeLists.txt b/libs/misc/CMakeLists.txt index 393e390..cd01695 100644 --- a/libs/misc/CMakeLists.txt +++ b/libs/misc/CMakeLists.txt @@ -4,7 +4,6 @@ list(APPEND NNFW_UTILITY_SRCS src/tensor/Shape.cpp) list(APPEND NNFW_UTILITY_SRCS src/tensor/NonIncreasingStride.cpp) list(APPEND NNFW_UTILITY_SRCS src/tensor/IndexFormatter.cpp) list(APPEND NNFW_UTILITY_SRCS src/tensor/Comparator.cpp) -list(APPEND NNFW_UTILITY_SRCS src/profiling/time.cc) add_library(nnfw_lib_misc STATIC ${NNFW_UTILITY_SRCS}) target_include_directories(nnfw_lib_misc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/libs/misc/src/profiling/.FORMATDENY b/libs/misc/src/profiling/.FORMATDENY deleted file mode 100644 index e69de29..0000000 diff --git a/libs/profiling/CMakeLists.txt b/libs/profiling/CMakeLists.txt new file mode 100644 index 0000000..7169508 --- /dev/null +++ b/libs/profiling/CMakeLists.txt @@ -0,0 +1,5 @@ +file(GLOB_RECURSE SOURCES "src/*.cpp") + +add_library(nnfw_lib_profiling STATIC ${SOURCES}) +set_property(TARGET nnfw_lib_profiling PROPERTY POSITION_INDEPENDENT_CODE ON) +target_include_directories(nnfw_lib_profiling PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/libs/misc/include/util/profiling/profile_buffer.h b/libs/profiling/include/profiling/profile_buffer.h similarity index 99% rename from libs/misc/include/util/profiling/profile_buffer.h rename to libs/profiling/include/profiling/profile_buffer.h index 8d7d93b..83cd3eb 100644 --- a/libs/misc/include/util/profiling/profile_buffer.h +++ b/libs/profiling/include/profiling/profile_buffer.h @@ -40,7 +40,7 @@ limitations under the License. #include #include -#include "util/profiling/time.h" +#include "profiling/time.h" namespace tflite { namespace profiling { diff --git a/libs/misc/include/util/profiling/profiler.h b/libs/profiling/include/profiling/profiler.h similarity index 99% rename from libs/misc/include/util/profiling/profiler.h rename to libs/profiling/include/profiling/profiler.h index 1dbbf31..953042d 100644 --- a/libs/misc/include/util/profiling/profiler.h +++ b/libs/profiling/include/profiling/profiler.h @@ -39,7 +39,7 @@ limitations under the License. #include -#include "util/profiling/profile_buffer.h" +#include "profiling/profile_buffer.h" #ifdef TFLITE_PROFILING_ENABLED diff --git a/libs/misc/include/util/profiling/profiling.h b/libs/profiling/include/profiling/profiling.h similarity index 100% rename from libs/misc/include/util/profiling/profiling.h rename to libs/profiling/include/profiling/profiling.h diff --git a/libs/misc/include/util/profiling/time.h b/libs/profiling/include/profiling/time.h similarity index 100% rename from libs/misc/include/util/profiling/time.h rename to libs/profiling/include/profiling/time.h diff --git a/libs/misc/src/profiling/time.cc b/libs/profiling/src/profiling/time.cpp similarity index 81% rename from libs/misc/src/profiling/time.cc rename to libs/profiling/src/profiling/time.cpp index 6841c71..92d8595 100644 --- a/libs/misc/src/profiling/time.cc +++ b/libs/profiling/src/profiling/time.cpp @@ -12,7 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include "util/profiling/time.h" + +// NOTE To minimize diff with upstream tensorflow, disable clang-format +// clang-format off + +// NOTE This header is derived from the following file (in TensorFlow v1.12) +// 'externals/tensorflow/tensorflow/contrib/lite/profiling/time.cpp +#include "profiling/time.h" #if defined(_MSC_VER) #include // NOLINT(build/c++11) @@ -45,3 +51,5 @@ uint64_t NowMicros() { } // namespace time } // namespace profiling } // namespace tflite + +// clang-format on diff --git a/runtimes/pure_arm_compute/CMakeLists.txt b/runtimes/pure_arm_compute/CMakeLists.txt index bf6ca06..2a26a7b 100644 --- a/runtimes/pure_arm_compute/CMakeLists.txt +++ b/runtimes/pure_arm_compute/CMakeLists.txt @@ -14,10 +14,8 @@ target_include_directories(nnapi_pure_arm_compute PUBLIC src) if(BUILD_TFLITE_BENCHMARK_MODEL) target_compile_definitions(nnapi_pure_arm_compute PUBLIC "TFLITE_PROFILING_ENABLED") endif() -target_link_libraries(nnapi_pure_arm_compute arm_compute) -target_link_libraries(nnapi_pure_arm_compute arm_compute_ex) -target_link_libraries(nnapi_pure_arm_compute nnfw_lib_misc) -target_link_libraries(nnapi_pure_arm_compute nnfw_lib_cpp14) +target_link_libraries(nnapi_pure_arm_compute arm_compute arm_compute_ex) +target_link_libraries(nnapi_pure_arm_compute nnfw_lib_cpp14 nnfw_lib_misc nnfw_lib_profiling) if("${TARGET_OS}" STREQUAL "android") target_link_libraries(nnapi_pure_arm_compute log) diff --git a/runtimes/pure_arm_compute/src/execution.cc b/runtimes/pure_arm_compute/src/execution.cc index 778a221..cabca57 100644 --- a/runtimes/pure_arm_compute/src/execution.cc +++ b/runtimes/pure_arm_compute/src/execution.cc @@ -18,8 +18,8 @@ #include "compilation.h" #include "execution.h" -#include "util/profiling/profiling.h" -#include "util/profiling/profiler.h" +#include "profiling/profiling.h" +#include "profiling/profiler.h" #include "event.h" #include "internal/VectorSource.h" diff --git a/tools/tflite_benchmark_model/CMakeLists.txt b/tools/tflite_benchmark_model/CMakeLists.txt index 62f0565..2623fe2 100644 --- a/tools/tflite_benchmark_model/CMakeLists.txt +++ b/tools/tflite_benchmark_model/CMakeLists.txt @@ -9,5 +9,6 @@ list(APPEND SOURCES "${TENSORFLOW_LITE_BASE}/tools/benchmark/benchmark_main.cc" add_executable(tflite_benchmark_model ${SOURCES}) target_compile_definitions(tflite_benchmark_model PUBLIC "TFLITE_PROFILING_ENABLED") -target_link_libraries(tflite_benchmark_model tensorflow-lite ${LIB_PTHREAD} dl nnfw_lib_misc nnfw_lib_tflite) +target_link_libraries(tflite_benchmark_model nnfw_lib_misc nnfw_lib_tflite nnfw_lib_profiling) +target_link_libraries(tflite_benchmark_model tensorflow-lite ${LIB_PTHREAD} dl) install(TARGETS tflite_benchmark_model DESTINATION bin) diff --git a/tools/tflite_benchmark_model/benchmark_tflite_model.cc b/tools/tflite_benchmark_model/benchmark_tflite_model.cc index c31b23c..5524eab 100644 --- a/tools/tflite_benchmark_model/benchmark_tflite_model.cc +++ b/tools/tflite_benchmark_model/benchmark_tflite_model.cc @@ -49,7 +49,7 @@ limitations under the License. #include "tensorflow/contrib/lite/tools/benchmark/logging.h" // For profiling nnapi_delegate -#include "util/profiling/profiling.h" +#include "profiling/profiling.h" #include "tflite/ext/nnapi_delegate.h" namespace { -- 2.7.4