From c5d8bda3c6f743ec2725bf281874d4b6431122c3 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Wed, 21 Jul 2021 10:35:08 +0100 Subject: MLECO-1982: Update to using latest ethos-u embedded components Change-Id: I744a4eb2553207004c9403b956e5bd9e9b352bfb Signed-off-by: Isabella Gottardi --- Readme.md | 10 +++--- dependencies/cmsis | 2 +- dependencies/core-driver | 2 +- dependencies/core-software | 2 +- docs/documentation.md | 2 +- docs/quick_start.md | 2 +- docs/use_cases/ad.md | 1 - docs/use_cases/asr.md | 1 - docs/use_cases/kws.md | 1 - docs/use_cases/kws_asr.md | 1 - download_dependencies.py | 14 ++++---- release_notes.txt | 23 +++++++----- scripts/cmake/toolchains/bare-metal-armclang.cmake | 2 +- scripts/make/cortex_m_ethos_eval_makefile.inc | 20 ++++++----- .../bare-metal/bsp/bsp-packs/mps3/uart_stdout.c | 4 +++ .../bsp/bsp-packs/simple_platform/uart_pl011.c | 8 +++-- .../platforms/bare-metal/timer/baremetal_timer.c | 41 ++++++++++------------ 17 files changed, 74 insertions(+), 62 deletions(-) diff --git a/Readme.md b/Readme.md index 332a51c..63efa70 100644 --- a/Readme.md +++ b/Readme.md @@ -27,11 +27,11 @@ The example application at your disposal and the utilized models are listed in t | ML application | Description | Neural Network Model | | :----------------------------------: | :-----------------------------------------------------: | :----: | -| [Image classification](./docs/use_cases/img_class.md) | Recognize the presence of objects in a given image | [Mobilenet V2](https://github.com/ARM-software/ML-zoo/tree/master/models/image_classification/mobilenet_v2_1.0_224/tflite_int8) | -| [Keyword spotting(KWS)](./docs/use_cases/kws.md) | Recognize the presence of a key word in a recording | [DS-CNN-L](https://github.com/ARM-software/ML-zoo/blob/master/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8) | -| [Automated Speech Recognition(ASR)](./docs/use_cases/asr.md) | Transcribe words in a recording | [Wav2Letter](https://github.com/ARM-software/ML-zoo/blob/master/models/speech_recognition/wav2letter/tflite_int8) | -| [KWS and ASR](./docs/use_cases/kws_asr.md) | Utilise Cortex-M and Ethos-U to transcribe words in a recording after a keyword was spotted | [DS-CNN-L](https://github.com/ARM-software/ML-zoo/blob/master/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8) [Wav2Letter](https://github.com/ARM-software/ML-zoo/blob/master/models/speech_recognition/wav2letter/tflite_int8) | -| [Anomaly Detection](./docs/use_cases/ad.md) | Detecting abnormal behavior based on a sound recording of a machine | [Anomaly Detection](https://github.com/ARM-software/ML-zoo/raw/7c32b097f7d94aae2cd0b98a8ed5a3ba81e66b18/models/anomaly_detection/micronet_medium/tflite_int8/ad_medium_int8.tflite)| +| [Image classification](./docs/use_cases/img_class.md) | Recognize the presence of objects in a given image | [Mobilenet V2](https://github.com/ARM-software/ML-zoo/tree/e0aa361b03c738047b9147d1a50e3f2dcb13dbcb/models/image_classification/mobilenet_v2_1.0_224/tflite_int8) | +| [Keyword spotting(KWS)](./docs/use_cases/kws.md) | Recognize the presence of a key word in a recording | [DS-CNN-L](https://github.com/ARM-software/ML-zoo/tree/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8) | +| [Automated Speech Recognition(ASR)](./docs/use_cases/asr.md) | Transcribe words in a recording | [Wav2Letter](https://github.com/ARM-software/ML-zoo/tree/1a92aa08c0de49a7304e0a7f3f59df6f4fd33ac8/models/speech_recognition/wav2letter/tflite_int8) | +| [KWS and ASR](./docs/use_cases/kws_asr.md) | Utilise Cortex-M and Ethos-U to transcribe words in a recording after a keyword was spotted | [DS-CNN-L](https://github.com/ARM-software/ML-zoo/tree/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8) [Wav2Letter](https://github.com/ARM-software/ML-zoo/tree/1a92aa08c0de49a7304e0a7f3f59df6f4fd33ac8/models/speech_recognition/wav2letter/tflite_int8) | +| [Anomaly Detection](./docs/use_cases/ad.md) | Detecting abnormal behavior based on a sound recording of a machine | [Anomaly Detection](https://github.com/ARM-software/ML-zoo/tree/7c32b097f7d94aae2cd0b98a8ed5a3ba81e66b18/models/anomaly_detection/micronet_medium/tflite_int8/)| | [Generic inference runner](./docs/use_cases/inference_runner.md) | Code block allowing you to develop your own use case for Ethos-U NPU | Your custom model | The above use cases implement end-to-end ML flow including data pre-processing and post-processing. They will allow you diff --git a/dependencies/cmsis b/dependencies/cmsis index 0d7e4fa..e9637de 160000 --- a/dependencies/cmsis +++ b/dependencies/cmsis @@ -1 +1 @@ -Subproject commit 0d7e4fa7131241a17e23dfae18140e0b2e77728f +Subproject commit e9637de2b4cfd99cd5c93893d88593262d8660c1 diff --git a/dependencies/core-driver b/dependencies/core-driver index effc7aa..d1ea036 160000 --- a/dependencies/core-driver +++ b/dependencies/core-driver @@ -1 +1 @@ -Subproject commit effc7aa8b9272fb20cdd1a7d1097818af70acc93 +Subproject commit d1ea036bd870663d737db9bfbb25e2aa04a389e0 diff --git a/dependencies/core-software b/dependencies/core-software index 7f3c1c9..8b1d9de 160000 --- a/dependencies/core-software +++ b/dependencies/core-software @@ -1 +1 @@ -Subproject commit 7f3c1c92732b611a53968b14e70a2b116e43b980 +Subproject commit 8b1d9ded33ec59545897ff45019d05403dba7eee diff --git a/docs/documentation.md b/docs/documentation.md index c1b1f3b..b9b0f91 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -33,7 +33,7 @@ Before starting the setup process, please make sure that you have: - At least one of the following toolchains: - GNU Arm Embedded toolchain (version 10.2.1 or above) - [GNU Arm Embedded toolchain downloads](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - - Arm Compiler (version 6.14 or above) with a valid license - + - Arm Compiler (version 6.15 or above) with a valid license - [Arm Compiler download Page](https://developer.arm.com/tools-and-software/embedded/arm-compiler/downloads/) - An ArmĀ® MPS3 FPGA prototyping board and components for FPGA evaluation or a `Fixed Virtual Platform` binary: diff --git a/docs/quick_start.md b/docs/quick_start.md index 878bdcf..ff260e1 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -143,7 +143,7 @@ mv resources_downloaded/inference_runner/dnn_s_quantized_vela.tflite resources_d --memory-mode=Shared_Sram \ --system-config=Ethos_U55_High_End_Embedded \ --output-dir=resources_downloaded/img_class -mv resources_downloaded/img_class/mobilenet_v2_1.0_224_INT8.tflite_vela.tflite resources_downloaded/img_class/mobilenet_v2_1.0_224_INT8.tflite_vela_H128.tflite +mv resources_downloaded/img_class/mobilenet_v2_1.0_224_INT8_vela.tflite resources_downloaded/img_class/mobilenet_v2_1.0_224_INT8_vela_H128.tflite . resources_downloaded/env/bin/activate && vela resources_downloaded/asr/wav2letter_int8.tflite \ --accelerator-config=ethos-u55-128 \ diff --git a/docs/use_cases/ad.md b/docs/use_cases/ad.md index a8476bd..84a601c 100644 --- a/docs/use_cases/ad.md +++ b/docs/use_cases/ad.md @@ -335,7 +335,6 @@ What the preceding choices do: 4. Show NN model info: Prints information about the model data type, input, and output, tensor sizes: ```log - INFO - uTFL version: 2.5.0 INFO - Model info: INFO - Model INPUT tensors: INFO - tensor type is INT8 diff --git a/docs/use_cases/asr.md b/docs/use_cases/asr.md index 134a706..9863ce6 100644 --- a/docs/use_cases/asr.md +++ b/docs/use_cases/asr.md @@ -398,7 +398,6 @@ What the preceding choices do: 4. Show NN model info: Prints information about the model data type, input, and output, tensor sizes: ```log - INFO - uTFL version: 2.5.0 INFO - Model info: INFO - Model INPUT tensors: INFO - tensor type is INT8 diff --git a/docs/use_cases/kws.md b/docs/use_cases/kws.md index 13ce7c3..d490f2b 100644 --- a/docs/use_cases/kws.md +++ b/docs/use_cases/kws.md @@ -365,7 +365,6 @@ What the preceding choices do: 4. Show NN model info: Prints information about the model data type, input, and output, tensor sizes: ```log - INFO - uTFL version: 2.5.0 INFO - Model info: INFO - Model INPUT tensors: INFO - tensor type is INT8 diff --git a/docs/use_cases/kws_asr.md b/docs/use_cases/kws_asr.md index 8d7b396..80e5265 100644 --- a/docs/use_cases/kws_asr.md +++ b/docs/use_cases/kws_asr.md @@ -456,7 +456,6 @@ What the preceding choices do: 4. Show NN model info: Prints information about the model data type, input, and output, tensor sizes: ```log - INFO - uTFL version: 2.5.0 INFO - Model INPUT tensors: INFO - tensor type is INT8 INFO - tensor occupies 490 bytes with dimensions diff --git a/download_dependencies.py b/download_dependencies.py index b22c63f..9d2e6fa 100755 --- a/download_dependencies.py +++ b/download_dependencies.py @@ -25,13 +25,10 @@ import tempfile from urllib.request import urlopen from zipfile import ZipFile -logging.basicConfig(filename='download_dependencies.log', level=logging.DEBUG) -logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) - -tf = "https://github.com/tensorflow/tensorflow/archive/6cff09aee1f832d495b3cae40cab0de58155a0af.zip" -cmsis = "https://github.com/ARM-software/CMSIS_5/archive/0d7e4fa7131241a17e23dfae18140e0b2e77728f.zip" -ethos_u_core_sw = "https://git.mlplatform.org/ml/ethos-u/ethos-u-core-software.git/snapshot/ethos-u-core-software-7f3c1c92732b611a53968b14e70a2b116e43b980.tar.gz" -ethos_u_core_driver = "https://git.mlplatform.org/ml/ethos-u/ethos-u-core-driver.git/snapshot/ethos-u-core-driver-effc7aa8b9272fb20cdd1a7d1097818af70acc93.tar.gz" +tf = "https://github.com/tensorflow/tflite-micro/archive/f510d38d0eaa3195ce3af66e3f32648740f08afb.zip" +cmsis = "https://github.com/ARM-software/CMSIS_5/archive/e9637de2b4cfd99cd5c93893d88593262d8660c1.zip" +ethos_u_core_sw = "https://git.mlplatform.org/ml/ethos-u/ethos-u-core-software.git/snapshot/ethos-u-core-software-8b1d9ded33ec59545897ff45019d05403dba7eee.tar.gz" +ethos_u_core_driver = "https://git.mlplatform.org/ml/ethos-u/ethos-u-core-driver.git/snapshot/ethos-u-core-driver-d1ea036bd870663d737db9bfbb25e2aa04a389e0.tar.gz" def download(url_file: str, post_process=None): @@ -84,6 +81,9 @@ def main(dependencies_path: str): if __name__ == '__main__': + logging.basicConfig(filename='download_dependencies.log', level=logging.DEBUG) + logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) + download_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "dependencies")) if os.path.isdir(download_dir): diff --git a/release_notes.txt b/release_notes.txt index 1b2ced7..62618a5 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,17 +1,24 @@ +Changes in 21.08 + * Support for 21.05 Ethos-U component (core-software, core-driver, Vela 3.0.0). + * TensorFlow submodule changed to https://github.com/tensorflow/tflite-micro (tested with TensorFlow Lite Micro commit hash: f510d38d0eaa3195ce3af66e3f32648740f08afb). + * Image classification model changed (from uint8 to int8 datatype). + * Documentation updates, added support to Corstone-300 + Ethos-U65. + * Various scripts improvements. + Changes in 21.05 * Added script to download and optimize default models. * Added script to run default build flow. * Added a model for Anomaly Detection use case. - * added support for build with Arm GNU Embedded Toolchain (10.2.1). - * deprecated support for target subsystem SSE-200. + * Added support for build with Arm GNU Embedded Toolchain (10.2.1). + * Deprecated support for target subsystem SSE-200. Changes in 21.03 - * simple platform support added. - * model conditioning examples added. - * documentation updated. - * build changed to use sources of the dependency libraries. - * tests for native platform added. - * anomaly detection use case added. + * Simple platform support added. + * Model conditioning examples added. + * Documentation updated. + * Build changed to use sources of the dependency libraries. + * Tests for native platform added. + * Anomaly detection use-case added. Changes in 20.11 * SSE-200 and SSE-300 system support was added. diff --git a/scripts/cmake/toolchains/bare-metal-armclang.cmake b/scripts/cmake/toolchains/bare-metal-armclang.cmake index 0a86eb6..d07aa9e 100644 --- a/scripts/cmake/toolchains/bare-metal-armclang.cmake +++ b/scripts/cmake/toolchains/bare-metal-armclang.cmake @@ -25,7 +25,7 @@ set(CMAKE_ASM_COMPILER_AR armar) set(CMAKE_CROSSCOMPILING true) set(CMAKE_SYSTEM_NAME Generic) -set(MIN_ARM_CLANG_VERSION 6.14) +set(MIN_ARM_CLANG_VERSION 6.15) # Skip compiler test execution set(CMAKE_C_COMPILER_WORKS 1) diff --git a/scripts/make/cortex_m_ethos_eval_makefile.inc b/scripts/make/cortex_m_ethos_eval_makefile.inc index dbb460d..407bc85 100644 --- a/scripts/make/cortex_m_ethos_eval_makefile.inc +++ b/scripts/make/cortex_m_ethos_eval_makefile.inc @@ -117,12 +117,6 @@ ifeq ($(TARGET),$(filter $(TARGET), cortex_m_ethos_eval)) MICROLITE_LIBS := $(filter-out -lm,$(MICROLITE_LIBS)) else ifeq ($(TOOLCHAIN), gcc) - export PATH := $(MAKEFILE_DIR)/downloads/gcc_embedded/bin/:$(PATH) - DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/arm_gcc_download.sh ${MAKEFILE_DIR}/downloads) - ifneq ($(DOWNLOAD_RESULT), SUCCESS) - $(error Something went wrong with the GCC download: $(DOWNLOAD_RESULT)) - endif - TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- FLAGS_GCC = -mcpu=$(GCC_TARGET_ARCH) -mfpu=auto @@ -133,6 +127,16 @@ ifeq ($(TARGET),$(filter $(TARGET), cortex_m_ethos_eval)) $(error "TOOLCHAIN=$(TOOLCHAIN) is not supported.") endif +# TODO(#47718): resolve warnings. +CXX_OMIT_ERRORS = \ + -Wno-implicit-fallthrough \ + -Wno-unused-variable + +# TODO: Remove when Arm Ethos-U NPU driver is updated to version > 21.05 +CC_OMIT_ERRORS = \ + ${CXX_OMIT_ERRORS} \ + -Wno-int-conversion + PLATFORM_FLAGS = \ -DTF_LITE_MCU_DEBUG_LOG \ -mthumb \ @@ -147,7 +151,7 @@ ifeq ($(TARGET),$(filter $(TARGET), cortex_m_ethos_eval)) $(TARGET_SPECIFIC_FLAGS) # Common + C/C++ flags - CXXFLAGS += $(PLATFORM_FLAGS) - CCFLAGS += $(PLATFORM_FLAGS) + CXXFLAGS += $(PLATFORM_FLAGS) ${CXX_OMIT_ERRORS} + CCFLAGS += $(PLATFORM_FLAGS) ${CC_OMIT_ERRORS} endif diff --git a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/mps3/uart_stdout.c b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/mps3/uart_stdout.c index ed12c8b..3211c4d 100644 --- a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/mps3/uart_stdout.c +++ b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/mps3/uart_stdout.c @@ -111,6 +111,10 @@ bool GetLine(char *lp, unsigned int len) lp++; /* Increment line pointer */ cnt++; /* and count. */ c = LF; + UartPutc (*lp = c); /* Echo and store character. */ + fflush (stdout); + lp++; /* Increment line pointer */ + cnt++; /* and count. */ break; default: UartPutc (*lp = c); /* Echo and store character. */ diff --git a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/uart_pl011.c b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/uart_pl011.c index b2dee14..1cbf70c 100644 --- a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/uart_pl011.c +++ b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/uart_pl011.c @@ -199,11 +199,15 @@ bool GetLine (char *lp, unsigned int len) case 0: *lp = 0; /* ESC - stop editing line. */ return false; - case CR: /* CR - done, stop editing line. */ + case CR: /* CR - done, stop editing line. */ + UartPutc (*lp = c); /* Echo and store character. */ + lp++; /* Increment line pointer */ + cnt++; /* and count. */ + c = LF; UartPutc (*lp = c); /* Echo and store character. */ + fflush (stdout); lp++; /* Increment line pointer */ cnt++; /* and count. */ - c = LF; break; default: UartPutc (*lp = c); /* echo and store character. */ diff --git a/source/application/hal/platforms/bare-metal/timer/baremetal_timer.c b/source/application/hal/platforms/bare-metal/timer/baremetal_timer.c index 00028bd..c8e7252 100644 --- a/source/application/hal/platforms/bare-metal/timer/baremetal_timer.c +++ b/source/application/hal/platforms/bare-metal/timer/baremetal_timer.c @@ -25,6 +25,8 @@ #include "pmu_ethosu.h" +extern struct ethosu_driver ethosu_drv; /* Default Ethos-U55 device driver */ + /** * @brief Initialises the PMU and enables the cycle counter. **/ @@ -183,30 +185,25 @@ void init_timer(platform_timer *timer) } #if defined (ARM_NPU) - -static void _reset_ethosu_counters(void) +static void _reset_ethosu_counters() { /* Reset all cycle and event counters. */ - ETHOSU_PMU_CYCCNT_Reset(); - ETHOSU_PMU_EVCNTR_ALL_Reset(); + ETHOSU_PMU_CYCCNT_Reset(ðosu_drv); + ETHOSU_PMU_EVCNTR_ALL_Reset(ðosu_drv); } - -static void _init_ethosu_cyclecounter(void) +static void _init_ethosu_cyclecounter() { /* Reset overflow status. */ - ETHOSU_PMU_Set_CNTR_OVS(ETHOSU_PMU_CNT1_Msk | ETHOSU_PMU_CCNT_Msk); - + ETHOSU_PMU_Set_CNTR_OVS(ðosu_drv, ETHOSU_PMU_CNT1_Msk | ETHOSU_PMU_CCNT_Msk); /* We can retrieve only 4 PMU counters: */ - ETHOSU_PMU_Set_EVTYPER(0, ETHOSU_PMU_NPU_IDLE); - ETHOSU_PMU_Set_EVTYPER(1, ETHOSU_PMU_AXI0_RD_DATA_BEAT_RECEIVED); - ETHOSU_PMU_Set_EVTYPER(2, ETHOSU_PMU_AXI0_WR_DATA_BEAT_WRITTEN); - ETHOSU_PMU_Set_EVTYPER(3, ETHOSU_PMU_AXI1_RD_DATA_BEAT_RECEIVED); - + ETHOSU_PMU_Set_EVTYPER(ðosu_drv, 0, ETHOSU_PMU_NPU_IDLE); + ETHOSU_PMU_Set_EVTYPER(ðosu_drv, 1, ETHOSU_PMU_AXI0_RD_DATA_BEAT_RECEIVED); + ETHOSU_PMU_Set_EVTYPER(ðosu_drv, 2, ETHOSU_PMU_AXI0_WR_DATA_BEAT_WRITTEN); + ETHOSU_PMU_Set_EVTYPER(ðosu_drv, 3, ETHOSU_PMU_AXI1_RD_DATA_BEAT_RECEIVED); /* Enable PMU. */ - ETHOSU_PMU_Enable(); - + ETHOSU_PMU_Enable(ðosu_drv); /* Enable counters for cycle and counter# 0. */ - ETHOSU_PMU_CNTR_Enable(ETHOSU_PMU_CNT1_Msk | ETHOSU_PMU_CNT2_Msk | ETHOSU_PMU_CNT3_Msk | ETHOSU_PMU_CNT4_Msk| ETHOSU_PMU_CCNT_Msk); + ETHOSU_PMU_CNTR_Enable(ðosu_drv, ETHOSU_PMU_CNT1_Msk | ETHOSU_PMU_CNT2_Msk | ETHOSU_PMU_CNT3_Msk | ETHOSU_PMU_CNT4_Msk| ETHOSU_PMU_CCNT_Msk); _reset_ethosu_counters(); } @@ -235,7 +232,7 @@ static uint32_t counter_overflow(uint32_t pmu_counter_mask) { /* Check for overflow: The idle counter is 32 bit while the total cycle count is 64 bit. */ - const uint32_t overflow_status = ETHOSU_PMU_Get_CNTR_OVS(); + const uint32_t overflow_status = ETHOSU_PMU_Get_CNTR_OVS(ðosu_drv); return pmu_counter_mask & overflow_status; } @@ -298,11 +295,11 @@ static time_counter bm_get_time_counter(void) .counter = get_time_counter(), #if defined (ARM_NPU) - .npu_total_ccnt = ETHOSU_PMU_Get_CCNTR(), - .npu_idle_ccnt = ETHOSU_PMU_Get_EVCNTR(0), - .npu_axi0_read_beats = ETHOSU_PMU_Get_EVCNTR(1), - .npu_axi0_write_beats = ETHOSU_PMU_Get_EVCNTR(2), - .npu_axi1_read_beats = ETHOSU_PMU_Get_EVCNTR(3) + .npu_total_ccnt = ETHOSU_PMU_Get_CCNTR(ðosu_drv), + .npu_idle_ccnt = ETHOSU_PMU_Get_EVCNTR(ðosu_drv, 0), + .npu_axi0_read_beats = ETHOSU_PMU_Get_EVCNTR(ðosu_drv, 1), + .npu_axi0_write_beats = ETHOSU_PMU_Get_EVCNTR(ðosu_drv, 2), + .npu_axi1_read_beats = ETHOSU_PMU_Get_EVCNTR(ðosu_drv, 3) #endif /* defined (ARM_NPU) */ }; -- cgit v1.2.1