From 8db6d221772d95fe96181d199b1458b3707e0cfd Mon Sep 17 00:00:00 2001 From: Haipeng Wang Date: Mon, 27 Sep 2021 12:45:31 +0800 Subject: [PATCH] support saving model defined parameters without add scale_op (#36119) * add scale_op in model save step is not necessary, just fix the prune method to support static graph and inplace op * fix jit.save, no need to add scale_op to each outputvar anymore. fix prune_with_input, now it supports inplace op * temporarily disable test_trt_dynamic_shape.TRTDynamicShapeOutOfBound2Test * allow user to export parameters defined in model --- 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 11e7e7c2f7..b6241f6e52 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 f050b3995b..e110c47d79 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