MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / test_dict

Method test_dict

tensorflow/python/ops/prefetch_test.py:139–171  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

137 coord.request_stop()
138
139 def test_dict(self):
140 with ops.Graph().as_default() as graph:
141 with ops.device('/cpu:0'):
142 values = array_ops.constant([1, 1, 1], dtype=dtypes.int64)
143 indices = array_ops.constant(
144 ([0, 0], [0, 1], [0, 2]), dtype=dtypes.int64)
145 dense_shape = array_ops.constant([3, 3], dtype=dtypes.int64)
146
147 x1 = sparse_tensor.SparseTensor(values=values,
148 indices=indices,
149 dense_shape=dense_shape)
150 x2 = array_ops.constant(42.0, dtype=dtypes.float32, shape=[])
151 x = {'foo': x2, 'bar': x1}
152 with ops.device(test.gpu_device_name()):
153 y = prefetch.staged(x, timeout_millis=1000)
154
155 graph.finalize()
156
157 with self.test_session(use_gpu=True, graph=graph) as sess:
158 values_data = sess.run(values)
159 indices_data = sess.run(indices)
160 dense_shape_data = sess.run(dense_shape)
161 x2_data = sess.run(x2)
162 coord = coordinator.Coordinator()
163 prefetch.make_prefetch_hook().after_create_session(sess, coord)
164 for _ in xrange(3):
165 prefetched = sess.run(y)
166 self.assertAllClose(values_data, prefetched['bar'].values, rtol=1e-6)
167 self.assertAllClose(indices_data, prefetched['bar'].indices, rtol=1e-6)
168 self.assertAllClose(
169 dense_shape_data, prefetched['bar'].dense_shape, rtol=1e-6)
170 self.assertAllClose(x2_data, prefetched['foo'], rtol=1e-6)
171 coord.request_stop()
172
173 def test_dict_from_feeds(self):
174 with ops.Graph().as_default() as graph:

Callers

nothing calls this directly

Calls 11

request_stopMethod · 0.95
CoordinatorMethod · 0.80
as_defaultMethod · 0.45
GraphMethod · 0.45
deviceMethod · 0.45
constantMethod · 0.45
finalizeMethod · 0.45
test_sessionMethod · 0.45
runMethod · 0.45
after_create_sessionMethod · 0.45
assertAllCloseMethod · 0.45

Tested by

no test coverage detected