• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 // Copyright (C) 2015 Benoit Jacob <benoitjacob@google.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef CXX11_SRC_FIXEDPOINT_MATMATPRODUCTNEON_H_
12 #define CXX11_SRC_FIXEDPOINT_MATMATPRODUCTNEON_H_
13 
14 namespace Eigen {
15 namespace internal {
16 
17 // AVX2 optimized implementation of the case where the lhs is encoded using
18 // signed 8bit
19 // integers and the rhs using unsigned 8bit integers.
20 #ifdef EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT
21 
22 template <bool _ConjLhs, bool _ConjRhs>
23 class gebp_traits<QInt8, QUInt8, _ConjLhs, _ConjRhs> {
24  public:
25   typedef QInt8 LhsScalar;
26   typedef QUInt8 RhsScalar;
27   typedef QInt32 ResScalar;
28 
29   enum {
30     // register block size along the M and N directions
31     // One for the current implementation
32     nr = 1,
33     mr = 1,
34     // Progress made at each iteration of the product loop
35     // also 1 for the current implementation
36     LhsProgress = 1,
37     RhsProgress = 1
38   };
39 };
40 
41 // Mat-Mat product of a signed 8bit lhs with an unsigned 8bit rhs
42 template <typename Index, typename DataMapper, int mr, int nr,
43           bool ConjugateLhs, bool ConjugateRhs>
44 struct gebp_kernel<QInt8, QUInt8, Index, DataMapper, mr, nr, ConjugateLhs,
45                    ConjugateRhs> {
46   EIGEN_DONT_INLINE
47   void operator()(const DataMapper& res, const QInt8* blockA,
48                   const QUInt8* blockB, Index rows, Index depth, Index cols,
49                   QInt32 alpha, Index strideA = -1, Index strideB = -1,
50                   Index offsetA = 0, Index offsetB = 0);
51 };
52 
53 template <typename Index, typename DataMapper, int mr, int nr,
54           bool ConjugateLhs, bool ConjugateRhs>
55 EIGEN_DONT_INLINE void gebp_kernel<QInt8, QUInt8, Index, DataMapper, mr, nr,
56                                    ConjugateLhs, ConjugateRhs>::
57 operator()(const DataMapper& res, const QInt8* blockA, const QUInt8* blockB,
58            Index rows, Index depth, Index cols, QInt32 alpha, Index strideA,
59            Index strideB, Index offsetA, Index offsetB) {
60   EIGEN_STATIC_ASSERT(!ConjugateLhs, YOU_MADE_A_PROGRAMMING_MISTAKE);
61   EIGEN_STATIC_ASSERT(!ConjugateRhs, YOU_MADE_A_PROGRAMMING_MISTAKE);
62 
63   eigen_assert(alpha.value == 1);
64   eigen_assert(strideA == -1);
65   eigen_assert(strideB == -1);
66   eigen_assert(offsetA == 0);
67   eigen_assert(offsetB == 0);
68 
69   eigen_assert(rows > 0);
70   eigen_assert(cols > 0);
71   eigen_assert(depth > 0);
72   eigen_assert(blockA);
73   eigen_assert(blockB);
74 
75   for (Index j = 0; j < cols; ++j) {
76     Index startB = j * depth;
77 
78     for (Index i = 0; i < rows; ++i) {
79       Index startA = i * depth;
80 
81       for (Index k = 0; k < depth; ++k) {
82         res(i, j) += blockA[startA + k] * blockB[startB + k];
83       }
84     }
85   }
86 }
87 #endif
88 
89 }  // namespace internal
90 }  // namespace Eigen
91 
92 #endif  // CXX11_SRC_FIXEDPOINT_MATMATPRODUCTNEON_H_
93