Fixes race condition.

PiperOrigin-RevId: 225050185
This commit is contained in:
Alexandre Passos 2018-12-11 12:28:45 -08:00 committed by TensorFlower Gardener
parent 6756eee557
commit 806ccc2cf7

View File

@ -178,7 +178,7 @@ VariableInputLockHolder MaybeLockVariableInputMutexesInOrder(
mutex* mu = GetTrainingVariableMutex<Device, T>(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);