4040from tensorflow .python .ipu import ipu_compiler , scopes , loops , ipu_infeed_queue , ipu_outfeed_queue
4141from tensorflow .python .ipu import dataset_benchmark
4242from tensorflow .python .ipu import rand_ops
43- from tensorflow .python .ipu . config import IPUConfig
43+ from tensorflow .python .ipu import config
4444from tensorflow .python .ipu .ops import application_compile_op
4545from tensorflow .compat .v1 import disable_v2_behavior
4646from tensorflow .python .training import momentum
@@ -151,7 +151,7 @@ def run_and_export_model(tmp_dir,
151151 saver = train .Saver ()
152152
153153 # Setup and acquire an IPU device:
154- cfg = IPUConfig ()
154+ cfg = config . IPUConfig ()
155155 cfg .auto_select_ipus = 2 if pipelined else 1
156156 tu .add_hw_ci_connection_options (cfg )
157157 cfg .configure_ipu_system ()
@@ -212,6 +212,8 @@ def run_and_export_model(tmp_dir,
212212 print (f" Compiling and exporting..." )
213213 sess .run (compile_op )
214214
215+ config .reset_ipu_configuration ()
216+
215217 return model_ref
216218
217219
@@ -513,7 +515,6 @@ def test_embedded_runtime_wrapper(self):
513515 infeeds = (images ,)
514516 result = embedded_runtime .embedded_runtime_call (infeeds , ctx )
515517
516- session .run (variables .global_variables_initializer ())
517518 for j in range (n_test ):
518519 images_host = images_all [j , :, :]
519520
@@ -681,7 +682,7 @@ def my_net():
681682 outfeed_queue = outfeed_queue )
682683
683684 with tu .ipu_session () as sess :
684- cfg = IPUConfig ()
685+ cfg = config . IPUConfig ()
685686 cfg .auto_select_ipus = 2
686687 tu .add_hw_ci_connection_options (cfg )
687688 cfg .configure_ipu_system ()
@@ -692,6 +693,7 @@ def my_net():
692693 compile_op = application_compile_op .experimental_application_compile_op (
693694 my_net , output_path = poplar_exec_filepath )
694695 sess .run (compile_op )
696+ config .reset_ipu_configuration ()
695697
696698 ctx = embedded_runtime .embedded_runtime_start (poplar_exec_filepath , [],
697699 "pipeline_flush" )
@@ -724,7 +726,7 @@ def my_net():
724726 return loops .repeat (10 , body , [], infeed_queue )
725727
726728 with tu .ipu_session () as sess :
727- cfg = IPUConfig ()
729+ cfg = config . IPUConfig ()
728730 cfg .auto_select_ipus = 1
729731 cfg .io_tiles .num_io_tiles = 32
730732 cfg .io_tiles .place_ops_on_io_tiles = True
@@ -737,6 +739,7 @@ def my_net():
737739 compile_op = application_compile_op .experimental_application_compile_op (
738740 my_net , output_path = poplar_exec_filepath )
739741 sess .run (compile_op )
742+ config .reset_ipu_configuration ()
740743
741744 ctx = embedded_runtime .embedded_runtime_start (poplar_exec_filepath , [],
742745 "io_overlap_flush" )
@@ -775,7 +778,7 @@ def my_net(outq, a, b, c):
775778 c_ph = array_ops .placeholder (dtypes .float32 , shape = (2 ), name = 'c' )
776779
777780 with tu .ipu_session () as sess , tempfile .TemporaryDirectory () as tmp_dir :
778- cfg = IPUConfig ()
781+ cfg = config . IPUConfig ()
779782 cfg .auto_select_ipus = 1
780783 tu .add_hw_ci_connection_options (cfg )
781784 cfg .configure_ipu_system ()
@@ -786,6 +789,7 @@ def my_net(outq, a, b, c):
786789 compile_op = application_compile_op .experimental_application_compile_op (
787790 model , output_path = poplar_exec_filepath )
788791 sess .run (compile_op )
792+ config .reset_ipu_configuration ()
789793
790794 ctx = embedded_runtime .embedded_runtime_start (poplar_exec_filepath , [],
791795 "multiple_infeeds" )
@@ -817,7 +821,7 @@ def exception_executable(tmp_dir):
817821 poplar_exec_filepath = os .path .join (tmp_dir .name ,
818822 "application.poplar_exec" )
819823
820- cfg = IPUConfig ()
824+ cfg = config . IPUConfig ()
821825 cfg .auto_select_ipus = 1
822826 cfg .floating_point_behaviour .div0 = True
823827 tu .add_hw_ci_connection_options (cfg )
@@ -828,6 +832,7 @@ def exception_executable(tmp_dir):
828832 my_net , output_path = poplar_exec_filepath )
829833 with sl .Session () as sess :
830834 sess .run (compile_op )
835+ config .reset_ipu_configuration ()
831836
832837 return poplar_exec_filepath
833838
0 commit comments