Skip to content

Commit 78e9dc6

Browse files
Daniel Velezaggarg
authored andcommitted
components: Bump MLEK version to 25.05
The goal of this commit is to update ML-Embedded-Evaluation-Kit library to version 25.05 which includes switching to CMSIS6 from CMSIS5. Signed-off-by: Daniel Velez <[email protected]> Signed-off-by: Ahmed Ismail <[email protected]>
1 parent 1993cc3 commit 78e9dc6

17 files changed

+67
-251
lines changed

.github/.cSpellWords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ cmos
3333
CMSDK
3434
cmsis
3535
CMSIS
36+
CMSISDSP
3637
CMSIS's
3738
COEF
3839
coef

applications/keyword_detection/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ target_include_directories(keyword-detection
9494
if(${AUDIO_SOURCE} STREQUAL "ROM")
9595
iot_reference_arm_corstone3xx_convert_audio_source_to_code(
9696
${CMAKE_CURRENT_LIST_DIR}/resources
97-
${CMAKE_CURRENT_BINARY_DIR}
97+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}
9898
)
9999

100100
target_sources(keyword-detection
101101
PRIVATE
102-
${CMAKE_CURRENT_BINARY_DIR}/InputFiles.cc
103-
${CMAKE_CURRENT_BINARY_DIR}/test.cc
102+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}/sample_files.c
103+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}/test.c
104104
)
105105

106106
target_include_directories(keyword-detection
107107
PRIVATE
108-
${CMAKE_CURRENT_BINARY_DIR}
108+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}
109109
)
110110
elseif(${AUDIO_SOURCE} STREQUAL "VSI")
111111
target_compile_definitions(keyword-detection

applications/keyword_detection/ml_interface.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extern QueueHandle_t xMlMqttQueue;
103103

104104
#else /* !defined(AUDIO_VSI) */
105105

106-
#include "InputFiles.hpp"
106+
#include "sample_files.h"
107107

108108
#endif /* AUDIO_VSI */
109109

@@ -739,10 +739,18 @@ static void prvProcessAudio( ApplicationContext &ctx )
739739
ctx.Get<arm::app::KwsClassifier &>( "classifier" ),
740740
ctx.Get<std::vector<std::string> &>( "labels" ),
741741
singleInfResult );
742+
const int16_t * pusSampleDataPtr = get_sample_data_ptr( 0 );
743+
uint32_t ulSampleDataSize = get_sample_data_size( 0 );
744+
745+
if( ( pusSampleDataPtr == NULL ) || ( ulSampleDataSize < preProcess.m_audioDataWindowSize ) )
746+
{
747+
LogError( ( "No audio sample data available for inference.\r\n" ) );
748+
return;
749+
}
742750

743751
/* Creating a sliding window through the whole audio clip. */
744752
auto audioDataSlider = audio::SlidingWindow<const int16_t>(
745-
GetAudioArray( 0 ), GetAudioArraySize( 0 ), preProcess.m_audioDataWindowSize, preProcess.m_audioDataStride );
753+
pusSampleDataPtr, ulSampleDataSize, preProcess.m_audioDataWindowSize, preProcess.m_audioDataStride );
746754

747755
/* Start sliding through audio clip. */
748756
while( audioDataSlider.HasNext() )

applications/speech_recognition/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ target_compile_definitions(speech-recognition
8888
if(${AUDIO_SOURCE} STREQUAL "ROM")
8989
iot_reference_arm_corstone3xx_convert_audio_source_to_code(
9090
${CMAKE_CURRENT_LIST_DIR}/resources
91-
${CMAKE_CURRENT_BINARY_DIR}
91+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}
9292
)
9393

9494
target_sources(speech-recognition
9595
PRIVATE
96-
${CMAKE_CURRENT_BINARY_DIR}/InputFiles.cc
97-
${CMAKE_CURRENT_BINARY_DIR}/test.cc
96+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}/sample_files.c
97+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}/test.c
9898
)
9999

100100
target_include_directories(speech-recognition
101101
PRIVATE
102-
${CMAKE_CURRENT_BINARY_DIR}
102+
${CMAKE_CURRENT_BINARY_DIR}/generated/${ML_USE_CASE}
103103
)
104104
elseif(${AUDIO_SOURCE} STREQUAL "VSI")
105105
target_compile_definitions(speech-recognition

applications/speech_recognition/dsp/src/dsp_task.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2023-2024 Arm Limited and/or its affiliates
1+
/* Copyright 2023-2025 Arm Limited and/or its affiliates
22
33
* SPDX-License-Identifier: MIT
44
*/
@@ -118,7 +118,7 @@ extern EventGroupHandle_t xSystemEvents;
118118

119119
#else /* !defined(AUDIO_VSI) */
120120

121-
#include "InputFiles.hpp"
121+
#include "sample_files.h"
122122

123123
#endif // AUDIO_VSI
124124

@@ -168,12 +168,20 @@ void vDspTask( void * pvParameters )
168168
const int16_t * audioBuf = shared_audio_buffer;
169169
auto audioSource = DspAudioSource( audioBuf, AUDIO_BLOCK_NUM );
170170
#else
171-
const int16_t * audioBuf = GetAudioArray( 0 );
171+
const int16_t * audioBuf = get_sample_data_ptr( 0 );
172+
uint32_t ulSampleDataSize = get_sample_data_size( 0 );
173+
174+
if( ( audioBuf == NULL ) || ( ulSampleDataSize < ( AUDIO_BLOCK_SIZE / sizeof( uint16_t ) ) ) )
175+
{
176+
LogError( ( "No audio sample data available for inference.\r\n" ) );
177+
return;
178+
}
179+
172180
/* This integer division for calculating the number of blocks means that, */
173181
/* any remainder data at the end of the audio clip that's smaller than a */
174182
/* block will not be accounted for. This will not have a major impact on */
175183
/* the inference result as a block is only a small fraction of a second. */
176-
const size_t audioBlockNum = ( size_t ) GetAudioArraySize( 0 ) / ( AUDIO_BLOCK_SIZE / sizeof( uint16_t ) );
184+
const size_t audioBlockNum = ( size_t ) ulSampleDataSize / ( AUDIO_BLOCK_SIZE / sizeof( uint16_t ) );
177185
auto audioSource = DspAudioSource( audioBuf, audioBlockNum );
178186
#endif /* ifdef AUDIO_VSI */
179187

components/ai/ml_embedded_evaluation_kit/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ include(ApplyPatches)
1212

1313
set(PATCH_FILES_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/integration/patches")
1414
set(PATCH_FILES
15-
"${PATCH_FILES_DIRECTORY}/0001-User-defined-resources-download-path.patch"
16-
"${PATCH_FILES_DIRECTORY}/0002-Use-CMSIS_device_header-instead-of-RTE_Components.h.patch"
17-
"${PATCH_FILES_DIRECTORY}/0003-Make-ETHOSU_ARCH-configurable-in-TensorFlow-CMake.patch"
18-
"${PATCH_FILES_DIRECTORY}/0004-Override-EthosU55-NPU-default-IRQ-handler.patch"
15+
"${PATCH_FILES_DIRECTORY}/0001-Override-EthosU55-NPU-default-IRQ-handler.patch"
1916
)
2017
iot_reference_arm_corstone3xx_apply_patches("${ml_embedded_evaluation_kit_SOURCE_DIR}" "${PATCH_FILES}")
21-
22-
set(PATCH_FILES
23-
"${PATCH_FILES_DIRECTORY}/0005-Patch-tensorflow.patch"
24-
)
25-
iot_reference_arm_corstone3xx_apply_patches("${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/tensorflow/" "${PATCH_FILES}")

components/ai/ml_embedded_evaluation_kit/integration/cmake/ConvertAudioSourceToCode.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Copyright 2023-2024 Arm Limited and/or its affiliates
1+
# Copyright 2023-2025 Arm Limited and/or its affiliates
22
33
# SPDX-License-Identifier: MIT
44

55
# Convert audio clip to C file
66
function(iot_reference_arm_corstone3xx_convert_audio_source_to_code audio_path generated_path)
77
add_custom_target(convert-audio
88
BYPRODUCTS
9-
${generated_path}/InputFiles.cc
10-
${generated_path}/test.cc
9+
${generated_path}/sample_files.c
10+
${generated_path}/test.c
1111
# use ml-embedded-evaluation-kit's Python Virtual Environment which
1212
# contains dependencies for gen_audio_cpp.py
1313
COMMAND bash -c " \
1414
source ${CMAKE_CURRENT_BINARY_DIR}/mlek_resources_downloaded/env/bin/activate && \
15+
pip install --upgrade soundfile && \
1516
python3 ${ml_embedded_evaluation_kit_SOURCE_DIR}/scripts/py/gen_audio_cpp.py \
1617
--audio_path ${audio_path} \
17-
--source_folder_path ${generated_path} \
18-
--header_folder_path ${generated_path} "
18+
--package_gen_dir ${generated_path} "
1919
VERBATIM
2020
USES_TERMINAL
2121
)

components/ai/ml_embedded_evaluation_kit/integration/cmake/SetupMlEmbeddedEvaluationKitLibraries.cmake

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 Arm Limited and/or its affiliates
1+
# Copyright 2021-2025 Arm Limited and/or its affiliates
22
33
# SPDX-License-Identifier: MIT
44

@@ -8,8 +8,7 @@ include(ExternalProject)
88
# Setup for the ML target #
99
###########################
1010
#set(LOG_LEVEL LOG_LEVEL_TRACE)
11-
12-
set(CMSIS_VER 5)
11+
set(CMSIS_VER 6)
1312

1413
# External repositories
1514
set(CMSIS_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/cmsis-${CMSIS_VER}")
@@ -26,7 +25,7 @@ set(MLEK_RESOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}/mlek_resources_download
2625
set(ML_RESOURCES_SET_UP_ARGS
2726
"--additional-ethos-u-config-name=${ETHOSU_TARGET_NPU_CONFIG}"
2827
"--use-case-resources-file=${ML_USE_CASE_RESOURCES_FILE}"
29-
"--downloaded-model-resources-path=${MLEK_RESOURCES_DIR}"
28+
"--downloads-dir=${MLEK_RESOURCES_DIR}"
3029
)
3130

3231
# Tensorflow settings
@@ -77,7 +76,7 @@ function(assert_defined var_name)
7776
endif()
7877
endfunction()
7978

80-
include(${CMAKE_SCRIPTS_DIR}/tensorflow_lite_micro.cmake)
79+
add_library(cmsis_device INTERFACE)
8180

8281
# Manually add libs
8382
add_subdirectory(${ml_embedded_evaluation_kit_SOURCE_DIR}/source/log ${CMAKE_BINARY_DIR}/log)
@@ -91,13 +90,26 @@ add_subdirectory(${ml_embedded_evaluation_kit_SOURCE_DIR}/source/application/api
9190
if (ETHOS_U_NPU_ENABLED)
9291
add_subdirectory(${ml_embedded_evaluation_kit_SOURCE_DIR}/source/hal/source/components/npu ${CMAKE_BINARY_DIR}/npu)
9392
# ethos_u_npu library needs the CPU Header (CMSIS_device_header)
93+
target_include_directories(ethos_u_npu PUBLIC ${ml_embedded_evaluation_kit_SOURCE_DIR}/source/hal/source/components/cmsis_device/include)
9494
target_link_libraries(ethos_u_npu PUBLIC arm-corstone-platform-bsp)
9595
endif()
9696

97+
include(${CMAKE_SCRIPTS_DIR}/tensorflow_lite_micro.cmake)
98+
target_include_directories(tflu PRIVATE
99+
${TARGET_PLATFORM_PATH}/device/include
100+
${TARGET_PLATFORM_PATH}/partition
101+
)
102+
target_compile_definitions(tflu PRIVATE
103+
CMSIS_DEVICE_ARM_CORTEX_M_XX_HEADER_FILE=CMSIS_device_header
104+
)
105+
target_compile_options(tflu PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
106+
target_link_libraries(tflu PRIVATE arm-corstone-platform-bsp)
107+
108+
97109
# Add the dependency on tensorflow_build (defined in tensorflow.cmake)
98-
add_dependencies(common_api tensorflow_build)
110+
add_dependencies(common_api tflu)
99111
target_include_directories(common_api PUBLIC ${TFLITE_MICRO_PATH})
100-
target_compile_options(common_api PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-std=c++14>)
112+
target_compile_options(common_api PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
101113

102114
# Add relevant use case API
103115
add_subdirectory(${ml_embedded_evaluation_kit_SOURCE_DIR}/source/application/api/use_case/${ML_USE_CASE} ${CMAKE_BINARY_DIR}/${ML_USE_CASE}_api)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 1a047cff83badc2f6a95e3e78af735abef51ef8a Mon Sep 17 00:00:00 2001
1+
From 8ea782b063ffe69cbce26655af66382fe797378b Mon Sep 17 00:00:00 2001
22
From: Ahmed Ismail <[email protected]>
3-
Date: Thu, 28 Nov 2024 16:14:38 +0000
4-
Subject: [PATCH 4/4] Override EthosU55 NPU default IRQ handler
3+
Date: Mon, 7 Jul 2025 12:43:51 +0100
4+
Subject: [PATCH] Override EthosU55 NPU default IRQ handler
55

66
This change is done to avoid modifying the
77
vector table by setting the Ethos U55 IRQ handler
@@ -24,7 +24,7 @@ Signed-off-by: Ahmed Ismail <[email protected]>
2424
2 files changed, 4 insertions(+), 4 deletions(-)
2525

2626
diff --git a/source/hal/source/components/npu/ethosu_npu_init.c b/source/hal/source/components/npu/ethosu_npu_init.c
27-
index 2cbdb1e..1c8b4f6 100644
27+
index 8b74e93..c17a443 100644
2828
--- a/source/hal/source/components/npu/ethosu_npu_init.c
2929
+++ b/source/hal/source/components/npu/ethosu_npu_init.c
3030
@@ -71,20 +71,20 @@ static void arm_ethosu_npu_irq_init(void)

components/ai/ml_embedded_evaluation_kit/integration/patches/0001-User-defined-resources-download-path.patch

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)