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;
98 const int8_t* u,
double* v)
const {
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_
static IntSimdMatrix * GetFastestMultiplier()
int num_inputs_per_group_
void Init(const GENERIC_2D_ARRAY< int8_t > &w)
void MatrixDotVector(const GENERIC_2D_ARRAY< int8_t > &w, const GenericVector< double > &scales, const int8_t *u, double *v) const
int RoundOutputs(int size) const
static int Roundup(int input, int factor)
std::vector< int8_t > shaped_w_
static bool IsSSEAvailable()
static bool IsAVX2Available()