https://github.com/Microsoft/CNTK
Raw File
Tip revision: dd517c4be2308d923de8e0b5f08d6761f02a491c authored by Peggy Peng on 06 September 2018, 23:12:21 UTC
Undo multiverso merge
Tip revision: dd517c4
MatrixQuantizerCPU.h
#pragma once

#include "MatrixQuantizerImpl.h"
#include "ColumnQuantizer.h"
#include "QuantizedMatrix.h"
#include "CPUMatrix.h"

#ifdef _WIN32
#ifdef MATH_EXPORTS
#define MATH_API __declspec(dllexport)
#else
#define MATH_API __declspec(dllimport)
#endif
#else // no DLLs on Linux
#define MATH_API
#endif

namespace Microsoft { namespace MSR { namespace CNTK {

//see dbn::matrix quantizer
template <class ElemType>
class MatrixQuantizerCPU final : public MatrixQuantizerImpl<ElemType>
{
public:
    MatrixQuantizerCPU();

    // Disallow copy construction and assignment
    MatrixQuantizerCPU(const MatrixQuantizerCPU&) = delete;
    MatrixQuantizerCPU& operator=(const MatrixQuantizerCPU&) = delete;

    void QuantizeAsync(const Matrix<ElemType>& inMatrix, const Matrix<ElemType>& inResidual, QuantizedMatrix<ElemType>& outQMatrix, Matrix<ElemType>& outResidual, bool zeroThresholdFor1Bit) override;
    void WaitQuantizeAsyncDone() override;

    void UnquantizeAsync(QuantizedMatrix<ElemType>& inQMatrix, Matrix<ElemType>& outMatrix, bool add = false) override;
    void WaitUnquantizeAsyncDone() override;

    void TopKAsync(const Matrix<ElemType>& inMatrix, const Matrix<ElemType>& inResidual, struct stream &sendbuf, Matrix<ElemType>& outResidual, int topK) override;
    void WaitTopKAsyncDone() override;

    void UnTopKAsync(struct stream &recvbuf, Matrix<ElemType>& outMatrix) override;
    void WaitUnTopKAsyncDone() override;
};
} } }
back to top