-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PPC crash in tensorflow/core/grappler/optimizers:arithmetic_optim…
…izer_test_cpu
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
easybuild/easyconfigs/t/TensorFlow/TensorFlow-2.11.0_fix-eigen-gemm-on-PPC.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
Fix a SIGSEGV in e.g. //tensorflow/core/grappler/optimizers:arithmetic_optimizer_test_cpu | ||
See https://gitlab.com/libeigen/eigen/-/issues/2608 | ||
|
||
Author: Alexander Grund (TU Dresden) | ||
|
||
diff --git a/third_party/eigen3/fix-ppc-gemm.patch b/third_party/eigen3/fix-ppc-gemm.patch | ||
new file mode 100644 | ||
index 00000000000..6a9faf462e0 | ||
--- /dev/null | ||
+++ b/third_party/eigen3/fix-ppc-gemm.patch | ||
@@ -0,0 +1,91 @@ | ||
+diff --git a/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h b/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h | ||
+index 28868ca5a..35e7f673e 100644 | ||
+--- a/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h | ||
++++ b/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h | ||
+@@ -30,23 +30,6 @@ EIGEN_ALWAYS_INLINE void gemm_extra_row( | ||
+ const Packet& pAlpha, | ||
+ const Packet& pMask); | ||
+ | ||
+-template<typename Scalar, typename Packet, typename DataMapper, const Index accCols, bool ConjugateLhs, bool ConjugateRhs, bool LhsIsReal, bool RhsIsReal> | ||
+-EIGEN_STRONG_INLINE void gemm_extra_cols( | ||
+- const DataMapper& res, | ||
+- const Scalar* blockA, | ||
+- const Scalar* blockB, | ||
+- Index depth, | ||
+- Index strideA, | ||
+- Index offsetA, | ||
+- Index strideB, | ||
+- Index offsetB, | ||
+- Index col, | ||
+- Index rows, | ||
+- Index cols, | ||
+- Index remaining_rows, | ||
+- const Packet& pAlpha, | ||
+- const Packet& pMask); | ||
+- | ||
+ template<typename Packet> | ||
+ EIGEN_ALWAYS_INLINE Packet bmask(const Index remaining_rows); | ||
+ | ||
+diff --git a/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h b/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h | ||
+index aa1cbf88f..3cd4ab32a 100644 | ||
+--- a/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h | ||
++++ b/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h | ||
+@@ -427,6 +427,49 @@ EIGEN_ALWAYS_INLINE void gemmMMA_cols( | ||
+ } | ||
+ } | ||
+ | ||
++#define MICRO_EXTRA(MICRO_EXTRA_UNROLL, value, is_col) \ | ||
++ switch(value) { \ | ||
++ default: \ | ||
++ MICRO_EXTRA_UNROLL(1) \ | ||
++ break; \ | ||
++ case 2: \ | ||
++ if (is_col || (sizeof(Scalar) == sizeof(float))) { \ | ||
++ MICRO_EXTRA_UNROLL(2) \ | ||
++ } \ | ||
++ break; \ | ||
++ case 3: \ | ||
++ if (is_col || (sizeof(Scalar) == sizeof(float))) { \ | ||
++ MICRO_EXTRA_UNROLL(3) \ | ||
++ } \ | ||
++ break; \ | ||
++ } | ||
++ | ||
++#define MICRO_EXTRA_COLS(N) \ | ||
++ gemmMMA_cols<Scalar, Packet, RhsPacket2, DataMapper, N, accCols>(res, blockA, blockB, depth, strideA, offsetA, strideB, offsetB, col, rows, remaining_rows, pAlpha, pMask); | ||
++ | ||
++template<typename Scalar, typename Packet, typename RhsPacket2, typename DataMapper, const Index accCols> | ||
++EIGEN_STRONG_INLINE void gemmMMA_extra_cols( | ||
++ const DataMapper& res, | ||
++ const Scalar* blockA, | ||
++ const Scalar* blockB, | ||
++ Index depth, | ||
++ Index strideA, | ||
++ Index offsetA, | ||
++ Index strideB, | ||
++ Index offsetB, | ||
++ Index col, | ||
++ Index rows, | ||
++ Index cols, | ||
++ Index remaining_rows, | ||
++ const Packet& pAlpha, | ||
++ const Packet& pMask) | ||
++{ | ||
++ MICRO_EXTRA(MICRO_EXTRA_COLS, cols-col, true) | ||
++} | ||
++ | ||
++#undef MICRO_EXTRA | ||
++#undef MICRO_EXTRA_COLS | ||
++ | ||
+ template<typename Scalar, typename Packet, typename RhsPacket, typename DataMapper, const Index accRows, const Index accCols> | ||
+ void gemmMMA(const DataMapper& res, const Scalar* blockA, const Scalar* blockB, Index rows, Index depth, Index cols, Scalar alpha, Index strideA, Index strideB, Index offsetA, Index offsetB) | ||
+ { | ||
+@@ -448,7 +491,7 @@ void gemmMMA(const DataMapper& res, const Scalar* blockA, const Scalar* blockB, | ||
+ | ||
+ if (col != cols) | ||
+ { | ||
+- gemm_extra_cols<Scalar, Packet, DataMapper, accCols>(res, blockA, blockB, depth, strideA, offsetA, strideB, offsetB, col, rows, cols, remaining_rows, pAlpha, pMask); | ||
++ gemmMMA_extra_cols<Scalar, Packet, RhsPacket2, DataMapper, accCols>(res, blockA, blockB, depth, strideA, offsetA, strideB, offsetB, col, rows, cols, remaining_rows, pAlpha, pMask); | ||
+ } | ||
+ } | ||
+ | ||
diff --git a/third_party/eigen3/workspace.bzl b/third_party/eigen3/workspace.bzl | ||
index 6c8744aeec4..2a2a7b474c9 100644 | ||
--- a/third_party/eigen3/workspace.bzl | ||
+++ b/third_party/eigen3/workspace.bzl | ||
@@ -14,7 +14,7 @@ def repo(): | ||
tf_http_archive( | ||
name = "eigen_archive", | ||
build_file = "//third_party/eigen3:eigen_archive.BUILD", | ||
- patch_file = ["//third_party/eigen3:disable-atan-on-ppc.patch"], | ||
+ patch_file = ["//third_party/eigen3:disable-atan-on-ppc.patch", "//third_party/eigen3:fix-ppc-gemm.patch"], | ||
sha256 = EIGEN_SHA256, | ||
strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT), | ||
urls = tf_mirror_urls("https://gitlab.com/libeigen/eigen/-/archive/{commit}/eigen-{commit}.tar.gz".format(commit = EIGEN_COMMIT)), |