Switch to the new tflite-micro repo.

Change-Id: I19b806e94207580ab548e8cd4ddada32debf0639
diff --git a/.gitignore b/.gitignore
index 78bff7d..952fe45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@
 /rtos/mbed-os
 /rtos/zephyr
 /tensorflow
+/tflite_micro
 /cmsis-view
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f5f1cb..cc0d39e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,7 @@
 set(CMSIS_VIEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-view" CACHE PATH "Path to cmsis-view.")
 set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.")
 set(LINUX_DRIVER_STACK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../linux_driver_stack" CACHE PATH "Path to Linux driver stack for Arm Ethos-U.")
-set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow" CACHE PATH "Path to Tensorflow.")
+set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro" CACHE PATH "Path to Tensorflow Lite Micro.")
 set(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.")
 
 # Select accelerator for tensorflow
@@ -58,8 +58,8 @@
     target_link_libraries(ethosu_core INTERFACE ethosu_core_driver)
 endif()
 
-# Build Tensorflow library
-include(tensorflow.cmake)
+# Build Tensorflow Lite Micro library
+include(tflite_micro.cmake)
 
 # Build RTOS
 add_subdirectory(rtos)
diff --git a/applications/inference_process/src/inference_process.cpp b/applications/inference_process/src/inference_process.cpp
index 511a139..3e1f12e 100644
--- a/applications/inference_process/src/inference_process.cpp
+++ b/applications/inference_process/src/inference_process.cpp
@@ -22,7 +22,6 @@
 #include "tensorflow/lite/micro/micro_interpreter.h"
 #include "tensorflow/lite/micro/micro_profiler.h"
 #include "tensorflow/lite/schema/schema_generated.h"
-#include "tensorflow/lite/version.h"
 
 #include "arm_profiler.hpp"
 #ifdef ETHOSU
diff --git a/tflite_micro.cmake b/tflite_micro.cmake
new file mode 100644
index 0000000..2cdc4eb
--- /dev/null
+++ b/tflite_micro.cmake
@@ -0,0 +1,103 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the License); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an AS IS BASIS, 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(ProcessorCount)
+ProcessorCount(J)
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "ARMClang")
+    set(TFLU_TOOLCHAIN "armclang")
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    set(TFLU_TOOLCHAIN "gcc")
+else ()
+    message(FATAL_ERROR "No compiler ID is set")
+endif()
+
+get_filename_component(TFLU_TARGET_TOOLCHAIN_ROOT ${CMAKE_C_COMPILER} DIRECTORY)
+
+set(TFLU_TARGET_TOOLCHAIN_ROOT "'${TFLU_TARGET_TOOLCHAIN_ROOT}'/")
+set(TFLU_PATH "${TENSORFLOW_PATH}/tensorflow/lite/micro")
+set(TFLU_GENDIR "${CMAKE_CURRENT_BINARY_DIR}/tflite_micro/")
+set(TFLU_TARGET "cortex_m_generic")
+set(TFLU_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}
+    CACHE STRING "Tensorflow Lite for Microcontrollers target architecture")
+set(TFLU_BUILD_TYPE "release" CACHE STRING "Tensorflow Lite Mirco build type, can be release or debug")
+set(TFLU_OPTIMIZATION_LEVEL CACHE STRING "Tensorflow Lite Micro optimization level")
+
+
+if (TFLU_PREBUILT_LIBRARY_PATH)
+    set(TFLU_IMPORTED_LIB_PATH "${TFLU_PREBUILT_LIBRARY_PATH}")
+    message(STATUS "Using a prebuilt TensorFlow Lite for Microcontrollers library: ${TFLU_IMPORTED_LIB_PATH}")
+else()
+    if(CORE_SOFTWARE_ACCELERATOR STREQUAL NPU)
+        set(TFLU_ETHOSU_LIBS $<TARGET_FILE:ethosu_core_driver>)
+        # Set preference for ethos-u over cmsis-nn
+        set(TFLU_OPTIMIZED_KERNEL_DIR "cmsis_nn")
+        set(TFLU_CO_PROCESSOR "ethos_u")
+    elseif(CORE_SOFTWARE_ACCELERATOR STREQUAL CMSIS-NN)
+        set(TFLU_OPTIMIZED_KERNEL_DIR "cmsis_nn")
+    endif()
+
+    # Windows: change to relative paths.
+    if (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
+        file(RELATIVE_PATH CMSIS_PATH ${TENSORFLOW_PATH} ${CMSIS_PATH})
+        file(RELATIVE_PATH CORE_DRIVER_PATH ${TENSORFLOW_PATH} ${CORE_DRIVER_PATH})
+    endif()
+
+    # Command and target
+    add_custom_target(tflu_gen ALL
+                  COMMAND make -j${J} -f ${TFLU_PATH}/tools/make/Makefile microlite
+                          TARGET_TOOLCHAIN_ROOT=${TFLU_TARGET_TOOLCHAIN_ROOT}
+                          TOOLCHAIN=${TFLU_TOOLCHAIN}
+                          GENDIR=${TFLU_GENDIR}
+                          TARGET=${TFLU_TARGET}
+                          TARGET_ARCH=${TFLU_TARGET_ARCH}
+                          OPTIMIZED_KERNEL_DIR="${TFLU_OPTIMIZED_KERNEL_DIR}"
+                          CO_PROCESSOR="${TFLU_CO_PROCESSOR}"
+                          $<$<BOOL:${FLOAT}>:FLOAT=${FLOAT}>
+                          BUILD_TYPE=${TFLU_BUILD_TYPE}
+                          $<$<BOOL:${TFLU_OPTIMIZATION_LEVEL}>:OPTIMIZATION_LEVEL=${TFLU_OPTIMIZATION_LEVEL}>
+                          CMSIS_PATH=${CMSIS_PATH}
+                          ETHOSU_DRIVER_PATH=${CORE_DRIVER_PATH}
+                          ETHOSU_DRIVER_LIBS=${TFLU_ETHOSU_LIBS}
+                  BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/tensorflow/tensorflow/lite/micro/tools/make/downloads
+                  WORKING_DIRECTORY ${TENSORFLOW_PATH})
+
+    set(TFLU_IMPORTED_LIB_PATH "${TFLU_GENDIR}/lib/libtensorflow-microlite.a")
+endif()
+
+# Create library and link library to custom target
+add_library(tflu STATIC IMPORTED)
+set_property(TARGET tflu PROPERTY IMPORTED_LOCATION "${TFLU_IMPORTED_LIB_PATH}")
+add_dependencies(tflu tflu_gen)
+target_include_directories(tflu INTERFACE
+    ${TENSORFLOW_PATH})
+target_compile_options(tflu INTERFACE
+    -I${TENSORFLOW_PATH}/tensorflow/lite/micro/tools/make/downloads/flatbuffers/include)
+target_compile_definitions(tflu INTERFACE TF_LITE_MICRO TF_LITE_STATIC_MEMORY)
+
+if(${TFLU_BUILD_TYPE} STREQUAL "release")
+    target_compile_definitions(tflu INTERFACE TF_LITE_STRIP_ERROR_STRINGS)
+endif()
+
+if(CORE_SOFTWARE_ACCELERATOR STREQUAL NPU)
+    target_link_libraries(tflu INTERFACE ethosu_core_driver)
+endif()
+
+# Install libraries and header files
+get_target_property(TFLU_IMPORTED_LOCATION tflu IMPORTED_LOCATION)
+install(FILES ${TFLU_IMPORTED_LOCATION} DESTINATION "lib")