Skip to content

Commit bdfed16

Browse files
gergelykarmurutva
authored andcommitted
component: Update MLEK
Signed-off-by: Gergely Korcsák <[email protected]>
1 parent c2d9ce2 commit bdfed16

File tree

11 files changed

+113
-47
lines changed

11 files changed

+113
-47
lines changed

applications/keyword_detection/ml_interface.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,6 @@ static int prvMlInterfaceInit()
10531053

10541054
caseContext.Set<const std::vector<std::string> &>( "labels", labels );
10551055

1056-
PrintTensorFlowVersion();
10571056
LogInfo( ( "*** ML interface initialised\r\n" ) );
10581057
return 0;
10591058
}

applications/object_detection/ml_interface.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ static int prvMlInterfaceInit( void )
487487
/* Instantiate application context. */
488488
xCaseContext.Set<arm::app::Model &>( "model", xModel );
489489

490-
PrintTensorFlowVersion();
491490
LogInfo( ( "*** ML interface initialised\r\n" ) );
492491
return 0;
493492
}

applications/speech_recognition/ml_interface.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ static int prvMlInterfaceInit( void )
579579
caseContext.Set<const std::vector<std::string> &>( "labels", labels );
580580
caseContext.Set<arm::app::AsrClassifier &>( "classifier", classifier );
581581

582-
PrintTensorFlowVersion();
583582
LogInfo( ( "*** ML interface initialised\r\n" ) );
584583
return 0;
585584
}

components/ai/ml_embedded_evaluation_kit/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ set(PATCH_FILES_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/integration/patches")
1414
set(PATCH_FILES
1515
"${PATCH_FILES_DIRECTORY}/0001-User-defined-resources-download-path.patch"
1616
"${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"
1718
)
1819
iot_reference_arm_corstone3xx_apply_patches("${ml_embedded_evaluation_kit_SOURCE_DIR}" "${PATCH_FILES}")
20+
21+
set(PATCH_FILES
22+
"${PATCH_FILES_DIRECTORY}/0004-Patch-tensorflow.patch"
23+
)
24+
iot_reference_arm_corstone3xx_apply_patches("${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/tensorflow/" "${PATCH_FILES}")

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ include(ExternalProject)
99
###########################
1010
#set(LOG_LEVEL LOG_LEVEL_TRACE)
1111

12+
set(CMSIS_VER 5)
13+
1214
# External repositories
13-
set(CMSIS_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/cmsis")
15+
set(CMSIS_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/cmsis-${CMSIS_VER}")
1416
set(CMSIS_DSP_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/cmsis-dsp")
1517
set(CMSIS_DSP_INC_DIR "${CMSIS_DSP_SRC_PATH}/Include")
16-
set(CMSIS_CORE_INC_DIR "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/CMSIS/Core/Include")
18+
set(CMSIS_CORE_INC_DIR "${CMSIS_SRC_PATH}/CMSIS/Core/Include")
1719
set(CMSIS_NN_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/cmsis-nn")
1820
set(TENSORFLOW_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/tensorflow")
1921
set(ETHOS_U_NPU_DRIVER_SRC_PATH "${ml_embedded_evaluation_kit_SOURCE_DIR}/dependencies/core-driver")

components/ai/ml_embedded_evaluation_kit/integration/cmake/model/GenerateObjectDetectionModel.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(OBJECT_DETECTION_IMAGE_SIZE 192)
2020
set(OBJECT_DETECTION_ANCHOR_1 "{38, 77, 47, 97, 61, 126}")
2121
set(OBJECT_DETECTION_ANCHOR_2 "{14, 26, 19, 37, 28, 55 }")
2222
set(OBJECT_DETECTION_ORIGINAL_IMAGE_SIZE ${OBJECT_DETECTION_IMAGE_SIZE})
23-
set(OBJECT_DETECTION_ACTIVATION_BUF_SZ 0x00082000)
23+
set(OBJECT_DETECTION_ACTIVATION_BUF_SZ 0x00182000)
2424

2525
if (ETHOS_U_NPU_ENABLED)
2626
set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/yolo-fastest_192_face_v4_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)

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

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,92 +14,89 @@ Signed-off-by: Ahmed Ismail <[email protected]>
1414
1 file changed, 14 insertions(+), 7 deletions(-)
1515

1616
diff --git a/set_up_default_resources.py b/set_up_default_resources.py
17-
index bf3aba3..efc8621 100755
17+
index 2ce972a..85c02ea 100755
1818
--- a/set_up_default_resources.py
1919
+++ b/set_up_default_resources.py
20-
@@ -121,6 +121,7 @@ class SetupArgs:
20+
@@ -157,12 +157,14 @@ class PathsConfig:
2121
installed.
22-
use_case_resources_file (str) : Path to a JSON file containing the use case
22+
use_case_resources_file (Path) : Path to a JSON file containing the use case
2323
metadata resources.
2424
+ downloaded_model_resources_path (str): Path to store model resources files.
25+
26+
downloads_dir (Path) : Path to store model resources files.
2527
"""
26-
run_vela_on_models: bool = False
27-
additional_npu_config_names: typing.List[str] = ()
28-
@@ -129,6 +130,7 @@ class SetupArgs:
29-
check_clean_folder: bool = False
3028
additional_requirements_file: Path = ""
3129
use_case_resources_file: Path = ""
30+
downloads_dir: Path = ""
3231
+ downloaded_model_resources_path: Path = ""
3332

3433

3534
def load_use_case_resources(
36-
@@ -646,8 +648,7 @@ def set_up_resources(args: SetupArgs) -> Path:
35+
@@ -678,7 +680,7 @@ def set_up_resources(setup_config: SetupConfig, paths_config: PathsConfig) -> Pa
3736
"""
3837
# Paths.
39-
current_file_dir = Path(__file__).parent.resolve()
40-
- download_dir = current_file_dir / "resources_downloaded"
41-
- metadata_file_path = download_dir / "resources_downloaded_metadata.json"
42-
+ metadata_file_path = args.downloaded_model_resources_path / "resources_downloaded_metadata.json"
38+
check_paths_config(paths_config)
39+
- metadata_file_path = paths_config.downloads_dir / "resources_downloaded_metadata.json"
40+
+ metadata_file_path = paths_config.downloaded_model_resources_path / "resources_downloaded_metadata.json"
4341

4442
# Is Python minimum requirement matched?
4543
if sys.version_info < py3_version_minimum:
46-
@@ -664,14 +665,14 @@ def set_up_resources(args: SetupArgs) -> Path:
44+
@@ -695,14 +697,14 @@ def set_up_resources(setup_config: SetupConfig, paths_config: PathsConfig) -> Pa
4745
setup_script_hash = get_md5sum_for_file(Path(__file__).resolve())
4846

4947
metadata_dict, setup_script_hash_verified = initialize_resources_directory(
50-
- download_dir,
51-
+ args.downloaded_model_resources_path,
52-
args.check_clean_folder,
48+
- paths_config.downloads_dir,
49+
+ paths_config.downloaded_model_resources_path,
50+
setup_config.check_clean_folder,
5351
metadata_file_path,
5452
setup_script_hash
5553
)
5654

5755
env_path, env_activate = set_up_python_venv(
58-
- download_dir,
59-
+ args.downloaded_model_resources_path,
60-
args.additional_requirements_file
56+
- paths_config.downloads_dir,
57+
+ paths_config.downloaded_model_resources_path,
58+
paths_config.additional_requirements_file
6159
)
6260

63-
@@ -681,7 +682,7 @@ def set_up_resources(args: SetupArgs) -> Path:
61+
@@ -712,7 +714,7 @@ def set_up_resources(setup_config: SetupConfig, paths_config: PathsConfig) -> Pa
6462
download_resources(
6563
use_case,
6664
metadata_dict,
67-
- download_dir,
68-
+ args.downloaded_model_resources_path,
69-
args.check_clean_folder,
65+
- paths_config.downloads_dir,
66+
+ paths_config.downloaded_model_resources_path,
67+
setup_config.check_clean_folder,
7068
setup_script_hash_verified
7169
)
72-
@@ -698,7 +699,7 @@ def set_up_resources(args: SetupArgs) -> Path:
70+
@@ -728,7 +730,7 @@ def set_up_resources(setup_config: SetupConfig, paths_config: PathsConfig) -> Pa
71+
if setup_config.run_vela_on_models is True:
7372
# Consolidate all config names while discarding duplicates:
7473
run_vela_on_all_models(
75-
current_file_dir,
76-
- download_dir,
77-
+ args.downloaded_model_resources_path,
74+
- paths_config.downloads_dir,
75+
+ paths_config.downloaded_model_resources_path,
7876
env_activate,
79-
args.arena_cache_size,
77+
setup_config.arena_cache_size,
8078
npu_config_names=list(
81-
@@ -763,7 +764,12 @@ if __name__ == "__main__":
82-
type=str,
83-
default=default_use_case_resources_path
79+
@@ -799,6 +801,12 @@ if __name__ == "__main__":
80+
type=Path,
81+
default=default_downloads_path
8482
)
85-
-
8683
+ parser.add_argument(
87-
+ "--downloaded-model-resources-path",
84+
+ "--downloaded-model-resources-path",
8885
+ help="Path to downloaded model resources",
8986
+ type=Path,
9087
+ default=Path(__file__).parent.resolve() / 'resources_downloaded'
9188
+ )
89+
9290
parsed_args = parser.parse_args()
9391

94-
if parsed_args.arena_cache_size < 0:
95-
@@ -783,6 +789,7 @@ if __name__ == "__main__":
96-
check_clean_folder=parsed_args.clean,
97-
additional_requirements_file=parsed_args.requirements_file,
92+
@@ -823,6 +831,7 @@ if __name__ == "__main__":
9893
use_case_resources_file=parsed_args.use_case_resources_file,
99-
+ downloaded_model_resources_path= parsed_args.downloaded_model_resources_path,
94+
downloads_dir=parsed_args.downloads_dir,
95+
additional_requirements_file=parsed_args.requirements_file,
96+
+ downloaded_model_resources_path=parsed_args.downloaded_model_resources_path,
10097
)
10198

102-
set_up_resources(setup_args)
99+
set_up_resources(setup, paths)
103100
--
104101
2.34.1
105102

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From c5c0bdff764cde7db2c97761a5eff15f55a09dbb Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Gergely=20Korcs=C3=A1k?= <[email protected]>
3+
Date: Thu, 8 Aug 2024 17:47:54 +0200
4+
Subject: [PATCH] Make ETHOSU_ARCH configurable in TensorFlow CMake
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Signed-off-by: Gergely Korcsák <[email protected]>
10+
---
11+
scripts/cmake/tensorflow_lite_micro.cmake | 6 +-----
12+
1 file changed, 1 insertion(+), 5 deletions(-)
13+
14+
diff --git a/scripts/cmake/tensorflow_lite_micro.cmake b/scripts/cmake/tensorflow_lite_micro.cmake
15+
index 4a988aa..1640626 100644
16+
--- a/scripts/cmake/tensorflow_lite_micro.cmake
17+
+++ b/scripts/cmake/tensorflow_lite_micro.cmake
18+
@@ -75,11 +75,7 @@ else()
19+
if(ETHOS_U_NPU_ENABLED)
20+
# Arm Ethos-U55 NPU is the co-processor for ML workload:
21+
set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR "ethos_u")
22+
- if(${ETHOS_U_NPU_ID} STREQUAL "U65")
23+
- set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR_ARCH "u65")
24+
- else()
25+
- set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR_ARCH "u55")
26+
- endif ()
27+
+ string(TOLOWER "${ETHOS_U_NPU_ID}" TENSORFLOW_LITE_MICRO_CO_PROCESSOR_ARCH)
28+
endif()
29+
30+
set(TENSORFLOW_LITE_MICRO_OPTIMIZED_KERNEL "cmsis_nn")
31+
--
32+
2.34.1
33+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 2352b60b03042fc9ea2d9cf9ce861d8e87341e32 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Gergely=20Korcs=C3=A1k?= <[email protected]>
3+
Date: Mon, 12 Aug 2024 15:43:48 +0200
4+
Subject: [PATCH] Patch tensorflow
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Signed-off-by: Gergely Korcsák <[email protected]>
10+
---
11+
tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc | 4 ++++
12+
1 file changed, 4 insertions(+)
13+
14+
diff --git a/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc b/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
15+
index c61aaff3..81066237 100644
16+
--- a/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
17+
+++ b/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
18+
@@ -64,6 +64,10 @@ else ifeq ($(ETHOSU_ARCH), u65)
19+
ETHOSU_FLAGS += \
20+
-DETHOSU_ARCH=u65 \
21+
-DETHOSU65
22+
+else ifeq ($(ETHOSU_ARCH), u85)
23+
+ ETHOSU_FLAGS += \
24+
+ -DETHOSU_ARCH=u85 \
25+
+ -DETHOSU85
26+
else
27+
$(error "ETHOSU_ARCH=$(ETHOSU_ARCH) is not supported")
28+
endif
29+
--
30+
2.34.1
31+
Submodule library updated from 325c916 to ddb3ffd

0 commit comments

Comments
 (0)