From b2bd74f7b563ff952c3fc436da3b4b976890a652 Mon Sep 17 00:00:00 2001 From: risemeup1 <62429225+risemeup1@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:22:40 +0800 Subject: [PATCH] fix_gcc12_error (#52007) * fix_gcc12_error * patch on eigen3 for fixing gcc12 error * Update multiary.cc --- cmake/external/eigen.cmake | 16 ++++++++++++++++ paddle/phi/infermeta/multiary.cc | 2 +- patches/eigen/Complex.h.patch | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 patches/eigen/Complex.h.patch diff --git a/cmake/external/eigen.cmake b/cmake/external/eigen.cmake index 31280a768b3..12ccf5df27c 100644 --- a/cmake/external/eigen.cmake +++ b/cmake/external/eigen.cmake @@ -41,6 +41,22 @@ elseif(LINUX) endif() endif() +if(CMAKE_COMPILER_IS_GNUCC) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) + list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) + list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR) + set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}") + if(GCC_VERSION GREATER_EQUAL "12.0") + file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Complex.h.patch + complex_header) + set(EIGEN_PATCH_COMMAND + patch -d ${EIGEN_SOURCE_DIR}/Eigen/src/Core/arch/SSE/ < + ${complex_header}) + endif() +endif() + set(EIGEN_INCLUDE_DIR ${EIGEN_SOURCE_DIR}) include_directories(${EIGEN_INCLUDE_DIR}) diff --git a/paddle/phi/infermeta/multiary.cc b/paddle/phi/infermeta/multiary.cc index 5cd480f425a..73e0ff975d9 100644 --- a/paddle/phi/infermeta/multiary.cc +++ b/paddle/phi/infermeta/multiary.cc @@ -2231,7 +2231,7 @@ void MultiDotInferMeta(const std::vector& x, : phi::make_ddim({first_dim[0], last_dim[1]}); } - auto width = first_dim[1]; + auto width = first_dim.at(1); for (size_t i = 1; i < n - 1; i++) { PADDLE_ENFORCE_EQ(inputs_dims[i].size(), static_cast(2), diff --git a/patches/eigen/Complex.h.patch b/patches/eigen/Complex.h.patch new file mode 100644 index 00000000000..140e4ba8409 --- /dev/null +++ b/patches/eigen/Complex.h.patch @@ -0,0 +1,13 @@ +diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h +index f6f1b8c..2f4e7d1 100644 +--- a/Eigen/src/Core/arch/SSE/Complex.h ++++ b/Eigen/src/Core/arch/SSE/Complex.h +@@ -17,7 +17,7 @@ namespace internal { + //---------- float ---------- + struct Packet2cf + { +- EIGEN_STRONG_INLINE Packet2cf() {} ++ EIGEN_STRONG_INLINE Packet2cf() :v(_mm_setzero_ps()) {} + EIGEN_STRONG_INLINE explicit Packet2cf(const __m128& a) : v(a) {} + __m128 v; + }; -- GitLab