From 05e4be6b664ec8f65ed43c20eb8932a2d904bf0a Mon Sep 17 00:00:00 2001 From: winter-wang <1030748926@qq.com> Date: Thu, 26 Aug 2021 09:10:46 +0000 Subject: [PATCH] fix the crash when input variable is bool type, test=develop --- python/paddle/fluid/io.py | 2 +- python/paddle/static/io.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/io.py b/python/paddle/fluid/io.py index 8961a33b508c18..9d02809e544774 100644 --- a/python/paddle/fluid/io.py +++ b/python/paddle/fluid/io.py @@ -1378,7 +1378,7 @@ def save_inference_model(dirname, with program_guard(main_program): uniq_target_vars = [] for i, var in enumerate(target_vars): - if isinstance(var, Variable): + if isinstance(var, Variable) and var.dtype != paddle.bool: var = layers.scale( var, 1., name="save_infer_model/scale_{}".format(i)) uniq_target_vars.append(var) diff --git a/python/paddle/static/io.py b/python/paddle/static/io.py index d251e273befd1c..677218cc4c0e85 100644 --- a/python/paddle/static/io.py +++ b/python/paddle/static/io.py @@ -192,8 +192,9 @@ def normalize_program(program, feed_vars, fetch_vars): with program_guard(program): uniq_fetch_vars = [] for i, var in enumerate(fetch_vars): - var = layers.scale( - var, 1., name="save_infer_model/scale_{}".format(i)) + if var.dtype != paddle.bool: + var = layers.scale( + var, 1., name="save_infer_model/scale_{}".format(i)) uniq_fetch_vars.append(var) fetch_vars = uniq_fetch_vars