From abcefe721117010277fbffb1e159acf2228f08dc Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Thu, 14 Feb 2019 22:39:55 +0800 Subject: [PATCH] Fix debug mode in fake_quantize_op (#15693) * Fix debug mode in fake_quantize_op * Remove template specialization --- paddle/fluid/operators/fake_quantize_op.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/paddle/fluid/operators/fake_quantize_op.cc b/paddle/fluid/operators/fake_quantize_op.cc index 8aff9111412..d51eb054a96 100644 --- a/paddle/fluid/operators/fake_quantize_op.cc +++ b/paddle/fluid/operators/fake_quantize_op.cc @@ -21,26 +21,17 @@ limitations under the License. */ namespace paddle { namespace operators { -template -using EigenVectorArrayMap = - Eigen::TensorMap>; - -template -using ConstEigenVectorArrayMap = - Eigen::TensorMap>; +template +struct Compare { + public: + bool operator()(const T a, const T b) { return (std::abs(a) < std::abs(b)); } +}; template struct FindAbsMaxFunctor { void operator()(const platform::CPUDeviceContext& ctx, const T* in, const int num, T* out) { - Eigen::DSizes idim(num); - Eigen::DSizes odim(1); - Eigen::TensorMap> in_e(in, idim); - Eigen::TensorMap> out_e(out, odim); - - out_e = in_e.abs().maximum(); + *out = *(std::max_element(in + 0, in + num, Compare())); } }; -- GitLab