tesseract  4.0.0-1-g2a2b
intsimdmatrixsse.cpp
Go to the documentation of this file.
1 // File: intsindmatrixsse.cpp
3 // Description: SSE implementation of 8-bit int SIMD matrix multiply.
4 // Author: Ray Smith
5 // Created: Tue Aug 23 13:58:49 PST 2017
6 //
7 // (C) Copyright 2017, Google Inc.
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
18 
19 #include "intsimdmatrixsse.h"
20 
21 #include <cstdint>
22 #include <vector>
23 #include "dotproductsse.h"
24 
25 namespace tesseract {
26 
27 #ifdef __SSE4_1__
28 // Computes part of matrix.vector v = Wu. Computes 1 result.
29 static void PartialMatrixDotVector1(const int8_t* wi, const double* scales,
30  const int8_t* u, int num_in, int num_out,
31  double* v) {
32  int total = IntDotProductSSE(u, wi, num_in);
33  // Add in the bias and correct for integer values.
34  *v = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * *scales;
35 }
36 #endif // __SSE4_1__
37 
39 #ifdef __SSE4_1__
40  partial_funcs_ = {PartialMatrixDotVector1};
41 #endif // __SSE4_1__
42 }
43 
44 } // namespace tesseract.
std::vector< PartialFunc > partial_funcs_
int32_t IntDotProductSSE(const int8_t *u, const int8_t *v, int n)