diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index c847467294d5e093b23688b1c66a7579c51a737e..cb459f3834bd6deac212811a8dcd5df841f57060 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1066,8 +1066,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); }