@@ -127,7 +127,7 @@ def __init__(self,
127
127
128
128
self .final_dir = save_dir
129
129
if not os .path .exists (self .final_dir ):
130
- os .makedirs (self .final_dir )
130
+ os .makedirs (self .final_dir , exist_ok = True )
131
131
132
132
# load config
133
133
if isinstance (config , str ):
@@ -263,7 +263,7 @@ def _infer_shape(self, model_dir, model_filename, params_filename,
263
263
op .desc .infer_shape (block .desc )
264
264
265
265
save_path = os .path .join (save_path , "infered_shape" )
266
- os .makedirs (save_path )
266
+ os .makedirs (save_path , exist_ok = True )
267
267
paddle .static .save_inference_model (
268
268
save_path ,
269
269
feed_vars ,
@@ -763,8 +763,13 @@ def single_strategy_compress(self, strategy, config, strategy_idx,
763
763
inference_program , feed_target_names , fetch_targets , patterns ,
764
764
strategy , config , train_config )
765
765
if 'unstructure' in strategy :
766
- test_program_info .program ._program = remove_unused_var_nodes (
767
- test_program_info .program ._program )
766
+ if isinstance (test_program_info .program ,
767
+ paddle .static .CompiledProgram ):
768
+ test_program_info .program ._program = remove_unused_var_nodes (
769
+ test_program_info .program ._program )
770
+ else :
771
+ test_program_info .program = remove_unused_var_nodes (
772
+ test_program_info .program )
768
773
test_program_info = self ._start_train (
769
774
train_program_info , test_program_info , strategy , train_config )
770
775
if paddle .distributed .get_rank () == 0 :
0 commit comments