提交 30c69dcc 编写于 作者: Q qingqing01 提交者: Dang Qingqing

Fix debug mode in fake_quantize_op (#15693)

test=release/1.3

* Fix debug mode in fake_quantize_op
* Remove template specialization
上级 af4c9b5b
...@@ -21,26 +21,17 @@ limitations under the License. */ ...@@ -21,26 +21,17 @@ limitations under the License. */
namespace paddle { namespace paddle {
namespace operators { namespace operators {
template <typename T, int MajorType = Eigen::RowMajor, template <typename T>
typename IndexType = Eigen::DenseIndex> struct Compare {
using EigenVectorArrayMap = public:
Eigen::TensorMap<Eigen::Tensor<T, 1, MajorType, IndexType>>; bool operator()(const T a, const T b) { return (std::abs(a) < std::abs(b)); }
};
template <typename T, int MajorType = Eigen::RowMajor,
typename IndexType = Eigen::DenseIndex>
using ConstEigenVectorArrayMap =
Eigen::TensorMap<const Eigen::Tensor<T, 1, MajorType, IndexType>>;
template <typename T> template <typename T>
struct FindAbsMaxFunctor<platform::CPUDeviceContext, T> { struct FindAbsMaxFunctor<platform::CPUDeviceContext, T> {
void operator()(const platform::CPUDeviceContext& ctx, const T* in, void operator()(const platform::CPUDeviceContext& ctx, const T* in,
const int num, T* out) { const int num, T* out) {
Eigen::DSizes<Eigen::DenseIndex, 1> idim(num); *out = *(std::max_element(in + 0, in + num, Compare<T>()));
Eigen::DSizes<Eigen::DenseIndex, 1> odim(1);
Eigen::TensorMap<Eigen::Tensor<const T, 1, Eigen::RowMajor>> in_e(in, idim);
Eigen::TensorMap<Eigen::Tensor<T, 1, Eigen::RowMajor>> out_e(out, odim);
out_e = in_e.abs().maximum();
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册