Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2019-2020 Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | # not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | include(ProcessorCount) |
| 20 | ProcessorCount(J) |
| 21 | |
Per Åstrand | 3f6e07a | 2020-05-12 13:16:37 +0200 | [diff] [blame] | 22 | if (CMAKE_CXX_COMPILER_ID STREQUAL "ARMClang") |
| 23 | set(TFLU_CC "${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}") |
| 24 | set(TFLU_CXX "${CMAKE_CXX_COMPILER} --target=${CMAKE_C_COMPILER_TARGET} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}") |
| 25 | set(TFLU_AR ${CMAKE_AR}) |
| 26 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 27 | set(TFLU_CC "${CMAKE_C_COMPILER} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}") |
| 28 | set(TFLU_CXX "${CMAKE_CXX_COMPILER} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}") |
| 29 | set(TFLU_AR ${CMAKE_AR}) |
| 30 | else () |
| 31 | message(FATAL_ERROR "No compiler ID is set") |
| 32 | endif() |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 33 | |
| 34 | set(TFLU_PATH "${TENSORFLOW_PATH}/tensorflow/lite/micro") |
| 35 | set(TFLU_GENDIR ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/) |
| 36 | set(TFLU_TARGET "lib") |
| 37 | set(TFLU_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}) |
| 38 | set(TFLU_ETHOSU_LIBS $<TARGET_FILE:ethosu_core_driver>) |
| 39 | |
| 40 | if(CORE_SOFTWARE_BACKEND STREQUAL NPU) |
Henrik Hoglind | 43fd4de | 2020-05-08 14:18:26 +0200 | [diff] [blame] | 41 | list(APPEND TFLU_TAGS "ethos-u") |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 42 | endif() |
| 43 | |
| 44 | string(JOIN TFLU_TAGS " " TFLU_TAGS) |
| 45 | |
| 46 | # Command and target |
| 47 | add_custom_target(tflu_gen ALL |
Henrik Hoglind | 43fd4de | 2020-05-08 14:18:26 +0200 | [diff] [blame] | 48 | COMMAND make -j${J} -f ${TFLU_PATH}/tools/make/Makefile microlite TARGET=${TFLU_TARGET} TARGET_ARCH=${TFLU_TARGET_ARCH} CC_TOOL=${TFLU_CC} CXX_TOOL=${TFLU_CXX} AR_TOOL=${TFLU_AR} GENDIR=${TFLU_GENDIR} CMSIS_PATH=${CMSIS_PATH} ETHOSU_DRIVER_PATH=${CORE_DRIVER_PATH} ETHOSU_DRIVER_LIBS=${TFLU_ETHOSU_LIBS} TAGS="${TFLU_TAGS}" |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 49 | WORKING_DIRECTORY ${TENSORFLOW_PATH}) |
| 50 | |
| 51 | # Create library and link library to custom target |
| 52 | add_library(tflu STATIC IMPORTED) |
| 53 | set_property(TARGET tflu PROPERTY IMPORTED_LOCATION ${TFLU_GENDIR}/lib/libtensorflow-microlite.a) |
| 54 | add_dependencies(tflu tflu_gen) |
| 55 | target_include_directories(tflu INTERFACE ${TENSORFLOW_PATH}) |