Tweak GPUCompatibleFIFOQueue's unit test so it runs more configurations

tf.constant places on the CPU executing eagerly, which mismatched with GPU placements later in the test.

Fixes #45662.

PiperOrigin-RevId: 350216699
Change-Id: I2c82b5be99ccdf315f553003efbb1cd90672b992
This commit is contained in:
Allen Lavoie 2021-01-05 14:11:22 -08:00 committed by TensorFlower Gardener
parent 866d081cb4
commit 671c78343c

View File

@ -415,7 +415,9 @@ class GPUCompatibleFIFOQueueTests(test.TestCase):
with test_util.use_gpu():
q = data_flow_ops.GPUCompatibleFIFOQueue(10, dtypes_lib.float32)
elems_numpy = [10.0, 20.0, 30.0]
elems = [constant_op.constant(x) for x in elems_numpy]
# The identity ensures constants are copied to the GPU immediately
elems = [array_ops.identity(constant_op.constant(x))
for x in elems_numpy]
for x in elems:
self.evaluate(q.enqueue((x,)))