@@ -21,26 +21,17 @@ limitations under the License. */
21
21
namespace paddle {
22
22
namespace operators {
23
23
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
+ };
33
29
34
30
template <typename T>
35
31
struct FindAbsMaxFunctor <platform::CPUDeviceContext, T> {
36
32
void operator ()(const platform::CPUDeviceContext& ctx, const T* in,
37
33
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>()));
44
35
}
45
36
};
46
37
0 commit comments