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

Method test_sparse

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

Source from the content-addressed store, hash-verified

73 coord.request_stop()
74
75 def test_sparse(self):
76 with ops.Graph().as_default() as graph:
77 with ops.device('/cpu:0'):
78 values = array_ops.constant([1, 1, 1], dtype=dtypes.int64)
79 indices = array_ops.constant(
80 ([0, 0], [0, 1], [0, 2]), dtype=dtypes.int64)
81 dense_shape = array_ops.constant([3, 3], dtype=dtypes.int64)
82
83 x = sparse_tensor.SparseTensor(values=values,
84 indices=indices,
85 dense_shape=dense_shape)
86 with ops.device(test.gpu_device_name()):
87 y = prefetch.staged(x, timeout_millis=1000)
88
89 graph.finalize()
90
91 with self.test_session(use_gpu=True, graph=graph) as sess:
92 values_data = sess.run(values)
93 indices_data = sess.run(indices)
94 dense_shape_data = sess.run(dense_shape)
95 coord = coordinator.Coordinator()
96 prefetch.make_prefetch_hook().after_create_session(sess, coord)
97 for _ in xrange(3):
98 prefetched = sess.run(y)
99 self.assertAllClose(values_data, prefetched.values, rtol=1e-6)
100 self.assertAllClose(indices_data, prefetched.indices, rtol=1e-6)
101 self.assertAllClose(dense_shape_data, prefetched.dense_shape, rtol=1e-6)
102 coord.request_stop()
103
104 def test_list(self):
105 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