diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 4b1b0d4f05c4baffc7d9e7d7dab3d09a7a679864..6ef44fb127afbe56207136116fbc09e933b1c7f0 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); }