#include <intsimdmatrix.h>
Definition at line 63 of file intsimdmatrix.h.
◆ MatrixDotVectorFunction
◆ Init()
void tesseract::IntSimdMatrix::Init |
( |
const GENERIC_2D_ARRAY< int8_t > & |
w, |
|
|
std::vector< int8_t > & |
shaped_w |
|
) |
| const |
Definition at line 29 of file intsimdmatrix.cpp.
31 const int num_out = w.
dim1();
32 const int num_in = w.
dim2() - 1;
37 shaped_w.resize((rounded_num_in + 1) * rounded_num_out, 0);
45 int num_outputs_per_register_set =
48 while (output + num_outputs_per_register_set <= rounded_num_out) {
53 for (
int j = 0; j < num_outputs_per_register_set; ++j) {
58 if (output + j < num_out && input + i < num_in)
59 weight = w(output + j, input + i);
60 shaped_w[shaped_index++] = weight;
65 for (
int j = 0; j < num_outputs_per_register_set; ++j) {
67 if (output + j < num_out) weight = w(output + j, num_in);
68 shaped_w[shaped_index++] = weight;
70 output += num_outputs_per_register_set;
◆ MatrixDotVector()
void tesseract::IntSimdMatrix::MatrixDotVector |
( |
const GENERIC_2D_ARRAY< int8_t > & |
w, |
|
|
const GenericVector< double > & |
scales, |
|
|
const int8_t * |
u, |
|
|
double * |
v |
|
) |
| |
|
static |
Definition at line 79 of file intsimdmatrix.cpp.
82 int num_out = w.
dim1();
83 int num_in = w.
dim2() - 1;
85 for (
int i = 0; i < num_out; ++i) {
86 const int8_t* wi = w[i];
88 for (
int j = 0; j < num_in; ++j) total += wi[j] * u[j];
90 v[i] = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * scales[i];
◆ RoundInputs()
int tesseract::IntSimdMatrix::RoundInputs |
( |
int |
size | ) |
const |
|
inline |
◆ 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.
88 return (input + factor - 1) / factor * factor;
◆ intSimdMatrix
const IntSimdMatrix * tesseract::IntSimdMatrix::intSimdMatrix = nullptr |
|
static |
◆ intSimdMatrixAVX2
◆ intSimdMatrixSSE
Initial value:= {
matrixDotVector,
1,
1,
1,
1
}
Definition at line 118 of file intsimdmatrix.h.
◆ 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: