#include <intsimdmatrix.h>
Definition at line 64 of file intsimdmatrix.h.
◆ MatrixDotVectorFunction
◆ Init()
void tesseract::IntSimdMatrix::Init |
( |
const GENERIC_2D_ARRAY< int8_t > & |
w, |
|
|
std::vector< int8_t > & |
shaped_w, |
|
|
int32_t & |
rounded_num_out |
|
) |
| const |
Definition at line 27 of file intsimdmatrix.cpp.
28 {
29 const int num_out = w.
dim1();
30 const int num_in = w.
dim2() - 1;
31
34
35 shaped_w.resize((rounded_num_in + 1) * rounded_num_out, 0);
36 int shaped_index = 0;
38
39
41
43
44 while (
output + num_outputs_per_register_set <= rounded_num_out) {
45
46
48
49 for (int j = 0; j < num_outputs_per_register_set; ++j) {
50
51
53 int8_t weight = 0;
54 if (
output + j < num_out && input +
i < num_in) {
55 weight = w(
output + j, input +
i);
56 }
57 shaped_w[shaped_index++] = weight;
58 }
59 }
60 }
61
62 for (int j = 0; j < num_outputs_per_register_set; ++j) {
63 int8_t weight = 0;
64 if (
output + j < num_out) {
65 weight = w(
output + j, num_in);
66 }
67 shaped_w[shaped_index++] = weight;
68 }
69 output += num_outputs_per_register_set;
70 }
71 }
72}
int num_inputs_per_group_
int max_output_registers_
int RoundOutputs(int size) const
int num_outputs_per_register_
static int Roundup(int input, int factor)
◆ MatrixDotVector()
void tesseract::IntSimdMatrix::MatrixDotVector |
( |
const GENERIC_2D_ARRAY< int8_t > & |
w, |
|
|
const std::vector< TFloat > & |
scales, |
|
|
const int8_t * |
u, |
|
|
TFloat * |
v |
|
) |
| |
|
static |
Definition at line 78 of file intsimdmatrix.cpp.
79 {
80 int num_out = w.
dim1();
81 int num_in = w.
dim2() - 1;
82
83 for (
int i = 0;
i < num_out; ++
i) {
84 const int8_t *wi = w[
i];
85 int total = 0;
86 for (int j = 0; j < num_in; ++j) {
87 total += wi[j] * u[j];
88 }
89
90 v[
i] = (total + wi[num_in] * INT8_MAX) * scales[
i];
91 }
92}
◆ RoundInputs()
int tesseract::IntSimdMatrix::RoundInputs |
( |
int |
size | ) |
const |
|
inline |
Definition at line 70 of file intsimdmatrix.h.
70 {
72 }
int num_inputs_per_register_
◆ RoundOutputs()
int tesseract::IntSimdMatrix::RoundOutputs |
( |
int |
size | ) |
const |
|
inline |
◆ Roundup()
static int tesseract::IntSimdMatrix::Roundup |
( |
int |
input, |
|
|
int |
factor |
|
) |
| |
|
inlinestatic |
Definition at line 87 of file intsimdmatrix.h.
87 {
88 return (input + factor - 1) / factor * factor;
89 }
◆ intSimdMatrix
const IntSimdMatrix * tesseract::IntSimdMatrix::intSimdMatrix = nullptr |
|
static |
◆ intSimdMatrixAVX2
◆ intSimdMatrixNEON
◆ intSimdMatrixSSE
◆ matrixDotVectorFunction
◆ max_output_registers_
int tesseract::IntSimdMatrix::max_output_registers_ |
◆ num_inputs_per_group_
int tesseract::IntSimdMatrix::num_inputs_per_group_ |
◆ num_inputs_per_register_
int tesseract::IntSimdMatrix::num_inputs_per_register_ |
◆ num_outputs_per_register_
int tesseract::IntSimdMatrix::num_outputs_per_register_ |
The documentation for this struct was generated from the following files: