qmatrix.h
Go to the documentation of this file.
#ifndef FASTTEXT_QMATRIX_H
#define FASTTEXT_QMATRIX_H
#include <cstdint>
#include <istream>
#include <ostream>
#include <vector>
#include <memory>
#include "real.h"
#include "matrix.h"
#include "vector.h"
#include "productquantizer.h"
namespace fasttext {
class QMatrix {
private:
std::unique_ptr<ProductQuantizer> pq_;
std::unique_ptr<ProductQuantizer> npq_;
uint8_t* codes_;
uint8_t* norm_codes_;
bool qnorm_;
int64_t m_;
int64_t n_;
int32_t codesize_;
public:
QMatrix();
QMatrix(const Matrix&, int32_t, bool);
~QMatrix();
int64_t getM() const;
int64_t getN() const;
void quantizeNorm(const Vector&);
void quantize(const Matrix&);
void addToVector(Vector& x, int32_t t) const;
real dotRow(const Vector&, int64_t) const;
void save(std::ostream&);
void load(std::istream&);
};
}
#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