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

Method testInterleave

tensorflow/python/grappler/datasets_test.py:332–365  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

330 op_properties['IteratorGetNext'][0].shape)
331
332 def testInterleave(self):
333 test_cases = [{
334 'tensor': 0,
335 'shape': tensor_shape.TensorShape([])
336 }, {
337 'tensor': np.array([1, 2, 3]),
338 'shape': tensor_shape.TensorShape([3])
339 }, {
340 'tensor': np.array([[1, 2, 3]]),
341 'shape': tensor_shape.TensorShape([1, 3])
342 }]
343
344 for test_case in test_cases:
345 with ops.Graph().as_default() as g:
346 dataset = dataset_ops.Dataset.range(42)
347
348 def make_dataset(tensor):
349
350 def dataset_fn(n):
351 return dataset_ops.Dataset.from_tensors(tensor).repeat(n)
352
353 return dataset_fn
354
355 dataset = dataset.interleave(
356 make_dataset(test_case['tensor']), cycle_length=42)
357 iterator = dataset_ops.make_one_shot_iterator(dataset)
358 get_next = iterator.get_next()
359 train_op = ops.get_collection_ref(ops.GraphKeys.TRAIN_OP)
360 train_op.append(get_next)
361 mg = meta_graph.create_meta_graph_def(graph=g)
362 grappler_item = item.Item(mg)
363 op_properties = grappler_item.GetOpProperties()
364 self.assertEqual(test_case['shape'],
365 op_properties['IteratorGetNext'][0].shape)
366
367 def testMap(self):
368 test_cases = [{

Callers

nothing calls this directly

Calls 11

GetOpPropertiesMethod · 0.95
get_collection_refMethod · 0.80
ItemMethod · 0.80
make_datasetFunction · 0.50
as_defaultMethod · 0.45
GraphMethod · 0.45
rangeMethod · 0.45
interleaveMethod · 0.45
get_nextMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected