@@ -774,6 +774,27 @@ def test_multithread_prefetch(self):
774774 steps .append (step )
775775 self .assertEqual (steps , [0 , 1 , 2 ])
776776
777+ def test_check_and_set_cloned_dataset_need_clone (self ):
778+ epl .init ()
779+ epl .set_default_strategy (epl .replicate (1 ))
780+ num_x = np .random .randint (0 , 10 , (500 , 10 )).astype (dtype = np .float32 )
781+ num_y = np .random .randint (0 , 10 , 500 ).astype (dtype = np .int32 )
782+ dataset = tf .data .Dataset .from_tensor_slices ((num_x , num_y )) \
783+ .batch (2 ).repeat (1 )
784+ iterator = dataset .make_initializable_iterator ()
785+ tf .add_to_collection (tf .GraphKeys .TABLE_INITIALIZERS , iterator .initializer )
786+ source , target = iterator .get_next ()
787+ x = tf .layers .dense (inputs = source , units = 16 , activation = None )
788+ x = tf .layers .dense (inputs = x , units = 16 , activation = None )
789+ dense1 = tf .layers .dense (inputs = x , units = 16 , activation = None )
790+ logits = tf .layers .dense (inputs = dense1 , units = 10 , activation = None )
791+ loss = tf .reduce_mean (logits )
792+ global_step = tf .train .get_or_create_global_step ()
793+ optimizer = tf .train .MomentumOptimizer (learning_rate = 0.001 , momentum = 0.9 )
794+ train_op = optimizer .minimize (loss , global_step = global_step )
795+ epl .Graph .get ().check_and_set_cloned_dataset_need_clone ()
796+
797+
777798
778799# pylint: enable=missing-docstring,protected-access,unused-argument,
779800# pylint: enable=line-too-long,bad-continuation,unused-variable
0 commit comments