aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ohlsson <jonas.ohlsson@arm.com>2021-05-05 10:48:03 +0200
committerJonas Ohlsson <jonas.ohlsson@arm.com>2021-05-05 10:48:03 +0200
commit7f3c1c92732b611a53968b14e70a2b116e43b980 (patch)
tree16c69c51237b578d43f903e836d27cc83414a771
parente348f8f16feef3c473e9217b932468f828988aa3 (diff)
downloadethos-u-core-software-7f3c1c92732b611a53968b14e70a2b116e43b980.tar.gz
MLBEDSW-4228 Building on Windows21.05-rc221.05-rc1
Changes to facilitate building on Windows systems. Signed-off-by: Jonas Ohlsson <jonas.ohlsson@arm.com> Change-Id: I40ffad5fbbe0640a1026f6f8a95bd4a1ef0fb68b
-rw-r--r--CMakeLists.txt3
-rw-r--r--README.md2
-rw-r--r--tensorflow.cmake40
3 files changed, 31 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7d3bea..e8d46ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,8 @@
# limitations under the License.
#
+# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
+# Issues solved with CMake 3.20.1.
cmake_minimum_required(VERSION 3.15.6)
project(core_software VERSION 0.0.1)
@@ -29,6 +31,7 @@ set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.")
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(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.")
# Select accelerator for tensorflow
set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers")
diff --git a/README.md b/README.md
index 42ee2fb..da5618e 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ Date: Mon Feb 29 12:12:12 2016 +0000
Title of the commit
Short description of the change.
-
+
Signed-off-by: John Doe john.doe@example.org
Signed-off-by: Foo Bar foo.bar@example.org
```
diff --git a/tensorflow.cmake b/tensorflow.cmake
index 0216e78..75d7d35 100644
--- a/tensorflow.cmake
+++ b/tensorflow.cmake
@@ -29,26 +29,37 @@ endif()
get_filename_component(TFLU_TARGET_TOOLCHAIN_ROOT ${CMAKE_C_COMPILER} DIRECTORY)
-set(TFLU_TARGET_TOOLCHAIN_ROOT "${TFLU_TARGET_TOOLCHAIN_ROOT}/")
+set(TFLU_TARGET_TOOLCHAIN_ROOT "'${TFLU_TARGET_TOOLCHAIN_ROOT}'/")
set(TFLU_PATH "${TENSORFLOW_PATH}/tensorflow/lite/micro")
-set(TFLU_GENDIR ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/)
+set(TFLU_GENDIR "${CMAKE_CURRENT_BINARY_DIR}/tensorflow/")
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(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()
-# Command and target
-add_custom_target(tflu_gen ALL
+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}
@@ -66,9 +77,12 @@ add_custom_target(tflu_gen ALL
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_GENDIR}/lib/libtensorflow-microlite.a)
+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_definitions(tflu INTERFACE TF_LITE_MICRO TF_LITE_STATIC_MEMORY)