From 3629fc4e98254c37e614ac3f77fa250b75c70f8d Mon Sep 17 00:00:00 2001
From: codrut3 <grosu.codrut@gmail.com>
Date: Fri, 29 Dec 2017 03:38:27 +0200
Subject: [PATCH] Add a mutex in cuda_solvers GetrfImpl. (#14492)

* Add a mutex in cuda_solvers GetrfImpl.

The NVIDIA documentation claims the cuSolverDn functions
are thread-safe. However, issue #13558 gives an example
of code where two threads simultaneously call GetrfImpl
and a segmentation fault occurs. Although one can not prove
the bug is in the NVIDIA code, this is most likely the case.

Note that GetrsImpl was already protected by a lock
for a similar reason.

* Revert changes to cuda_solvers.

The mutex was already added by a different commit.
---
 tensorflow/core/kernels/matrix_inverse_op.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tensorflow/core/kernels/matrix_inverse_op.cc b/tensorflow/core/kernels/matrix_inverse_op.cc
index c61a091c7b7..52afdd15ba6 100644
--- a/tensorflow/core/kernels/matrix_inverse_op.cc
+++ b/tensorflow/core/kernels/matrix_inverse_op.cc
@@ -210,7 +210,7 @@ class MatrixInverseOpGpu : public AsyncOpKernel {
             done);
       }
     } else {
-      // For large matrices, we wompute the inverse of each matrix in the batch
+      // For large matrices, we compute the inverse of each matrix in the batch
       // sequentially. Here we use the cuSolver methods GETRF/GETRS because they
       // are MUCH faster than their batched cuBlas equivalents for large
       // matrices.