diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2016-06-30 14:00:39 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-06-30 15:05:38 -0700 |
commit | 379df09118ddfdbad19375d6d853254312ccf1ae (patch) | |
tree | 3edd22ddd15f9d86d6ae42382e55f91c1d88b825 /tensorflow/core/kernels/barrier_ops.cc | |
parent | 76fcc17bb1252862f1a640e741142b20239387d6 (diff) |
Fix initialization issues with Variables whose shape contains a zero.
Fixes #2099.
Tries to give Variables the same behavior as non-Variable tensors in
this respect. Useful for not having to special case e.g. coefficients
of a feature vector which may sometimes not have any features.
Change: 126347791
Diffstat (limited to 'tensorflow/core/kernels/barrier_ops.cc')
-rw-r--r-- | tensorflow/core/kernels/barrier_ops.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tensorflow/core/kernels/barrier_ops.cc b/tensorflow/core/kernels/barrier_ops.cc index 533b03db0e..e66b9d4168 100644 --- a/tensorflow/core/kernels/barrier_ops.cc +++ b/tensorflow/core/kernels/barrier_ops.cc @@ -354,7 +354,8 @@ class Barrier : public ResourceBase { element.push_back(PersistentTensor(uninitialized)); } } - if (element[1 + component_index].IsInitialized()) { + const PersistentTensor& component = element[1 + component_index]; + if (component.IsInitialized() && component.NumElements() > 0) { return errors::InvalidArgument("Key ", keys_vec(i), " already has a value for component ", component_index, " in barrier ", name()); @@ -374,7 +375,7 @@ class Barrier : public ResourceBase { // ready queue. bool is_complete = true; for (int j = 0; is_complete && j < element.size(); ++j) { - is_complete = element[j].IsInitialized(); + is_complete = element[j].IsInitialized() && element[j].NumElements() > 0; } if (is_complete) { // Add tuple to the ready queue. A queue tuple has the index |