Skip to content

Commit 30c69dc

Browse files
committed
Fix debug mode in fake_quantize_op (#15693)
test=release/1.3 * Fix debug mode in fake_quantize_op * Remove template specialization
1 parent af4c9b5 commit 30c69dc

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

paddle/fluid/operators/fake_quantize_op.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,17 @@ limitations under the License. */
2121
namespace paddle {
2222
namespace operators {
2323

24-
template <typename T, int MajorType = Eigen::RowMajor,
25-
typename IndexType = Eigen::DenseIndex>
26-
using EigenVectorArrayMap =
27-
Eigen::TensorMap<Eigen::Tensor<T, 1, MajorType, IndexType>>;
28-
29-
template <typename T, int MajorType = Eigen::RowMajor,
30-
typename IndexType = Eigen::DenseIndex>
31-
using ConstEigenVectorArrayMap =
32-
Eigen::TensorMap<const Eigen::Tensor<T, 1, MajorType, IndexType>>;
24+
template <typename T>
25+
struct Compare {
26+
public:
27+
bool operator()(const T a, const T b) { return (std::abs(a) < std::abs(b)); }
28+
};
3329

3430
template <typename T>
3531
struct FindAbsMaxFunctor<platform::CPUDeviceContext, T> {
3632
void operator()(const platform::CPUDeviceContext& ctx, const T* in,
3733
const int num, T* out) {
38-
Eigen::DSizes<Eigen::DenseIndex, 1> idim(num);
39-
Eigen::DSizes<Eigen::DenseIndex, 1> odim(1);
40-
Eigen::TensorMap<Eigen::Tensor<const T, 1, Eigen::RowMajor>> in_e(in, idim);
41-
Eigen::TensorMap<Eigen::Tensor<T, 1, Eigen::RowMajor>> out_e(out, odim);
42-
43-
out_e = in_e.abs().maximum();
34+
*out = *(std::max_element(in + 0, in + num, Compare<T>()));
4435
}
4536
};
4637

0 commit comments

Comments
 (0)