Move libs/misc/profiling to libs/profiling (#3997)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 13 Dec 2018 01:35:01 +0000 (10:35 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 13 Dec 2018 01:35:01 +0000 (10:35 +0900)
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 <hseok82.oh@samsung.com>
13 files changed:
externals/CMakeLists.txt
libs/misc/CMakeLists.txt
libs/misc/src/profiling/.FORMATDENY [deleted file]
libs/profiling/CMakeLists.txt [new file with mode: 0644]
libs/profiling/include/profiling/profile_buffer.h [moved from libs/misc/include/util/profiling/profile_buffer.h with 99% similarity]
libs/profiling/include/profiling/profiler.h [moved from libs/misc/include/util/profiling/profiler.h with 99% similarity]
libs/profiling/include/profiling/profiling.h [moved from libs/misc/include/util/profiling/profiling.h with 100% similarity]
libs/profiling/include/profiling/time.h [moved from libs/misc/include/util/profiling/time.h with 100% similarity]
libs/profiling/src/profiling/time.cpp [moved from libs/misc/src/profiling/time.cc with 81% similarity]
runtimes/pure_arm_compute/CMakeLists.txt
runtimes/pure_arm_compute/src/execution.cc
tools/tflite_benchmark_model/CMakeLists.txt
tools/tflite_benchmark_model/benchmark_tflite_model.cc

index 65c9cd9..52f0489 100644 (file)
@@ -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")
index 393e390..cd01695 100644 (file)
@@ -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 (file)
index e69de29..0000000
diff --git a/libs/profiling/CMakeLists.txt b/libs/profiling/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7169508
--- /dev/null
@@ -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)
@@ -40,7 +40,7 @@ limitations under the License.
 #include <cstddef>
 #include <cstdint>
 
-#include "util/profiling/time.h"
+#include "profiling/time.h"
 
 namespace tflite {
 namespace profiling {
similarity index 99%
rename from libs/misc/include/util/profiling/profiler.h
rename to libs/profiling/include/profiling/profiler.h
index 1dbbf31..953042d 100644 (file)
@@ -39,7 +39,7 @@ limitations under the License.
 
 #include <vector>
 
-#include "util/profiling/profile_buffer.h"
+#include "profiling/profile_buffer.h"
 
 #ifdef TFLITE_PROFILING_ENABLED
 
similarity index 81%
rename from libs/misc/src/profiling/time.cc
rename to libs/profiling/src/profiling/time.cpp
index 6841c71..92d8595 100644 (file)
@@ -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 <chrono>  // NOLINT(build/c++11)
@@ -45,3 +51,5 @@ uint64_t NowMicros() {
 }  // namespace time
 }  // namespace profiling
 }  // namespace tflite
+
+// clang-format on
index bf6ca06..2a26a7b 100644 (file)
@@ -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)
index 778a221..cabca57 100644 (file)
@@ -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"
index 62f0565..2623fe2 100644 (file)
@@ -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)
index c31b23c..5524eab 100644 (file)
@@ -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 {