(self)
| 102 | coord.request_stop() |
| 103 | |
| 104 | def test_list(self): |
| 105 | with ops.Graph().as_default() as graph: |
| 106 | with ops.device('/cpu:0'): |
| 107 | values = array_ops.constant([1, 1, 1], dtype=dtypes.int64) |
| 108 | indices = array_ops.constant( |
| 109 | ([0, 0], [0, 1], [0, 2]), dtype=dtypes.int64) |
| 110 | dense_shape = array_ops.constant([3, 3], dtype=dtypes.int64) |
| 111 | |
| 112 | x1 = sparse_tensor.SparseTensor(values=values, |
| 113 | indices=indices, |
| 114 | dense_shape=dense_shape) |
| 115 | x2 = array_ops.constant(42.0, dtype=dtypes.float32, shape=[]) |
| 116 | x = [x1, x2] |
| 117 | with ops.device(test.gpu_device_name()): |
| 118 | y = prefetch.staged(x, timeout_millis=1000) |
| 119 | |
| 120 | graph.finalize() |
| 121 | |
| 122 | with self.test_session(use_gpu=True, graph=graph) as sess: |
| 123 | values_data = sess.run(values) |
| 124 | indices_data = sess.run(indices) |
| 125 | dense_shape_data = sess.run(dense_shape) |
| 126 | x2_data = sess.run(x2) |
| 127 | coord = coordinator.Coordinator() |
| 128 | prefetch.make_prefetch_hook().after_create_session(sess, coord) |
| 129 | for _ in xrange(3): |
| 130 | prefetched = sess.run(y) |
| 131 | self.assertAllClose(values_data, prefetched[0].values, rtol=1e-6) |
| 132 | self.assertAllClose(indices_data, prefetched[0].indices, rtol=1e-6) |
| 133 | self.assertAllClose( |
| 134 | dense_shape_data, prefetched[0].dense_shape, |
| 135 | rtol=1e-6) |
| 136 | self.assertAllClose(x2_data, prefetched[1], rtol=1e-6) |
| 137 | coord.request_stop() |
| 138 | |
| 139 | def test_dict(self): |
| 140 | with ops.Graph().as_default() as graph: |
nothing calls this directly
no test coverage detected