diff --git a/cmsis-pack-examples/.cdefault.yml b/cmsis-pack-examples/.cdefault.yml index 8ce2541..d0c5605 100644 --- a/cmsis-pack-examples/.cdefault.yml +++ b/cmsis-pack-examples/.cdefault.yml @@ -23,9 +23,13 @@ default: misc: - for-compiler: AC6 CPP: - - -std=c++14 -fno-exceptions -Wno-license-management -fno-rtti + - -std=c++14 + - -fno-exceptions + - -Wno-license-management + - -fno-rtti C: - - -std=c99 -Wno-license-management + - -std=c99 + - -Wno-license-management Link: - --entry=Reset_Handler - --verbose @@ -33,4 +37,4 @@ default: - --map - --info=sizes,totals,unused,compression,inline,summarysizes - --list='diagnostics.map' - - --diag_suppress=L6439W,L6314W,L9931W \ No newline at end of file + - --diag_suppress=L6439W,L6314W,L9931W diff --git a/cmsis-pack-examples/common/common.clayer.yml b/cmsis-pack-examples/common/common.clayer.yml index 02c7c9b..ff89f3c 100644 --- a/cmsis-pack-examples/common/common.clayer.yml +++ b/cmsis-pack-examples/common/common.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -26,9 +26,14 @@ layer: files: - file: include/BufAttributes.hpp - file: include/ethosu_mem_config.h - - group: CMSIS Extra - files: - - file: src/arm_nn_softmax_common_s8.c + + # Workaround 4001: for TensorFlow's pack referring to + # CMSIS_DEVICE_ARM_CORTEX_M_XX_HEADER_FILE. + # Can be removed once the pack has been fixed. + misc: + - for-compiler: AC6 + CPP: + - "-include \"RTE_Components.h\"" components: - component: ARM::CMSIS:CORE @@ -39,6 +44,9 @@ layer: - component: tensorflow::Data Processing:Math:kissfft - component: tensorflow::Data Processing:Math:ruy - component: tensorflow::Machine Learning:TensorFlow:Kernel Utils + # Workaround 4001 (see description above) + define: + - CMSIS_DEVICE_ARM_CORTEX_M_XX_HEADER_FILE=CMSIS_device_header - component: tensorflow::Machine Learning:TensorFlow:Testing - component: ARM::ML Eval Kit:Common:API - component: ARM::ML Eval Kit:Common:Log diff --git a/cmsis-pack-examples/common/src/arm_nn_softmax_common_s8.c b/cmsis-pack-examples/common/src/arm_nn_softmax_common_s8.c deleted file mode 100644 index 6c5336e..0000000 --- a/cmsis-pack-examples/common/src/arm_nn_softmax_common_s8.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2022 Arm Limited or its affiliates. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* ---------------------------------------------------------------------- - * Project: CMSIS NN Library - * Title: arm_nn_softmax_common_s8.c - * Description: Softmax with s8 input and output of s8 or s16. - * - * $Date: 17 March 2022 - * $Revision: V.1.0.1 - * - * Target Processor: Cortex-M processors - * -------------------------------------------------------------------- */ - -#include "arm_nnsupportfunctions.h" - -#define ACCUM_BITS 12 - -/** - * @ingroup groupSupport - */ - -/** - * @addtogroup Softmax - * @{ - */ - -/* - * Softmax function with s8 input and output of s8 or s16. - * - * Refer header file for details. - * - */ -void arm_nn_softmax_common_s8(const int8_t* input, - const int32_t num_rows, - const int32_t row_size, - const int32_t mult, - const int32_t shift, - const int32_t diff_min, - const bool int16_output, - void* output) -{ - const int32_t mask = (1 << shift); - - int32_t col = 0; - int32_t row_idx; - - for (row_idx = 0; row_idx < num_rows; ++row_idx) { - // Find the maximum value in order to ensure numerical stability - int8_t max = *input; - - for (col = 1; col < row_size; ++col) { - max = MAX(max, input[col]); - } - - int32_t diff = 0; - int32_t sum = 0; - - for (col = 0; col < row_size; ++col) { - diff = input[col] - max; - if (diff >= diff_min) { - sum += DIV_POW2(EXP_ON_NEG(MUL_SAT(diff * mask, mult)), ACCUM_BITS); - } - } - - const int32_t headroom = __CLZ(sum); - const int32_t shifted_scale = ONE_OVER1((sum > 0 ? sum << headroom : 0) - (1 << 31)); - int32_t bits_over_unit; - - if (int16_output) { - int16_t* output_s16 = (int16_t*)output + row_idx * row_size; - - bits_over_unit = ACCUM_BITS - headroom + 15; - - for (col = 0; col < row_size; ++col) { - diff = input[col] - max; - - if (diff >= diff_min) { - const int32_t res = - DIV_POW2(MUL_SAT(shifted_scale, EXP_ON_NEG(MUL_SAT(diff * mask, mult))), - bits_over_unit) + - NN_Q15_MIN; - output_s16[col] = (int16_t)CLAMP(res, (int32_t)NN_Q15_MAX, (int32_t)NN_Q15_MIN); - } else { - output_s16[col] = NN_Q15_MIN; - } - } - } else { - int8_t* output_s8 = (int8_t*)output + row_idx * row_size; - - bits_over_unit = ACCUM_BITS - headroom + 23; - - for (col = 0; col < row_size; ++col) { - diff = input[col] - max; - if (diff >= diff_min) { - const int32_t res = - DIV_POW2(MUL_SAT(shifted_scale, EXP_ON_NEG(MUL_SAT(diff * mask, mult))), - bits_over_unit) + - NN_Q7_MIN; - output_s8[col] = (int8_t)CLAMP(res, (int32_t)NN_Q7_MAX, (int32_t)NN_Q7_MIN); - } else { - output_s8[col] = NN_Q7_MIN; - } - } - } - - input += row_size; - } -} - -/** - * @} end of NNBasicMath group - */ diff --git a/cmsis-pack-examples/mlek.csolution.yml b/cmsis-pack-examples/mlek.csolution.yml index 687d207..6d9b1bb 100644 --- a/cmsis-pack-examples/mlek.csolution.yml +++ b/cmsis-pack-examples/mlek.csolution.yml @@ -20,13 +20,15 @@ solution: packs: - pack: ARM::CMSIS@5.9.0 - - pack: Arm::ethos-u-core-driver@1.22.5-rc4 + - pack: ARM::CMSIS-DSP@1.14.4 + - pack: ARM::CMSIS-NN@4.0.0 + - pack: Arm::ethos-u-core-driver@1.22.8 - pack: ARM::ml-embedded-eval-kit-uc-api@22.8.0-Beta - - pack: tensorflow::flatbuffers@1.22.5-rc4 - - pack: tensorflow::gemmlowp@1.22.5-rc4 - - pack: tensorflow::kissfft@1.22.5-rc4 - - pack: tensorflow::ruy@1.22.5-rc4 - - pack: tensorflow::tensorflow-lite-micro@1.22.5-rc4 + - pack: tensorflow::flatbuffers@1.22.8 + - pack: tensorflow::gemmlowp@1.22.8 + - pack: tensorflow::kissfft@1.22.8 + - pack: tensorflow::ruy@1.22.8 + - pack: tensorflow::tensorflow-lite-micro@1.22.8 - pack: ARM::V2M_MPS3_SSE_300_BSP@1.3.0 - pack: ARM::V2M_MPS3_SSE_310_BSP@1.0.0