def testMaxIntraOpParallelismAsGraphDefInternal(self): dataset = dataset_ops.Dataset.from_tensors(0) dataset = dataset_ops._MaxIntraOpParallelismDataset(dataset, 1) graph = graph_pb2.GraphDef().FromString( self.evaluate(dataset._as_serialized_graph())) self.assertTrue( any([node.op != "MaxIntraOpParallelismDataset" for node in graph.node]))
def testMaxIntraOpParallelism(self): dataset = dataset_ops.Dataset.list_files(self.test_filenames, shuffle=False) dataset = dataset.flat_map(core_readers.TFRecordDataset) dataset = dataset.batch(5) dataset = dataset_ops._MaxIntraOpParallelismDataset(dataset, 1) dataset = distribute._AutoShardDataset(dataset, 5, 0) expected = [ b"Record %d of file %d" % (r, f) # pylint:disable=g-complex-comprehension for f in (0, 5) for r in range(0, 10) ] self.assertDatasetProduces(dataset, list(chunk(expected, 5)))