From 62d448364942b8131b35e1ad2f00b86b6fb586d3 Mon Sep 17 00:00:00 2001 From: arlesniak Date: Mon, 14 Dec 2020 14:07:57 +0100 Subject: [PATCH] Added verbose oneDNN lib version (#29378) --- paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc | 1 + paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc | 1 + paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc | 1 + paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc | 1 + paddle/fluid/platform/device_context.cc | 9 +++++++++ paddle/fluid/platform/device_context.h | 2 ++ paddle/fluid/platform/mkldnn_reuse.h | 8 ++++++-- 7 files changed, 21 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc index ea9b629d90e..63aa2357bee 100644 --- a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc @@ -144,6 +144,7 @@ class ConcatMKLDNNOpKernel : public paddle::framework::OpKernel { platform::errors::InvalidArgument( "The axis is expected to be in range of [%d, %d), but got %d", -rank, rank, concat_axis)); + platform::MKLDNNDeviceContext::tls().log_lib_version(); if (concat_axis < 0) { concat_axis = concat_axis + rank; } diff --git a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc index c0cfbd089f7..613d193477b 100644 --- a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc @@ -572,6 +572,7 @@ class FCMKLDNNOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ( platform::is_cpu_place(ctx.GetPlace()), true, platform::errors::PreconditionNotMet("FC MKL-DNN must use CPUPlace.")); + platform::MKLDNNDeviceContext::tls().log_lib_version(); auto input = ctx.Input("Input"); auto w = ctx.Input("W"); auto bias = ctx.Input("Bias"); diff --git a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc index 92be4d19e75..fddc4b4b2e5 100644 --- a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc @@ -378,6 +378,7 @@ class DNNLMatMulKernel : public framework::OpKernel { platform::errors::Unimplemented( "DNNL matmul doesn't support multiple heads.")); } + platform::MKLDNNDeviceContext::tls().log_lib_version(); ExecuteMatMul(ctx); } }; diff --git a/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc index 4174d88de61..46d51606d42 100644 --- a/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc @@ -353,6 +353,7 @@ class MulMKLDNNKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(platform::is_cpu_place(ctx.GetPlace()), true, paddle::platform::errors::PreconditionNotMet( "Operator DNNL Mul must use CPUPlace")); + platform::MKLDNNDeviceContext::tls().log_lib_version(); auto &dev_ctx = ctx.template device_context(); const auto &mkldnn_engine = dev_ctx.GetEngine(); diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index 4922fbeacc6..297466e8e5a 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -466,6 +466,15 @@ MKLDNNDeviceContextThreadLocals::Body::get_cur_paddle_data_layout(void) { return cur_paddle_data_layout; } +void MKLDNNDeviceContextThreadLocals::Body::log_lib_version(void) { + if (!said_once) { + said_once = true; + auto dv = dnnl::version(); + LOG(INFO) << "oneDNN v" << dv->major << "." << dv->minor << "." + << dv->patch; + } +} + void MKLDNNDeviceContext::ResetBlobMap() { std::lock_guard lock(*p_mutex_); if (!block_next_cache_clearing_) { diff --git a/paddle/fluid/platform/device_context.h b/paddle/fluid/platform/device_context.h index 8661c5e2ce2..56438a95f2a 100644 --- a/paddle/fluid/platform/device_context.h +++ b/paddle/fluid/platform/device_context.h @@ -466,6 +466,7 @@ class MKLDNNDeviceContextThreadLocals { typedef MKLDNNDeviceContextThreadLocals self; struct Body { + bool said_once = false; size_t cur_mkldnn_session_id; // Current data input shape string. // - For fixed-shape, it's a null string in default. @@ -485,6 +486,7 @@ class MKLDNNDeviceContextThreadLocals { void set_cur_input_shape_cache_capacity(int input_shape_cache_capacity); void set_cur_paddle_data_layout(framework::DataLayout dl); framework::DataLayout get_cur_paddle_data_layout(void); + void log_lib_version(void); }; MKLDNNDeviceContextThreadLocals() = default; MKLDNNDeviceContextThreadLocals(const MKLDNNDeviceContextThreadLocals& c) = diff --git a/paddle/fluid/platform/mkldnn_reuse.h b/paddle/fluid/platform/mkldnn_reuse.h index 03443996b61..c053815aea7 100644 --- a/paddle/fluid/platform/mkldnn_reuse.h +++ b/paddle/fluid/platform/mkldnn_reuse.h @@ -45,7 +45,9 @@ class MKLDNNHandlerT { key_common_(base_key), key_(platform::ExtendKeyWithThreadInfoIfNeeded(dev_ctx, base_key)), fwd_pd_(nullptr), - bwd_pd_(nullptr) {} + bwd_pd_(nullptr) { + platform::MKLDNNDeviceContext::tls().log_lib_version(); + } std::shared_ptr AcquireForwardPrimitive() { const std::string key_p = key_ + "@fwd_p"; @@ -313,7 +315,9 @@ class MKLDNNHandler { : dev_ctx_(dev_ctx), engine_(engine), key_common_(base_key), - key_(platform::ExtendKeyWithThreadInfoIfNeeded(dev_ctx, base_key)) {} + key_(platform::ExtendKeyWithThreadInfoIfNeeded(dev_ctx, base_key)) { + platform::MKLDNNDeviceContext::tls().log_lib_version(); + } std::shared_ptr AcquireSrcMemory( const mkldnn::memory::desc& md, void* ptr) { -- GitLab