Yulia Garbovich | f61ea35 | 2021-11-11 14:16:57 +0200 | [diff] [blame] | 1 | # |
Kristofer Jonsson | ac535f0 | 2022-03-10 11:08:39 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2022 Arm Limited. |
Yulia Garbovich | f61ea35 | 2021-11-11 14:16:57 +0200 | [diff] [blame] | 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 | |
Davide Grohmann | ffb8ccd | 2022-08-24 11:16:21 +0200 | [diff] [blame] | 19 | if(NOT TARGET freertos_kernel) |
| 20 | message("Skipping message handler") |
Yulia Garbovich | f61ea35 | 2021-11-11 14:16:57 +0200 | [diff] [blame] | 21 | return() |
| 22 | endif() |
| 23 | |
Kristofer Jonsson | a739d21 | 2022-05-05 12:11:52 +0200 | [diff] [blame] | 24 | # Split total tensor arena equally for each NPU |
Davide Grohmann | ffb8ccd | 2022-08-24 11:16:21 +0200 | [diff] [blame] | 25 | if(TARGET ethosu_core_driver AND ETHOSU_TARGET_NPU_COUNT GREATER 0) |
Kristofer Jonsson | a739d21 | 2022-05-05 12:11:52 +0200 | [diff] [blame] | 26 | set(NUM_ARENAS ${ETHOSU_TARGET_NPU_COUNT}) |
| 27 | else() |
| 28 | set(NUM_ARENAS 1) |
| 29 | endif() |
| 30 | |
Davide Grohmann | 144b2d2 | 2022-05-31 15:24:02 +0200 | [diff] [blame] | 31 | set(MESSAGE_HANDLER_ARENA_SIZE 2000000 CACHE STRING "Total size of all message handler tensor arenas") |
Kristofer Jonsson | a739d21 | 2022-05-05 12:11:52 +0200 | [diff] [blame] | 32 | math(EXPR TENSOR_ARENA_SIZE "${MESSAGE_HANDLER_ARENA_SIZE} / ${NUM_ARENAS}") |
| 33 | |
Davide Grohmann | 144b2d2 | 2022-05-31 15:24:02 +0200 | [diff] [blame] | 34 | add_subdirectory(lib) |
Davide Grohmann | ec72e9b | 2022-08-08 17:30:28 +0200 | [diff] [blame] | 35 | add_subdirectory(test) |
Davide Grohmann | 144b2d2 | 2022-05-31 15:24:02 +0200 | [diff] [blame] | 36 | |
| 37 | set(MESSAGE_HANDLER_MODEL_0 "" CACHE STRING "Path to built in model 0") |
| 38 | set(MESSAGE_HANDLER_MODEL_1 "" CACHE STRING "Path to built in model 1") |
| 39 | set(MESSAGE_HANDLER_MODEL_2 "" CACHE STRING "Path to built in model 2") |
| 40 | set(MESSAGE_HANDLER_MODEL_3 "" CACHE STRING "Path to built in model 3") |
| 41 | |
| 42 | ethosu_add_executable(message_handler |
| 43 | SOURCES |
Davide Grohmann | ffb8ccd | 2022-08-24 11:16:21 +0200 | [diff] [blame] | 44 | main.cpp |
Davide Grohmann | 144b2d2 | 2022-05-31 15:24:02 +0200 | [diff] [blame] | 45 | LIBRARIES |
Davide Grohmann | ffb8ccd | 2022-08-24 11:16:21 +0200 | [diff] [blame] | 46 | message_handler_lib |
| 47 | freertos_kernel) |
Davide Grohmann | 144b2d2 | 2022-05-31 15:24:02 +0200 | [diff] [blame] | 48 | |
| 49 | target_include_directories(message_handler PRIVATE |
| 50 | indexed_networks |
| 51 | ${LINUX_DRIVER_STACK_PATH}/kernel) |
| 52 | |
Yulia Garbovich | f61ea35 | 2021-11-11 14:16:57 +0200 | [diff] [blame] | 53 | target_compile_definitions(message_handler PRIVATE |
Kristofer Jonsson | a739d21 | 2022-05-05 12:11:52 +0200 | [diff] [blame] | 54 | TENSOR_ARENA_SIZE=${TENSOR_ARENA_SIZE} |
Kristofer Jonsson | 585ce69 | 2022-03-08 13:28:05 +0100 | [diff] [blame] | 55 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_0}>:MODEL_0=${MESSAGE_HANDLER_MODEL_0}> |
| 56 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_1}>:MODEL_1=${MESSAGE_HANDLER_MODEL_1}> |
| 57 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_2}>:MODEL_2=${MESSAGE_HANDLER_MODEL_2}> |
| 58 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_3}>:MODEL_3=${MESSAGE_HANDLER_MODEL_3}>) |
Per Åstrand | 2c76ec7 | 2022-04-26 09:57:20 +0200 | [diff] [blame] | 59 | |
| 60 | install(FILES $<TARGET_FILE:message_handler> |
| 61 | DESTINATION "lib/firmware" |
| 62 | RENAME "arm-${ETHOSU_TARGET_NPU_CONFIG}.fw" |
| 63 | ) |