未验证 提交 ef04d3d3 编写于 作者: A arlesniak 提交者: GitHub

[bug fix] Added verbose oneDNN lib version (#29671)

 fix #27935 (comment) by QA @OliverLPH (Could you add some MKLDNN-related print log when use FLAGS_use_mkldnn?)
上级 f791438f
......@@ -144,6 +144,7 @@ class ConcatMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
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;
}
......
......@@ -561,6 +561,7 @@ class FCMKLDNNOpKernel : public framework::OpKernel<T_in> {
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<LoDTensor>("Input");
auto w = ctx.Input<Tensor>("W");
auto bias = ctx.Input<Tensor>("Bias");
......
......@@ -379,6 +379,7 @@ class DNNLMatMulKernel : public framework::OpKernel<T> {
platform::errors::Unimplemented(
"DNNL matmul doesn't support multiple heads."));
}
platform::MKLDNNDeviceContext::tls().log_lib_version();
ExecuteMatMul<T, T>(ctx);
}
};
......
......@@ -342,6 +342,7 @@ class MulMKLDNNKernel : public framework::OpKernel<XT> {
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<MKLDNNDeviceContext>();
const auto &mkldnn_engine = dev_ctx.GetEngine();
......
......@@ -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<decltype(*p_mutex_)> lock(*p_mutex_);
if (!block_next_cache_clearing_) {
......
......@@ -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) =
......
......@@ -45,6 +45,7 @@ class MKLDNNHandlerT {
key_common_(base_key),
fwd_pd_(nullptr),
bwd_pd_(nullptr) {
platform::MKLDNNDeviceContext::tls().log_lib_version();
if (platform::MKLDNNDeviceContext::tls().get_cur_mkldnn_session_id() !=
platform::MKLDNNDeviceContextThreadLocals::kMKLDNNSessionID_Default) {
key_ = key_common_;
......@@ -311,6 +312,7 @@ class MKLDNNHandler {
MKLDNNHandler(const MKLDNNDeviceContext& dev_ctx, mkldnn::engine engine,
const std::string& base_key)
: dev_ctx_(dev_ctx), engine_(engine), key_common_(base_key) {
platform::MKLDNNDeviceContext::tls().log_lib_version();
if (platform::MKLDNNDeviceContext::tls().get_cur_mkldnn_session_id() !=
platform::MKLDNNDeviceContextThreadLocals::kMKLDNNSessionID_Default) {
key_ = key_common_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册