aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/training_op_helpers.cc
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2018-09-24 19:26:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-24 19:31:03 -0700
commitbb1c131aad55e336d25fd297ecd8582773d6476f (patch)
tree46daf6e7ae9bc3945947b4cfcdff2e3fa5b67c01 /tensorflow/core/kernels/training_op_helpers.cc
parent720594142a51c2676d086ba00705d95002474687 (diff)
Fix memory leak of a Var resource in the multiple variable-handling kernels.
This change fixes memory leaks in the ScatterNdUpdateOp and StridedSliceAssign kernels, and in training-op kernels that use `GetTrainingVariableMutex()`. PiperOrigin-RevId: 214372346
Diffstat (limited to 'tensorflow/core/kernels/training_op_helpers.cc')
-rw-r--r--tensorflow/core/kernels/training_op_helpers.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/training_op_helpers.cc b/tensorflow/core/kernels/training_op_helpers.cc
index d3c4f62071..83b83fcdb9 100644
--- a/tensorflow/core/kernels/training_op_helpers.cc
+++ b/tensorflow/core/kernels/training_op_helpers.cc
@@ -21,6 +21,7 @@ mutex* GetTrainingVariableMutex(OpKernelContext* ctx, int input) {
if (ctx->input_dtype(input) == DT_RESOURCE) {
Var* var;
if (LookupResource(ctx, HandleFromInput(ctx, input), &var).ok()) {
+ core::ScopedUnref scoped_unref(var);
return var->mu();
} else {
ctx->CtxFailureWithWarning(