From 044ac98d5bae1569ada9769f802399cb79a550e5 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 25 Nov 2021 16:20:21 +0000 Subject: [PATCH] fix bug of slice_grad using use_mkldnn attr --- paddle/fluid/framework/operator.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 1a60acf49a46fd..c911a450e19db8 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1064,8 +1064,9 @@ bool OperatorWithKernel::SupportsMKLDNN( bool OperatorWithKernel::CanMKLDNNBeUsed(const framework::ExecutionContext& ctx, proto::VarType::Type data_type) const { - bool use_mkldnn_ctx = - ctx.Attr("use_mkldnn") && platform::is_cpu_place(ctx.GetPlace()); + bool use_mkldnn_ctx = ctx.HasAttr("use_mkldnn") && + ctx.Attr("use_mkldnn") && + platform::is_cpu_place(ctx.GetPlace()); return use_mkldnn_ctx && this->SupportsMKLDNN(data_type); }