Skip to content

Commit dfe5bb3

Browse files
authored
save model with clip_extra=False (#1530)
1 parent 717d726 commit dfe5bb3

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

paddleslim/auto_compression/compressor.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ def _infer_shape(self, model_dir, model_filename, params_filename,
265265
save_path = os.path.join(save_path, "infered_shape")
266266
os.makedirs(save_path)
267267
paddle.static.save_inference_model(
268-
save_path, feed_vars, fetch_targets, exe, program=inference_program)
268+
save_path,
269+
feed_vars,
270+
fetch_targets,
271+
exe,
272+
program=inference_program,
273+
clip_extra=False)
269274
_logger.info(f"Saved model infered shape to {save_path}")
270275

271276
@property
@@ -901,7 +906,8 @@ def _save_model(self, test_program_info, strategy, strategy_idx):
901906
feed_vars=feed_vars,
902907
fetch_vars=test_program_info.fetch_targets,
903908
executor=self._exe,
904-
program=test_program)
909+
program=test_program,
910+
clip_extra=False)
905911

906912
def export_onnx(self,
907913
model_name='quant_model.onnx',

paddleslim/auto_compression/utils/fake_ptq.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,6 @@ def analysis_and_save_info(op_node, out_var_name):
169169
feed_vars=feed_vars,
170170
fetch_vars=_fetch_list,
171171
executor=executor,
172-
program=_program)
172+
program=_program,
173+
clip_extra=False)
173174
print("The quantized model is saved in: " + save_model_path)

paddleslim/auto_compression/utils/prune_model.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def get_sparse_model(executor, places, model_file, param_file, ratio,
9595
feed_vars=feed_vars,
9696
fetch_vars=fetch_targets,
9797
executor=executor,
98-
program=inference_program)
98+
program=inference_program,
99+
clip_extra=False)
99100
print("The pruned model is saved in: ", save_path)
100101

101102

@@ -170,4 +171,5 @@ def get_prune_model(executor, places, model_file, param_file, ratio, save_path):
170171
feed_vars=feed_vars,
171172
fetch_vars=fetch_targets,
172173
executor=executor,
173-
program=main_program)
174+
program=main_program,
175+
clip_extra=False)

0 commit comments

Comments
 (0)