Skip to content

Commit fe70d8f

Browse files
Tied a few loose ends:
* Added a test to ensure that we can enqueue / dequeue tensors of half floats * Fixed the description of add_check_numerics_ops Change: 125082343
1 parent 37f56fe commit fe70d8f

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

tensorflow/python/kernel_tests/fifo_queue_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ def testEnqueue(self):
9090
enqueue_op = q.enqueue((10.0,))
9191
enqueue_op.run()
9292

93+
def testEnqueueHalf(self):
94+
with self.test_session():
95+
q = tf.FIFOQueue(10, tf.float16)
96+
enqueue_op = q.enqueue((10.0,))
97+
enqueue_op.run()
98+
9399
def testEnqueueWithShape(self):
94100
with self.test_session():
95101
q = tf.FIFOQueue(10, tf.float32, shapes=(3, 2))
@@ -174,6 +180,20 @@ def testDequeue(self):
174180
vals = dequeued_t.eval()
175181
self.assertEqual([elems[i]], vals)
176182

183+
def testDequeueHalf(self):
184+
with self.test_session():
185+
q = tf.FIFOQueue(10, tf.float16)
186+
elems = [10.0, 20.0, 30.0]
187+
enqueue_ops = [q.enqueue((x,)) for x in elems]
188+
dequeued_t = q.dequeue()
189+
190+
for enqueue_op in enqueue_ops:
191+
enqueue_op.run()
192+
193+
for i in xrange(len(elems)):
194+
vals = dequeued_t.eval()
195+
self.assertEqual([elems[i]], vals)
196+
177197
def testEnqueueAndBlockingDequeue(self):
178198
with self.test_session() as sess:
179199
q = tf.FIFOQueue(3, tf.float32)

tensorflow/python/ops/numerics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16-
"""Connects all float and double tensors to CheckNumericsOp."""
16+
"""Connects all half, float and double tensors to CheckNumericsOp."""
1717

1818
from __future__ import absolute_import
1919
from __future__ import division
@@ -47,10 +47,10 @@ def verify_tensor_all_finite(t, msg, name=None):
4747
def add_check_numerics_ops():
4848
"""Connect a `check_numerics` to every floating point tensor.
4949
50-
`check_numerics` operations themselves are added for each `float` or `double`
51-
tensor in the graph. For all ops in the graph, the `check_numerics` op for
52-
all of its (`float` or `double`) inputs is guaranteed to run before the
53-
`check_numerics` op on any of its outputs.
50+
`check_numerics` operations themselves are added for each `half`, `float`,
51+
or `double` tensor in the graph. For all ops in the graph, the
52+
`check_numerics` op for all of its (`half`, `float`, or `double`) inputs
53+
is guaranteed to run before the `check_numerics` op on any of its outputs.
5454
5555
Returns:
5656
A `group` op depending on all `check_numerics` ops added.

0 commit comments

Comments
 (0)