From 806ccc2cf778407edacfc78bb864a3be01033f06 Mon Sep 17 00:00:00 2001 From: Alexandre Passos Date: Tue, 11 Dec 2018 12:28:45 -0800 Subject: [PATCH] Fixes race condition. PiperOrigin-RevId: 225050185 --- tensorflow/core/kernels/training_op_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/training_op_helpers.h b/tensorflow/core/kernels/training_op_helpers.h index 98e2b3c0f2f..715dd8af7da 100644 --- a/tensorflow/core/kernels/training_op_helpers.h +++ b/tensorflow/core/kernels/training_op_helpers.h @@ -178,7 +178,7 @@ VariableInputLockHolder MaybeLockVariableInputMutexesInOrder( mutex* mu = GetTrainingVariableMutex(ctx, input, sparse, &var); core::ScopedUnref scoped_unref(var); if (mu != nullptr) { - if (do_lock) { + if (!sparse || do_lock) { locks->emplace_back(*mu); } else { shared_locks->emplace_back(*mu);