From e2fdb0808bccf0f1432f96613e03af16d7947bc2 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Fri, 26 Nov 2021 11:28:30 +0800 Subject: [PATCH] fix bug of slice_grad using use_mkldnn attr (#37571) --- 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 4b1b0d4f05c..6ef44fb127a 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1065,8 +1065,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); } -- GitLab