aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/arm_gemm/misc.cpp
diff options
context:
space:
mode:
authorFrancesco.Petrogalli@arm.com <francesco.petrogalli@arm.com>2022-04-05 10:31:08 +0000
committerFrancesco Petrogalli <francesco.petrogalli@arm.com>2022-05-24 14:28:27 +0000
commit5fcf22dadf092efd7aafb359f9229aa270eb1129 (patch)
treef309426ed19bd6710329da3b530167db72d1c6b2 /src/core/NEON/kernels/arm_gemm/misc.cpp
parenta8caa023f0d7b71b3a250a14ceee935052fcc74a (diff)
downloadComputeLibrary-5fcf22dadf092efd7aafb359f9229aa270eb1129.tar.gz
[arm_gemm] Import fixed-format kernels from gemm_linux.
This is a No Functional Change Intended (NFCI) patch. It imports the kernel in the code, but the interface to select them and expose the format of the weight tensors to the user will be provided in a subsequent patch. Kernels and kernel selection code in arm_gemm has been provided by David.Mansell <David.Mansell@arm.com>. The kernels are not compiled in the library by default, but need to be selected via the `scons` option `experimental_fixed_format_kernels=1`. Resolves: ONCPUML-829 Signed-off-by: Francesco.Petrogalli@arm.com <francesco.petrogalli@arm.com> Change-Id: If00ccb2b9b7221e01b214cf9783111226ccc8bf4 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7380 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/NEON/kernels/arm_gemm/misc.cpp')
-rw-r--r--src/core/NEON/kernels/arm_gemm/misc.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/core/NEON/kernels/arm_gemm/misc.cpp b/src/core/NEON/kernels/arm_gemm/misc.cpp
index 229e6b56f9..cf99bbdb46 100644
--- a/src/core/NEON/kernels/arm_gemm/misc.cpp
+++ b/src/core/NEON/kernels/arm_gemm/misc.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 Arm Limited.
+ * Copyright (c) 2017-2018, 2022 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,6 +25,11 @@
#ifndef NO_MULTI_THREADING
#include <mutex>
#endif
+#include <cstdint>
+
+#include "arm_gemm.hpp"
+#include "kernel_weight_format.hpp"
+#include "utils.hpp"
namespace arm_gemm {
@@ -32,4 +37,39 @@ namespace arm_gemm {
std::mutex report_mutex;
#endif
-} // namespace arm_gemm \ No newline at end of file
+WeightFormat get_weight_format(const KernelWeightFormat kwf, size_t element_size) {
+ if (kwf==KernelWeightFormat::NON_FIXED) {
+ return WeightFormat::UNSPECIFIED;
+ }
+
+ uint32_t kwf_i = static_cast<uint32_t>(kwf);
+ uint32_t wf_i = 0;
+
+ const auto block_bytes = (kwf_i >> 8) & 0xf;
+ const auto vector_count = (kwf_i >> 12) & 0xf;
+
+ uint32_t vector_bytes;
+
+ // For fast mode BF16 kernels set the appropriate bit and override element size to 2.
+ if (kwf_i & 0x10) {
+ element_size = 2;
+ wf_i |= 0x10;
+ }
+
+ // Get total bytes in vector output
+ if (kwf_i & 0x1) {
+ vector_bytes = vector_count * get_vector_length<uint8_t>();
+ } else {
+ vector_bytes = vector_count * 16;
+ }
+
+ auto input_blocking = block_bytes / element_size;
+ auto output_blocking = vector_bytes / block_bytes;
+
+ wf_i |= (input_blocking << 20);
+ wf_i |= (output_blocking << 8);
+
+ return static_cast<WeightFormat>(wf_i);
+}
+
+} // namespace arm_gemm