NN: Integrate CMSIS-NN (CMSIS 5.8.0)

This commit integrates the newly added CMSIS-NN (part of CMSIS 5.8.0
release) component to the Zephyr build system.

Note that the CMake files added in this commit were re-implemented
specifically for Zephyr, and they are therefore different from the
upstream version.

(cherry picked from commit ed63b704bbfaceb71220557b658304c5ea3d5b88)

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
GitOrigin-RevId: ed63b704bbfaceb71220557b658304c5ea3d5b88
Change-Id: Ic7f227aaa42c62d135df5237daa64064e22ec9c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/cmsis/+/3391982
Tested-by: CopyBot Service Account <copybot.service@gmail.com>
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Commit-Queue: Tristan Honscheid <honscheid@google.com>
Tested-by: Tristan Honscheid <honscheid@google.com>
diff --git a/CMSIS/CMakeLists.txt b/CMSIS/CMakeLists.txt
index 4b1191f..172f011 100644
--- a/CMSIS/CMakeLists.txt
+++ b/CMSIS/CMakeLists.txt
@@ -5,3 +5,4 @@
 add_subdirectory_ifdef(CONFIG_HAS_CMSIS_CORE_R Core_R)
 
 add_subdirectory_ifdef(CONFIG_CMSIS_DSP        DSP)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN         NN)
diff --git a/CMSIS/NN/CMakeLists.txt b/CMSIS/NN/CMakeLists.txt
new file mode 100644
index 0000000..fc1993b
--- /dev/null
+++ b/CMSIS/NN/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_include_directories(Include)
+
+add_subdirectory(Source)
diff --git a/CMSIS/NN/Source/ActivationFunctions/CMakeLists.txt b/CMSIS/NN/Source/ActivationFunctions/CMakeLists.txt
new file mode 100644
index 0000000..b06a3c6
--- /dev/null
+++ b/CMSIS/NN/Source/ActivationFunctions/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_relu_q7.c
+  arm_relu6_s8.c
+)
diff --git a/CMSIS/NN/Source/BasicMathFunctions/CMakeLists.txt b/CMSIS/NN/Source/BasicMathFunctions/CMakeLists.txt
new file mode 100644
index 0000000..76260f0
--- /dev/null
+++ b/CMSIS/NN/Source/BasicMathFunctions/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_elementwise_add_s8.c
+  arm_elementwise_mul_s8.c
+)
diff --git a/CMSIS/NN/Source/CMakeLists.txt b/CMSIS/NN/Source/CMakeLists.txt
new file mode 100644
index 0000000..426b367
--- /dev/null
+++ b/CMSIS/NN/Source/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_ACTIVATION         ActivationFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_BASICMATH          BasicMathFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_CONCATENATION      ConcatenationFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_CONVOLUTION        ConvolutionFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_FULLYCONNECTED     FullyConnectedFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_NNSUPPORT          NNSupportFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_POOLING            PoolingFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_RESHAPE            ReshapeFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_SOFTMAX            SoftmaxFunctions)
+add_subdirectory_ifdef(CONFIG_CMSIS_NN_SVD                SVDFunctions)
diff --git a/CMSIS/NN/Source/ConcatenationFunctions/CMakeLists.txt b/CMSIS/NN/Source/ConcatenationFunctions/CMakeLists.txt
new file mode 100644
index 0000000..b128626
--- /dev/null
+++ b/CMSIS/NN/Source/ConcatenationFunctions/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_concatenation_s8_w.c
+  arm_concatenation_s8_x.c
+  arm_concatenation_s8_y.c
+  arm_concatenation_s8_z.c
+)
diff --git a/CMSIS/NN/Source/ConvolutionFunctions/CMakeLists.txt b/CMSIS/NN/Source/ConvolutionFunctions/CMakeLists.txt
new file mode 100644
index 0000000..40ace47
--- /dev/null
+++ b/CMSIS/NN/Source/ConvolutionFunctions/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_convolve_1_x_n_s8.c
+  arm_convolve_1x1_s8_fast.c
+  arm_convolve_s8.c
+  arm_convolve_wrapper_s8.c
+  arm_depthwise_conv_3x3_s8.c
+  arm_depthwise_conv_s8.c
+  arm_depthwise_conv_s8_opt.c
+  arm_depthwise_conv_wrapper_s8.c
+  arm_nn_depthwise_conv_s8_core.c
+  arm_nn_mat_mult_kernel_s8_s16.c
+  arm_nn_mat_mult_kernel_s8_s16_reordered.c
+  arm_nn_mat_mult_s8.c
+)
diff --git a/CMSIS/NN/Source/FullyConnectedFunctions/CMakeLists.txt b/CMSIS/NN/Source/FullyConnectedFunctions/CMakeLists.txt
new file mode 100644
index 0000000..931d9e6
--- /dev/null
+++ b/CMSIS/NN/Source/FullyConnectedFunctions/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_fully_connected_s8.c
+)
diff --git a/CMSIS/NN/Source/NNSupportFunctions/CMakeLists.txt b/CMSIS/NN/Source/NNSupportFunctions/CMakeLists.txt
new file mode 100644
index 0000000..8678808
--- /dev/null
+++ b/CMSIS/NN/Source/NNSupportFunctions/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_nn_depthwise_conv_nt_t_padded_s8.c
+  arm_nn_depthwise_conv_nt_t_s8.c
+  arm_nn_mat_mul_core_1x_s8.c
+  arm_nn_mat_mul_core_4x_s8.c
+  arm_nn_mat_mult_nt_t_s8.c
+  arm_nn_vec_mat_mult_t_s8.c
+  arm_nn_vec_mat_mult_t_svdf_s8.c
+)
diff --git a/CMSIS/NN/Source/PoolingFunctions/CMakeLists.txt b/CMSIS/NN/Source/PoolingFunctions/CMakeLists.txt
new file mode 100644
index 0000000..b463cdc
--- /dev/null
+++ b/CMSIS/NN/Source/PoolingFunctions/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_avgpool_s8.c
+  arm_max_pool_s8.c
+)
diff --git a/CMSIS/NN/Source/ReshapeFunctions/CMakeLists.txt b/CMSIS/NN/Source/ReshapeFunctions/CMakeLists.txt
new file mode 100644
index 0000000..bfbdf30
--- /dev/null
+++ b/CMSIS/NN/Source/ReshapeFunctions/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_reshape_s8.c
+)
diff --git a/CMSIS/NN/Source/SVDFunctions/CMakeLists.txt b/CMSIS/NN/Source/SVDFunctions/CMakeLists.txt
new file mode 100644
index 0000000..76b85df
--- /dev/null
+++ b/CMSIS/NN/Source/SVDFunctions/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_svdf_s8.c
+)
diff --git a/CMSIS/NN/Source/SoftmaxFunctions/CMakeLists.txt b/CMSIS/NN/Source/SoftmaxFunctions/CMakeLists.txt
new file mode 100644
index 0000000..8930108
--- /dev/null
+++ b/CMSIS/NN/Source/SoftmaxFunctions/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (c) 2021, Commonwealth Scientific and Industrial Research
+# Organisation (CSIRO) ABN 41 687 119 230.
+# SPDX-License-Identifier: Apache-2.0
+
+zephyr_library()
+
+zephyr_library_sources(
+  arm_softmax_q7.c
+  arm_softmax_s8.c
+  arm_softmax_u8.c
+)