Sha256: d781003c667fc991ba75915880551560d29547128e83a75951f417d292d31edb

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

/**
 * Copyright (c) 2016-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#pragma once

#include <cstdint>
#include <istream>
#include <ostream>

#include <memory>
#include <vector>

#include "real.h"

#include "densematrix.h"
#include "matrix.h"
#include "vector.h"

#include "productquantizer.h"

namespace fasttext {

class QuantMatrix : public Matrix {
 protected:
  std::unique_ptr<ProductQuantizer> pq_;
  std::unique_ptr<ProductQuantizer> npq_;

  std::vector<uint8_t> codes_;
  std::vector<uint8_t> norm_codes_;

  bool qnorm_;
  int32_t codesize_;

 public:
  QuantMatrix();
  QuantMatrix(DenseMatrix&&, int32_t, bool);
  QuantMatrix(const QuantMatrix&) = delete;
  QuantMatrix(QuantMatrix&&) = delete;
  QuantMatrix& operator=(const QuantMatrix&) = delete;
  QuantMatrix& operator=(QuantMatrix&&) = delete;
  virtual ~QuantMatrix() noexcept override = default;

  void quantizeNorm(const Vector&);
  void quantize(DenseMatrix&& mat);

  real dotRow(const Vector&, int64_t) const override;
  void addVectorToRow(const Vector&, int64_t, real) override;
  void addRowToVector(Vector& x, int32_t i) const override;
  void addRowToVector(Vector& x, int32_t i, real a) const override;
  void save(std::ostream&) const override;
  void load(std::istream&) override;
  void dump(std::ostream&) const override;
};

} // namespace fasttext

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fasttext-0.4.0 vendor/fastText/src/quantmatrix.h
fasttext-0.3.0 vendor/fastText/src/quantmatrix.h
fasttext-0.2.4 vendor/fastText/src/quantmatrix.h
fasttext-0.2.3 vendor/fastText/src/quantmatrix.h
fasttext-0.2.2 vendor/fastText/src/quantmatrix.h
fasttext-0.2.1 vendor/fastText/src/quantmatrix.h
fasttext-0.2.0 vendor/fastText/src/quantmatrix.h
fasttext-0.1.3 vendor/fastText/src/quantmatrix.h
fasttext-0.1.2 vendor/fastText/src/quantmatrix.h
fasttext-0.1.1 vendor/fastText/src/quantmatrix.h
fasttext-0.1.0 vendor/fastText/src/quantmatrix.h