aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/arm_gemm/ndrange.hpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2019-01-23 11:24:50 +0000
committerMichalis Spyrou <michalis.spyrou@arm.com>2019-01-24 10:19:46 +0000
commit1d480652b820317fc97ccbc3cb517e3b9e8be197 (patch)
treeb3c845ec02cccf89430b95186ed3e3f2ae65e2bd /src/core/NEON/kernels/arm_gemm/ndrange.hpp
parent20b527a7029d02d0edda78fd92002cbc430dbe05 (diff)
downloadComputeLibrary-1d480652b820317fc97ccbc3cb517e3b9e8be197.tar.gz
COMPMID-1867: Add u8 and s8 hybrid assembly kernels.
Change-Id: Ifeb005f9d18d19feff11949474cce84d9e03749c Reviewed-on: https://review.mlplatform.org/565 Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/NEON/kernels/arm_gemm/ndrange.hpp')
-rw-r--r--src/core/NEON/kernels/arm_gemm/ndrange.hpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/core/NEON/kernels/arm_gemm/ndrange.hpp b/src/core/NEON/kernels/arm_gemm/ndrange.hpp
new file mode 100644
index 0000000000..20824dfc8b
--- /dev/null
+++ b/src/core/NEON/kernels/arm_gemm/ndrange.hpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2019 Arm Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#pragma once
+
+#include <algorithm>
+#include <initializer_list>
+
+namespace arm_gemm {
+
+template<unsigned int D>
+class NDRange {
+private:
+ unsigned int m_sizes[D];
+ unsigned int m_totalsizes[D];
+
+ class NDRangeIterator {
+ private:
+ const NDRange &m_parent;
+ unsigned int m_pos = 0;
+ unsigned int m_end = 0;
+
+ public:
+ NDRangeIterator(const NDRange &p, unsigned int s, unsigned int e) : m_parent(p), m_pos(s), m_end(e) { }
+
+ bool done() const {
+ return (m_pos >= m_end);
+ }
+
+ unsigned int dim(unsigned int d) const {
+ unsigned int r = m_pos;
+
+ if (d < (D - 1)) {
+ r %= m_parent.m_totalsizes[d];
+ }
+
+ if (d > 0) {
+ r /= m_parent.m_totalsizes[d-1];
+ }
+
+ return r;
+ }
+
+ bool next_dim0() {
+ m_pos++;
+
+ return !done();
+ }
+
+ bool next_dim1() {
+ m_pos += m_parent.m_sizes[0] - dim(0);
+
+ return !done();
+ }
+
+ unsigned int dim0_max() const {
+ unsigned int offset = std::min(m_end - m_pos, m_parent.m_sizes[0] - dim(0));
+
+ return dim(0) + offset;
+ }
+ };
+
+public:
+ template <typename... T>
+ NDRange(T... ts) : m_sizes{ts...} {
+ unsigned int t=1;
+
+ for (unsigned int i=0; i<D; i++) {
+ t *= m_sizes[i];
+
+ m_totalsizes[i] = t;
+ }
+ }
+
+ NDRangeIterator iterator(unsigned int start, unsigned int end) const {
+ return NDRangeIterator(*this, start, end);
+ }
+
+ unsigned int total_size() const {
+ return m_totalsizes[D - 1];
+ }
+
+ unsigned int get_size(unsigned int v) const {
+ return m_sizes[v];
+ }
+};
+
+} // namespace arm_gemm