mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/14160 clang-format of C++ files Reviewed By: hx89 Differential Revision: D13115201 fbshipit-source-id: d2ad65f66209e00578ef90f87f41272de2d24aa9
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "caffe2/operators/lstm_unit_op.h"
|
|
#include "caffe2/quantization/server/caffe2_dnnlowp_utils.h"
|
|
#include "caffe2/quantization/server/dnnlowp.h"
|
|
#include "caffe2/quantization/server/op_wrapper.h"
|
|
#include "caffe2/quantization/server/sigmoid.h"
|
|
|
|
namespace caffe2 {
|
|
|
|
template <typename T>
|
|
class LSTMUnitDNNLowPOp final : public LSTMUnitOp<CPUContext> {
|
|
static_assert(std::is_integral<T>::value, "Integral required.");
|
|
|
|
public:
|
|
LSTMUnitDNNLowPOp(const OperatorDef& operator_def, Workspace* ws);
|
|
~LSTMUnitDNNLowPOp();
|
|
bool RunOnDevice() override;
|
|
|
|
private:
|
|
const TensorCPU& InputTensorCPU_(int idx);
|
|
TensorCPU* OutputTensorCPU_(int idx);
|
|
bool GetQuantizationParameters_();
|
|
OpWrapper<LSTMUnitOp<CPUContext>, T>* Fp32Op_();
|
|
|
|
bool drop_states_;
|
|
dnnlowp::Sigmoid<T> sigmoid_;
|
|
dnnlowp::Tanh<T> tanh_;
|
|
|
|
dnnlowp::TensorQuantizationParams H_in_qparams_, C_in_qparams_, G_in_qparams_,
|
|
H_out_qparams_, C_out_qparams_;
|
|
|
|
std::unique_ptr<OpWrapper<LSTMUnitOp<CPUContext>, T>> fp32_op_;
|
|
bool dequantize_output_{false}, measure_quantization_error_{false};
|
|
|
|
std::unique_ptr<dnnlowp::QuantizationFactory> qfactory_;
|
|
|
|
dnnlowp::QuantizationErrorStats cell_quantization_error_stats_,
|
|
hidden_quantization_error_stats_;
|
|
|
|
bool arguments_parsed_{false};
|
|
}; // class LSTMUnitDNNLowPOp
|
|
|
|
} // namespace caffe2
|