Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / infra / nnfw / cmake / packages / TensorFlowLite-2.3.0 / CMakeLists.txt
@@ -1,8 +1,8 @@
-# Reference: https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/lite/tools/make/Makefile
+# Reference: https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/lite/tools/make/Makefile
 #
-# Tensorflow Lite library 2.2.0
+# Tensorflow Lite library 2.3.0
 #
-set(TENSORFLOW_LITE_BASE ${TFLite220TensorFlowSource_DIR}/tensorflow/lite)
+set(TENSORFLOW_LITE_BASE ${TFLiteVanillaTensorFlowSource_DIR}/tensorflow/lite)
 
 file(GLOB TFLITE_CORE_SRCS "${TENSORFLOW_LITE_BASE}/*.c"
      "${TENSORFLOW_LITE_BASE}/*.cc"
@@ -18,8 +18,7 @@ file(GLOB TFLITE_API_SRCS "${TENSORFLOW_LITE_BASE}/core/api/*.c"
 list(APPEND TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/memory_info.cc")
 list(APPEND TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/time.cc")
 
-file(GLOB TFLITE_EXPERIMENTAL_SRCS "${TENSORFLOW_LITE_BASE}/experimental/resource/*.cc"
-     "${TENSORFLOW_LITE_BASE}/experimental/ruy/*.cc")
+file(GLOB TFLITE_EXPERIMENTAL_SRCS "${TENSORFLOW_LITE_BASE}/experimental/resource/*.cc")
 
 file(GLOB TFLITE_SPARSITY_SRCS "${TENSORFLOW_LITE_BASE}/tools/optimize/sparsity/*.cc")
 
@@ -32,24 +31,37 @@ list(APPEND TFLITE_SRCS ${TFLITE_EXPERIMENTAL_SRCS})
 list(APPEND TFLITE_SRCS ${TFLITE_SPARSITY_SRCS})
 
 # externals
-list(APPEND TFLITE_SRCS "${TFLite220FarmhashSource_DIR}/src/farmhash.cc")
-list(APPEND TFLITE_SRCS "${TFLite220FFT2DSource_DIR}/fftsg.c")
-list(APPEND TFLITE_SRCS "${TFLite220FFT2DSource_DIR}/fftsg2d.c")
-list(APPEND TFLITE_SRCS "${TFLite220FlatBuffersSource_DIR}/src/util.cpp")
+list(APPEND TFLITE_SRCS "${TFLiteVanillaFarmhashSource_DIR}/src/farmhash.cc")
+list(APPEND TFLITE_SRCS "${TFLiteVanillaFFT2DSource_DIR}/fftsg.c")
+list(APPEND TFLITE_SRCS "${TFLiteVanillaFFT2DSource_DIR}/fftsg2d.c")
+list(APPEND TFLITE_SRCS "${TFLiteVanillaFlatBuffersSource_DIR}/src/util.cpp")
 
 # externals - absl
-file(GLOB_RECURSE ABSL_SRCS "${TFLite220AbslSource_DIR}/absl/*.cc")
-file(GLOB_RECURSE ABSL_EXCLS "${TFLite220AbslSource_DIR}/absl/*test*.cc"
-     "${TFLite220AbslSource_DIR}/absl/*benchmark*.cc"
-     "${TFLite220AbslSource_DIR}/absl/synchronization/*.cc"
-     "${TFLite220AbslSource_DIR}/absl/debugging/*.cc"
-     "${TFLite220AbslSource_DIR}/absl/hash/*.cc"
-     "${TFLite220AbslSource_DIR}/absl/flags/*.cc")
+file(GLOB_RECURSE ABSL_SRCS "${TFLiteVanillaAbslSource_DIR}/absl/*.cc")
+file(GLOB_RECURSE ABSL_EXCLS "${TFLiteVanillaAbslSource_DIR}/absl/*test*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/*benchmark*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/synchronization/*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/debugging/*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/hash/*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/flags/*.cc"
+     "${TFLiteVanillaAbslSource_DIR}/absl/random/*.cc")
 list(REMOVE_ITEM ABSL_SRCS ${ABSL_EXCLS})
 list(APPEND TFLITE_SRCS ${ABSL_SRCS})
 
+# externals - ruy
+file(GLOB RUY_SRCS "${TFLiteVanillaRuySource_DIR}/ruy/*.cc")
+file(GLOB_RECURSE RUY_EXCLS "${TFLiteVanillaRuySource_DIR}/ruy/*test*.cc"
+      "${TFLiteVanillaRuySource_DIR}/ruy/*benchmark*.cc"
+      "${TFLiteVanillaRuySource_DIR}/ruy/*example*.cc")
+list(REMOVE_ITEM RUY_SRCS ${RUY_EXCLS})
+# Temporary fix for ruy compilation error.
+# TODO(b/158800055): Remove this hack once the ruy version is correctly bumped.
+list(REMOVE_ITEM RUY_SRCS "${TFLiteVanillaRuySource_DIR}/ruy/prepare_packed_matrices.cc")
+list(APPEND TFLITE_SRCS ${RUY_SRCS})
+
+
 # Build with mmap? true
-# caution: v2.2.0's Makefile has wrong code on this part. This is fixed on master branch.
+# caution: v2.3.0's Makefile has wrong code on this part. This is fixed on master branch.
 set(BUILD_WITH_MMAP TRUE)
 if(${BUILD_WITH_MMAP})
   list(REMOVE_ITEM TFLITE_SRCS "${TENSORFLOW_LITE_BASE}/mmap_allocation_disabled.cc")
@@ -86,25 +98,26 @@ file(GLOB_RECURSE TFLITE_EXCLS "${TENSORFLOW_LITE_BASE}/*test*.cc"
 list(REMOVE_ITEM TFLITE_SRCS ${TFLITE_EXCLS})
 
 # include headers
-list(APPEND TFLITE_INCLUDES "${TFLite220TensorFlowSource_DIR}")
-list(APPEND TFLITE_INCLUDES "${TFLite220EigenSource_DIR}")
-list(APPEND TFLITE_INCLUDES "${TFLite220AbslSource_DIR}")
-list(APPEND TFLITE_INCLUDES "${TFLite220GEMMLowpSource_DIR}")
-list(APPEND TFLITE_INCLUDES "${TFLite220NEON2SSESource_DIR}")
-list(APPEND TFLITE_INCLUDES "${TFLite220FarmhashSource_DIR}/src")
-list(APPEND TFLITE_INCLUDES "${TFLite220FlatBuffersSource_DIR}/include")
-list(APPEND TFLITE_INCLUDES "${TFLite220FP16Source_DIR}/include")
-
-add_library(tensorflow-lite-2.2.0 STATIC ${TFLITE_SRCS})
-target_include_directories(tensorflow-lite-2.2.0 SYSTEM PUBLIC ${TFLITE_INCLUDES})
-target_compile_definitions(tensorflow-lite-2.2.0 PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK -DTFLITE_WITH_RUY -DTFLITE_WITH_RUY_GEMV")
-set_property(TARGET tensorflow-lite-2.2.0 PROPERTY POSITION_INDEPENDENT_CODE ON)
-target_link_libraries(tensorflow-lite-2.2.0 eigen ${LIB_PTHREAD} dl)
-if(${BUILD_WITH_NNAPI})
-  target_link_libraries(tensorflow-lite-2.2.0 rt)
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaTensorFlowSource_DIR}")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaEigenSource_DIR}")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaAbslSource_DIR}")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaGEMMLowpSource_DIR}")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaNEON2SSESource_DIR}")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaFarmhashSource_DIR}/src")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaFlatBuffersSource_DIR}/include")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaFP16Source_DIR}/include")
+list(APPEND TFLITE_INCLUDES "${TFLiteVanillaRuySource_DIR}")
+
+add_library(tensorflow-lite-2.3.0 STATIC ${TFLITE_SRCS})
+target_include_directories(tensorflow-lite-2.3.0 SYSTEM PUBLIC ${TFLITE_INCLUDES})
+target_compile_definitions(tensorflow-lite-2.3.0 PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK -DTFLITE_WITH_RUY -DTFLITE_WITH_RUY_GEMV")
+set_property(TARGET tensorflow-lite-2.3.0 PROPERTY POSITION_INDEPENDENT_CODE ON)
+target_link_libraries(tensorflow-lite-2.3.0 eigen ${LIB_PTHREAD} dl)
+if(NOT ANDROID AND ${BUILD_WITH_NNAPI})
+  target_link_libraries(tensorflow-lite-2.3.0 rt)
 endif()
 
 if(ANDROID)
-  target_link_libraries(tensorflow-lite-2.2.0 log)
-  target_include_directories(tensorflow-lite-2.2.0 PUBLIC "${NDK_DIR}/..")
+  target_link_libraries(tensorflow-lite-2.3.0 log)
+  target_include_directories(tensorflow-lite-2.3.0 PUBLIC "${NDK_DIR}/..")
 endif()