From 377a5ce1269c7f05b5f19b72360bd1a6800b8454 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Mon, 8 Jun 2020 12:48:28 +0800 Subject: [PATCH] Clean fluid.compiler.CompiledProgram (#891) --- slim/distillation/distill.py | 2 +- slim/extensions/distill_pruned_model/distill_pruned_model.py | 2 +- slim/nas/train_nas.py | 2 +- slim/prune/eval.py | 3 +-- slim/prune/prune.py | 2 +- slim/quantization/eval.py | 3 +-- slim/quantization/train.py | 2 +- slim/sensitive/sensitive.py | 2 +- tools/eval.py | 3 +-- tools/train.py | 2 +- 10 files changed, 10 insertions(+), 13 deletions(-) diff --git a/slim/distillation/distill.py b/slim/distillation/distill.py index f95fc264e..dd3a86c0f 100644 --- a/slim/distillation/distill.py +++ b/slim/distillation/distill.py @@ -305,7 +305,7 @@ def main(): build_strategy=build_strategy, exec_strategy=exec_strategy) - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) # whether output bbox is normalized in model output layer is_bbox_normalized = False diff --git a/slim/extensions/distill_pruned_model/distill_pruned_model.py b/slim/extensions/distill_pruned_model/distill_pruned_model.py index 71059202c..a2adc6cf7 100644 --- a/slim/extensions/distill_pruned_model/distill_pruned_model.py +++ b/slim/extensions/distill_pruned_model/distill_pruned_model.py @@ -276,7 +276,7 @@ def main(): loss_name=loss.name, build_strategy=build_strategy, exec_strategy=exec_strategy) - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) # parse eval fetches extra_keys = [] diff --git a/slim/nas/train_nas.py b/slim/nas/train_nas.py index f4eca0e31..3c30c7ffd 100644 --- a/slim/nas/train_nas.py +++ b/slim/nas/train_nas.py @@ -323,7 +323,7 @@ def main(): build_strategy=build_strategy, exec_strategy=exec_strategy) if FLAGS.eval: - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) train_loader.set_sample_list_generator(train_reader, place) diff --git a/slim/prune/eval.py b/slim/prune/eval.py index 53f2005b1..73386d0f7 100644 --- a/slim/prune/eval.py +++ b/slim/prune/eval.py @@ -119,8 +119,7 @@ def main(): logger.info("pruned FLOPS: {}".format( float(base_flops - pruned_flops) / base_flops)) - compile_program = fluid.compiler.CompiledProgram( - eval_prog).with_data_parallel() + compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel() assert cfg.metric != 'OID', "eval process of OID dataset \ is not supported." diff --git a/slim/prune/prune.py b/slim/prune/prune.py index f6b219b36..01b3488d7 100644 --- a/slim/prune/prune.py +++ b/slim/prune/prune.py @@ -215,7 +215,7 @@ def main(): logger.info("FLOPs -{}; total FLOPs: {}; pruned FLOPs: {}".format( float(base_flops - pruned_flops) / base_flops, base_flops, pruned_flops)) - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) if FLAGS.resume_checkpoint: checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint) diff --git a/slim/quantization/eval.py b/slim/quantization/eval.py index 037bbcfd3..ecc77e45f 100644 --- a/slim/quantization/eval.py +++ b/slim/quantization/eval.py @@ -132,8 +132,7 @@ def main(): checkpoint.load_params(exe, eval_prog, cfg.weights) eval_prog = convert(eval_prog, place, config, save_int8=False) - compile_program = fluid.compiler.CompiledProgram( - eval_prog).with_data_parallel() + compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel() results = eval_run(exe, compile_program, loader, keys, values, cls, cfg, sub_eval_prog, sub_keys, sub_values) diff --git a/slim/quantization/train.py b/slim/quantization/train.py index 734dc39d4..63c65816b 100644 --- a/slim/quantization/train.py +++ b/slim/quantization/train.py @@ -200,7 +200,7 @@ def main(): if FLAGS.eval: # insert quantize op in eval_prog eval_prog = quant_aware(eval_prog, place, config, for_test=True) - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) start_iter = 0 if FLAGS.resume_checkpoint: diff --git a/slim/sensitive/sensitive.py b/slim/sensitive/sensitive.py index 23581fead..4ddea2015 100644 --- a/slim/sensitive/sensitive.py +++ b/slim/sensitive/sensitive.py @@ -122,7 +122,7 @@ def main(): def test(program): - compiled_eval_prog = fluid.compiler.CompiledProgram(program) + compiled_eval_prog = fluid.CompiledProgram(program) results = eval_run( exe, diff --git a/tools/eval.py b/tools/eval.py index 40840503f..2c822638f 100644 --- a/tools/eval.py +++ b/tools/eval.py @@ -88,8 +88,7 @@ def main(): cfg.metric, json_directory=FLAGS.output_eval, dataset=dataset) return - compile_program = fluid.compiler.CompiledProgram( - eval_prog).with_data_parallel() + compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel() assert cfg.metric != 'OID', "eval process of OID dataset \ is not supported." diff --git a/tools/train.py b/tools/train.py index 20ae45f0c..017fed672 100644 --- a/tools/train.py +++ b/tools/train.py @@ -180,7 +180,7 @@ def main(): exec_strategy=exec_strategy) if FLAGS.eval: - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) + compiled_eval_prog = fluid.CompiledProgram(eval_prog) fuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel' -- GitLab