From 4fe1bb45284cb7b172069f9a39587e154e346520 Mon Sep 17 00:00:00 2001 From: ceci3 Date: Fri, 3 Sep 2021 11:22:57 +0800 Subject: [PATCH] fix mean/variance when is_test=True (#35328) --- paddle/fluid/operators/batch_norm_op.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/batch_norm_op.cc b/paddle/fluid/operators/batch_norm_op.cc index 4f22d28a450..3467658e894 100644 --- a/paddle/fluid/operators/batch_norm_op.cc +++ b/paddle/fluid/operators/batch_norm_op.cc @@ -848,7 +848,8 @@ void BatchNormGradMaker::Apply(GradOpPtr op) const { } // used when setting use_global_stats True during training - if (BOOST_GET_CONST(bool, this->GetAttr("use_global_stats"))) { + if (BOOST_GET_CONST(bool, this->GetAttr("use_global_stats")) || + BOOST_GET_CONST(bool, this->GetAttr("is_test"))) { op->SetInput("Mean", this->Output("MeanOut")); op->SetInput("Variance", this->Output("VarianceOut")); } -- GitLab