Esempio n. 1
0
 def testDebugModeSequentialExecution(self):
     dataset_ops.toggle_debug_mode(True)
     ds = dataset_ops.Dataset.range(10)
     ds = ds.apply(
         testing.assert_next(["Interleave", "Map", "Batch", "FiniteTake"]))
     ds = ds.interleave(lambda x: dataset_ops.Dataset.from_tensors(x),
                        cycle_length=10,
                        num_parallel_calls=10)
     ds = ds.map(lambda x: x * x, num_parallel_calls=10)
     ds = ds.batch(batch_size=5, num_parallel_calls=2)
     ds = ds.prefetch(buffer_size=2)
     ds = ds.take(2)
     self.assertDatasetProduces(ds,
                                [[0, 1, 4, 9, 16], [25, 36, 49, 64, 81]])
     dataset_ops.toggle_debug_mode(False)
Esempio n. 2
0
    def testDebugModeEagerExecution(self):
        dataset_ops.toggle_debug_mode(True)
        counter = []
        ds = dataset_ops.Dataset.range(10)

        def map_fn(x):
            counter.append(1)
            return x

        ds = ds.map(map_fn)
        self.assertDatasetProduces(ds, list(range(10)))

        # The body of `map_fn` will be executed 11 times since the implementation
        # traces the function to figure out what the types and shapes of its
        # outputs are.
        self.assertLen(counter, 11)
        dataset_ops.toggle_debug_mode(False)
Esempio n. 3
0
 def tearDown(self):
     dataset_ops.toggle_debug_mode(False)
     super(DebugDatasetTest, self).tearDown()
Esempio n. 4
0
 def setUp(self):
     super(DebugDatasetTest, self).setUp()
     dataset_ops.toggle_debug_mode(True)