Skip to content

Commit f16b50e

Browse files
imsheridansb2nov
authored andcommitted
Support a single Tensor in StagingArea.put() (tensorflow#17863)
* Support a single Tensor in a StagingArea.put() * Fix the input values parameter could also be dictionary type
1 parent 10878ed commit f16b50e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tensorflow/python/ops/data_flow_ops.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,9 @@ def put(self, values, name=None):
17691769
its capacity.
17701770
17711771
Args:
1772-
values: Tensor (or a tuple of Tensors) to place into the staging area.
1772+
values: A single tensor, a list or tuple of tensors, or a dictionary with
1773+
tensor values. The number of elements must match the length of the
1774+
list provided to the dtypes argument when creating the StagingArea.
17731775
name: A name for the operation (optional).
17741776
17751777
Returns:
@@ -1780,11 +1782,12 @@ def put(self, values, name=None):
17801782
"""
17811783
with ops.name_scope(name, "%s_put" % self._name,
17821784
self._scope_vals(values)) as scope:
1785+
1786+
if not isinstance(values, (list, tuple, dict)):
1787+
values = [values]
17831788

17841789
# Hard-code indices for this staging area
1785-
indices = (
1786-
list(six.moves.range(len(values)))
1787-
if isinstance(values, (list, tuple)) else None)
1790+
indices = list(six.moves.range(len(values)))
17881791
vals, _ = self._check_put_dtypes(values, indices)
17891792

17901793
with ops.colocate_with(self._coloc_op):

0 commit comments

Comments
 (0)