diff --git a/cmake/external/eigen.cmake b/cmake/external/eigen.cmake index b47c4996e7c8ab7df2e5b973732f023dddc030a6..06e37b3c8a602872ac818736c2a1a0441b15ac0f 100644 --- a/cmake/external/eigen.cmake +++ b/cmake/external/eigen.cmake @@ -40,6 +40,13 @@ elseif(LINUX) endif() if(CMAKE_COMPILER_IS_GNUCC) + file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/TensorRandom.h.patch + tensor_random_header) + # See: [Why calling some `git` commands before `patch`?] + set(EIGEN_PATCH_COMMAND + git checkout -- . && git checkout ${EIGEN_TAG} && patch -Nd + ${SOURCE_DIR}/unsupported/Eigen/CXX11/src/Tensor < + ${tensor_random_header}) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion OUTPUT_VARIABLE GCC_VERSION) string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) @@ -49,9 +56,8 @@ if(CMAKE_COMPILER_IS_GNUCC) if(GCC_VERSION GREATER_EQUAL "12.0") file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Complex.h.patch complex_header) - # See: [Why calling some `git` commands before `patch`?] set(EIGEN_PATCH_COMMAND - git checkout -- . && git checkout ${EIGEN_TAG} && patch -Nd + ${EIGEN_PATCH_COMMAND} && patch -Nd ${SOURCE_DIR}/Eigen/src/Core/arch/SSE/ < ${complex_header}) endif() endif() diff --git a/patches/eigen/TensorRandom.h.patch b/patches/eigen/TensorRandom.h.patch new file mode 100644 index 0000000000000000000000000000000000000000..53ff4385113b6041edbfc7c445863293defd1181 --- /dev/null +++ b/patches/eigen/TensorRandom.h.patch @@ -0,0 +1,11 @@ +--- a/unsupported/Eigen/CXX11/src/Tensor/TensorRandom.h ++++ b/unsupported/Eigen/CXX11/src/Tensor/TensorRandom.h +@@ -16,7 +16,7 @@ namespace internal { + + namespace { + +-EIGEN_DEVICE_FUNC uint64_t get_random_seed() { ++static EIGEN_DEVICE_FUNC uint64_t get_random_seed() { + #if defined(EIGEN_GPU_COMPILE_PHASE) + // We don't support 3d kernels since we currently only use 1 and + // 2d kernels.