From 435f942b84c6988e7862ddd2951c6db75aba0a3d Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Tue, 15 Oct 2019 15:45:18 +0800 Subject: [PATCH] fix persistable test=develop (#2191) --- mobile/tools/python/fluidtools/run.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mobile/tools/python/fluidtools/run.py b/mobile/tools/python/fluidtools/run.py index 6fa5842009..4773222536 100644 --- a/mobile/tools/python/fluidtools/run.py +++ b/mobile/tools/python/fluidtools/run.py @@ -26,6 +26,7 @@ quantification = False quantification_fold = 1000 architecture = "arm-v7a" # architecture = "arm-v8a" +correct_persistable = False np.set_printoptions(linewidth=150) @@ -69,6 +70,18 @@ exe.run(fluid.default_startup_program()) # 加载模型 def load_model(model_path): prog, feeds, fetches = fluid.io.load_inference_model(dirname=model_path, executor=exe, model_filename="model", params_filename="params") + global correct_persistable + if correct_persistable: + ops = prog.current_block().ops + vars = prog.current_block().vars + for op in ops: + for var_name in op.output_arg_names: + if var_name == "fetch": + continue + var = vars[var_name] + if var.persistable: + pp_red("has found non-persistable output var : {}".format(var_name)) + var.persistable = False return (prog, feeds, fetches) prog, feeds, fetches = load_model(model_path) -- GitLab