#include <intsimdmatrix.h>
|
typedef void(* | PartialFunc) (const int8_t *w, const double *scales, const int8_t *u, int num_in, int num_out, double *v) |
|
|
static int | Roundup (int input, int factor) |
|
Definition at line 61 of file intsimdmatrix.h.
◆ PartialFunc
typedef void(* tesseract::IntSimdMatrix::PartialFunc) (const int8_t *w, const double *scales, const int8_t *u, int num_in, int num_out, double *v) |
|
protected |
◆ IntSimdMatrix()
tesseract::IntSimdMatrix::IntSimdMatrix |
( |
| ) |
|
|
inline |
Definition at line 65 of file intsimdmatrix.h.
int max_output_registers_
int num_outputs_per_register_
int num_inputs_per_register_
int num_inputs_per_group_
◆ GetFastestMultiplier()
IntSimdMatrix * tesseract::IntSimdMatrix::GetFastestMultiplier |
( |
| ) |
|
|
static |
Definition at line 31 of file intsimdmatrix.cpp.
34 multiplier =
new IntSimdMatrixAVX2();
36 multiplier =
new IntSimdMatrixSSE();
static bool IsSSEAvailable()
static bool IsAVX2Available()
◆ Init()
Definition at line 46 of file intsimdmatrix.cpp.
48 int num_out = w.
dim1();
49 int num_in = w.
dim2() - 1;
54 shaped_w_.resize((rounded_num_in + 1) * rounded_num_out, 0);
62 int num_outputs_per_register_set =
65 while (output + num_outputs_per_register_set <= rounded_num_out) {
70 for (
int j = 0; j < num_outputs_per_register_set; ++j) {
75 if (output + j < num_out && input + i < num_in)
76 weight = w(output + j, input + i);
82 for (
int j = 0; j < num_outputs_per_register_set; ++j) {
84 if (output + j < num_out) weight = w(output + j, num_in);
87 output += num_outputs_per_register_set;
int max_output_registers_
std::vector< PartialFunc > partial_funcs_
int num_outputs_per_register_
int num_inputs_per_group_
int RoundOutputs(int size) const
static int Roundup(int input, int factor)
std::vector< int8_t > shaped_w_
◆ MatrixDotVector()
void tesseract::IntSimdMatrix::MatrixDotVector |
( |
const GENERIC_2D_ARRAY< int8_t > & |
w, |
|
|
const GenericVector< double > & |
scales, |
|
|
const int8_t * |
u, |
|
|
double * |
v |
|
) |
| const |
Definition at line 96 of file intsimdmatrix.cpp.
99 int num_out = w.
dim1();
100 int num_in = w.
dim2() - 1;
103 for (
int i = 0; i < num_out; ++i) {
104 const int8_t* wi = w[i];
106 for (
int j = 0; j < num_in; ++j) total += wi[j] * u[j];
108 v[i] = (
static_cast<double>(total) / INT8_MAX + wi[num_in]) * scales[i];
112 const double* scales_data = &scales[0];
121 int w_step = (rounded_num_in + 1) * group_size;
124 for (; output + group_size <= rounded_num_out; output += group_size) {
125 (*fn)(w_data, scales_data, u, rounded_num_in, num_out - output, v);
127 scales_data += group_size;
int max_output_registers_
std::vector< PartialFunc > partial_funcs_
int num_outputs_per_register_
int num_inputs_per_group_
int RoundOutputs(int size) const
static int Roundup(int input, int factor)
std::vector< int8_t > shaped_w_
◆ RoundInputs()
int tesseract::IntSimdMatrix::RoundInputs |
( |
int |
size | ) |
const |
|
inline |
Definition at line 81 of file intsimdmatrix.h.
int num_inputs_per_register_
static int Roundup(int input, int factor)
◆ RoundOutputs()
int tesseract::IntSimdMatrix::RoundOutputs |
( |
int |
size | ) |
const |
|
inline |
Definition at line 85 of file intsimdmatrix.h.
int num_outputs_per_register_
static int Roundup(int input, int factor)
◆ Roundup()
static int tesseract::IntSimdMatrix::Roundup |
( |
int |
input, |
|
|
int |
factor |
|
) |
| |
|
inlinestaticprotected |
Definition at line 114 of file intsimdmatrix.h.
115 return (input + factor - 1) / factor * factor;
◆ max_output_registers_
int tesseract::IntSimdMatrix::max_output_registers_ |
|
protected |
◆ num_input_groups_
int tesseract::IntSimdMatrix::num_input_groups_ |
|
protected |
◆ num_inputs_per_group_
int tesseract::IntSimdMatrix::num_inputs_per_group_ |
|
protected |
◆ num_inputs_per_register_
int tesseract::IntSimdMatrix::num_inputs_per_register_ |
|
protected |
◆ num_outputs_per_register_
int tesseract::IntSimdMatrix::num_outputs_per_register_ |
|
protected |
◆ partial_funcs_
std::vector<PartialFunc> tesseract::IntSimdMatrix::partial_funcs_ |
|
protected |
◆ shaped_w_
std::vector<int8_t> tesseract::IntSimdMatrix::shaped_w_ |
|
protected |
The documentation for this class was generated from the following files: