pytorch/caffe2/quantization/server/lstm_unit_dnnlowp_op.h
cyy 483f748dd5 [BE] Enforce missing override keyword (#104032)
This PR enables `-Winconsistent-missing-destructor-override` and `-Winconsistent-missing-override`
and fixes violations.

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 47e904e</samp>

This pull request updates the code of various classes and operators in the `caffe2` and `aten` subdirectories to use the `override` specifier instead of the `virtual` keyword for destructors and other virtual functions that override a base class function. This improves the code readability, quality, and consistency with C++ best practices. It also modifies the `./CMakeLists.txt` file to enable warnings for these specifiers, but disable errors.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/104032
Approved by: https://github.com/malfet
2023-06-24 02:34:24 +00:00

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() override;
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