From 5f168af7a53ac227d29ca174824707698e642a64 Mon Sep 17 00:00:00 2001 From: Haipeng Wang Date: Mon, 27 Sep 2021 15:13:36 +0800 Subject: [PATCH] allow user to export parameters defined in model (#36132) --- python/paddle/fluid/framework.py | 6 +----- python/paddle/fluid/io.py | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 11e7e7c2f7c..b6241f6e529 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -5074,11 +5074,7 @@ class Program(object): else: target_op = op - if target_op is None: - raise ValueError( - "The target variable used for pruning should have an " - "associated operator that generates it.") - else: + if target_op is not None: targets_idx.append([target_op.block.idx, target_op.idx]) else: targets_idx.append([t.block.idx, t.idx]) diff --git a/python/paddle/fluid/io.py b/python/paddle/fluid/io.py index f050b3995be..e110c47d790 100644 --- a/python/paddle/fluid/io.py +++ b/python/paddle/fluid/io.py @@ -1426,7 +1426,8 @@ def save_inference_model(dirname, main_program.global_block().create_var( name=target_v.name, shape=target_v.shape, - dtype=target_v.dtype) + dtype=target_v.dtype, + persistable=target_v.persistable) prepend_feed_ops(main_program, feeded_var_names) append_fetch_ops(main_program, fetch_var_names) -- GitLab