fastText: /data/users/cpuhrsch/fbsource/fbcode/deeplearning/fastText/src/qmatrix.h Source File

| fastText d00d36476b15 Fast text processing tool/library

qmatrix.h
Go to the documentation of this file.
1
10 #ifndef FASTTEXT_QMATRIX_H
11 #define FASTTEXT_QMATRIX_H
12
13 #include <cstdint>
14 #include <istream>
15 #include <ostream>
16
17 #include <vector>
18 #include <memory>
19
20 #include "real.h"
21
22 #include "matrix.h"
23 #include "vector.h"
24
25 #include "productquantizer.h"
26
27 namespace fasttext {
28
29 class QMatrix {
30 private:
31 std::unique_ptr<ProductQuantizer> pq_;
32 std::unique_ptr<ProductQuantizer> npq_;
33
34 uint8_t* codes_;
35 uint8_t* norm_codes_;
36
37 bool qnorm_;
38
39 int64_t m_;
40 int64_t n_;
41
42 int32_t codesize_;
43
44 public:
45
46 QMatrix();
47 QMatrix(const Matrix&, int32_t, bool);
48 ~QMatrix();
49
50 int64_t getM() const;
51 int64_t getN() const;
52
53 void quantizeNorm(const Vector&);
54 void quantize(const Matrix&);
55
56 void addToVector(Vector& x, int32_t t) const;
57 real dotRow(const Vector&, int64_t) const;
58
59 void save(std::ostream&);
60 void load(std::istream&);
61 };
62
63 }
64
65 #endif
fasttext::QMatrix::codesize_
int32_t codesize_
Definition: qmatrix.h:42
fasttext::QMatrix::getM
int64_t getM() const
Definition: qmatrix.cc:83
fasttext::QMatrix::m_
int64_t m_
Definition: qmatrix.h:39
fasttext::QMatrix::codes_
uint8_t * codes_
Definition: qmatrix.h:34
fasttext
Definition: args.cc:17
fasttext::QMatrix::dotRow
real dotRow(const Vector &, int64_t) const
Definition: qmatrix.cc:72
fasttext::Vector
Definition: vector.h:23
fasttext::QMatrix::norm_codes_
uint8_t * norm_codes_
Definition: qmatrix.h:35
fasttext::QMatrix::quantize
void quantize(const Matrix &)
Definition: qmatrix.cc:49
fasttext::QMatrix::save
void save(std::ostream &)
Definition: qmatrix.cc:91
fasttext::QMatrix::~QMatrix
~QMatrix()
Definition: qmatrix.cc:34
real.h
matrix.h
fasttext::QMatrix::getN
int64_t getN() const
Definition: qmatrix.cc:87
productquantizer.h
fasttext::QMatrix::npq_
std::unique_ptr< ProductQuantizer > npq_
Definition: qmatrix.h:32
vector.h
fasttext::real
float real
Definition: real.h:15
fasttext::Matrix
Definition: matrix.h:23
fasttext::QMatrix::qnorm_
bool qnorm_
Definition: qmatrix.h:37
fasttext::QMatrix::addToVector
void addToVector(Vector &x, int32_t t) const
Definition: qmatrix.cc:64
fasttext::QMatrix::load
void load(std::istream &)
Definition: qmatrix.cc:104
fasttext::QMatrix::pq_
std::unique_ptr< ProductQuantizer > pq_
Definition: qmatrix.h:31
fasttext::QMatrix
Definition: qmatrix.h:29
fasttext::QMatrix::QMatrix
QMatrix()
Definition: qmatrix.cc:17
fasttext::QMatrix::quantizeNorm
void quantizeNorm(const Vector &)
Definition: qmatrix.cc:41
fasttext::QMatrix::n_
int64_t n_
Definition: qmatrix.h:40