未验证 提交 b51e1a7a 编写于 作者: M Måns Nilsson 提交者: GitHub

Add armclang support for target based on Arm Corstone-300 software

Armclang need to use -ffp-mode=full because quantization unit test is
using NaN and without this use of NaN is undefined behavior.
Because of a compiler defect which only occurs with -ffp-mode=full a
workaround is done in the lstm unit test. The workaround prevents
implicit conversion from double to float. Since many of those
conversions would be inexact, the compiler would not consider those
conversions as constant expressions with -ffp-mode=full.

BUG=https://github.com/tensorflow/tflite-micro/issues/1305
上级 399b83cb
#include <cstdint>
#include "tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h"
#define FIXED_POINT 16
......
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -41,6 +41,7 @@ TF_LITE_MICRO_TEST(TestAudioProvider) {
for (int i = 0; i < audio_samples_size; ++i) {
total += audio_samples[i];
}
(void)total;
}
TF_LITE_MICRO_TEST(TestTimer) {
......
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -37,6 +37,7 @@ TF_LITE_MICRO_TEST(TestImageProvider) {
for (int i = 0; i < kMaxImageSize; ++i) {
total += image_data[i];
}
(void)total;
}
TF_LITE_MICRO_TESTS_END
#!/usr/bin/env bash
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -27,11 +27,14 @@ source tensorflow/lite/micro/tools/ci_build/helper_functions.sh
TARGET=cortex_m_corstone_300
TARGET_ARCH=cortex-m55
OPTIMIZED_KERNEL_DIR=cmsis_nn
TOOLCHAINS=(gcc armclang)
# TODO(b/143715361): downloading first to allow for parallel builds.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile CO_PROCESSOR=ethos_u OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} third_party_downloads
# Avoid running tests in parallel.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -j$(nproc) -f tensorflow/lite/micro/tools/make/Makefile CO_PROCESSOR=ethos_u OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} build
readable_run make -f tensorflow/lite/micro/tools/make/Makefile CO_PROCESSOR=ethos_u OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} test
for TOOLCHAIN in "${TOOLCHAINS[@]}"; do
# Avoid running tests in parallel.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -j$(nproc) -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=${TOOLCHAIN} CO_PROCESSOR=ethos_u OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} build
readable_run make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=${TOOLCHAIN} CO_PROCESSOR=ethos_u OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} test
done
......@@ -66,10 +66,6 @@ else
LINKER_PATH=${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH}/targets/corstone-300
# Prepend #!cpp to scatter file.
SCATTER=${LINKER_PATH}/platform.scatter
echo -e "#!cpp\n$(cat ${SCATTER})" > ${SCATTER}
# Run C preprocessor on linker file to get rid of ifdefs and make sure compiler is downloaded first.
COMPILER=${DOWNLOADS_DIR}/gcc_embedded/bin/arm-none-eabi-gcc
if [ ! -f ${COMPILER} ]; then
......@@ -79,22 +75,8 @@ else
exit 1
fi
fi
${COMPILER} -E -x c -P -o ${LINKER_PATH}/platform_parsed.ld ${LINKER_PATH}/platform.ld
# Patch retarget.c so that g++ can find exit symbol.
cat <<EOT >> ${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH}/targets/corstone-300/retarget.c
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
#else
void RETARGET(exit)(int return_code) {
RETARGET(_exit)(return_code);
while (1) {}
}
#endif
EOT
fi
echo "SUCCESS"
From 6cd950c461ea56af59c68b15682e3d1e94ce7db8 Mon Sep 17 00:00:00 2001
From: Hannes Mogensen <hannes.mogensen@arm.com>
Date: Wed, 25 May 2022 09:30:09 +0200
Subject: [PATCH] Increase stack size and and change memory allocation from
DTCM to SRAM
From 24a382db4fba684a9d6d320cb900eeac7b628837 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A5ns=20Nilsson?= <mans.nilsson@arm.com>
Date: Wed, 15 Jun 2022 14:00:36 +0200
Subject: [PATCH] TFLM patch
Change-Id: If414fb875c0bff4940bf072e466068284579e5f6
---
targets/corstone-300/platform.ld | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
targets/corstone-300/platform.ld | 8 +++-----
targets/corstone-300/platform.scatter | 5 +++--
targets/corstone-300/retarget.c | 8 ++++++++
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/targets/corstone-300/platform.ld b/targets/corstone-300/platform.ld
index ec58acc..21316a4 100644
......@@ -16,11 +16,11 @@ index ec58acc..21316a4 100644
@@ -75,7 +75,7 @@
#define ETHOSU_ARENA 1
#endif
-__STACK_SIZE = 0x00008000;
+__STACK_SIZE = 0x00030000;
__HEAP_SIZE = 0x00008000;
MEMORY
@@ -150,9 +150,6 @@ SECTIONS
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
......@@ -31,14 +31,14 @@ index ec58acc..21316a4 100644
-
KEEP(*(.eh_frame*))
} > ITCM :rom_exec
@@ -275,6 +272,7 @@ SECTIONS
*(network_model_sec)
#endif
* (expected_output_data_sec)
+ *(.rodata*)
} > DDR :rom_dram
__eddr_data = ALIGN (16) ;
@@ -293,7 +291,7 @@ SECTIONS
*(COMMON)
......@@ -46,9 +46,59 @@ index ec58acc..21316a4 100644
__bss_end__ = .;
- } > DTCM :null
+ } > SRAM :null
.heap (COPY) :
{
--
2.25.1
diff --git a/targets/corstone-300/platform.scatter b/targets/corstone-300/platform.scatter
index fab12d1..be5c227 100644
--- a/targets/corstone-300/platform.scatter
+++ b/targets/corstone-300/platform.scatter
@@ -1,3 +1,4 @@
+#!cpp
/*
* Copyright (c) 2019-2021 Arm Limited. All rights reserved.
*
@@ -76,7 +77,7 @@
#endif
#ifndef STACK_SIZE
-#define STACK_SIZE 0x8000
+#define STACK_SIZE 0x20000
#endif
#ifndef HEAP_SIZE
@@ -136,7 +137,6 @@ APP_IMAGE LR_START LR_SIZE
; Make sure reset_handler ends up in root segment, when split across
; ITCM and DTCM
startup_ARMCM55.o
- .ANY (+RO)
}
#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
@@ -209,6 +209,7 @@ LOAD_REGION_1 DDR_START DDR_SIZE
* (input_data_sec)
* (expected_output_data_sec)
* (output_data_sec)
+ .ANY (+RO)
}
#if (ETHOSU_ARENA == 1)
diff --git a/targets/corstone-300/retarget.c b/targets/corstone-300/retarget.c
index 4bde44d..8b69295 100644
--- a/targets/corstone-300/retarget.c
+++ b/targets/corstone-300/retarget.c
@@ -274,3 +274,11 @@ int ferror(FILE *f) {
return EOF;
}
#endif
+
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
+#else
+void RETARGET(exit)(int return_code) {
+ RETARGET(_exit)(return_code);
+ while (1) {}
+}
+#endif
--
2.17.1
......@@ -97,7 +97,8 @@ ifeq ($(TOOLCHAIN), armclang)
FLAGS_ARMC = \
--target=arm-arm-none-eabi \
-Wno-unused-private-field \
-mcpu=$(MCPU_OPTION)
-mcpu=$(MCPU_OPTION) \
-ffp-mode=full
# Pass comma separated linker options to armlink
ARMC6_LDFLAGS += -Wl,--strict,--summary_stderr,--info,summarysizes,--map
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册