OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU][DEBUG_CAPS] Enable verbose mode for ov data types (#28747)
Maksim Kutakov5eeee6d1b6d1
diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp b/src/plugins/intel_cpu/src/dnnl_extension_utils.cppindex 64cfbb1ce3d..ea36ca54cf7 100644--- a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp+++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp@@ -47,7 +47,9 @@ uint8_t DnnlExtensionUtils::sizeOfDataType(dnnl::memory::data_type dataType) {}}-dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::element::Type& elementType) {+std::optional<dnnl::memory::data_type> DnnlExtensionUtils::ElementTypeToDataType(+ const ov::element::Type& elementType,+ DnnlExtensionUtils::nothrow_tag) noexcept {switch (elementType) {case ov::element::f32:return memory::data_type::f32;@@ -81,11 +83,18 @@ dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::elemcase ov::element::undefined:return memory::data_type::undef;default: {- OPENVINO_THROW("CPU plugin does not support ", elementType.to_string(), " for use with oneDNN.");+ return {};}}}+dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::element::Type& elementType,+ DnnlExtensionUtils::throw_tag) {+ auto&& result = ElementTypeToDataType(elementType, nothrow_tag{});+ OPENVINO_ASSERT(result, "CPU plugin does not support ", elementType.to_string(), " for use with oneDNN.");+ return result.value();+}+ov::element::Type DnnlExtensionUtils::DataTypeToElementType(const dnnl::memory::data_type& dataType) {switch (dataType) {case memory::data_type::f32:diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.h b/src/plugins/intel_cpu/src/dnnl_extension_utils.hindex 81f83048cb1..49da3835628 100644--- a/src/plugins/intel_cpu/src/dnnl_extension_utils.h+++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.h@@ -8,6 +8,7 @@*/#pragma once+#include <optional>#include <string>#include "common/c_types_map.hpp"@@ -25,9 +26,18 @@ class Shape;class IMemory;class DnnlExtensionUtils {+public:+ struct throw_tag {};+ struct nothrow_tag {};+public:static uint8_t sizeOfDataType(dnnl::memory::data_type dataType);- static dnnl::memory::data_type ElementTypeToDataType(const ov::element::Type& elementType);+ static dnnl::memory::data_type ElementTypeToDataType(const ov::element::Type& elementType,+ throw_tag tag = throw_tag{});++ static std::optional<dnnl::memory::data_type> ElementTypeToDataType(const ov::element::Type& elementType,+ nothrow_tag) noexcept;+static ov::element::Type DataTypeToElementType(const dnnl::memory::data_type& dataType);static Dim convertToDim(const dnnl::memory::dim& dim);static dnnl::memory::dim convertToDnnlDim(const Dim& dim);diff --git a/src/plugins/intel_cpu/src/utils/verbose.cpp b/src/plugins/intel_cpu/src/utils/verbose.cppindex 53779ce516e..dcc9e0b60b4 100644--- a/src/plugins/intel_cpu/src/utils/verbose.cpp+++ b/src/plugins/intel_cpu/src/utils/verbose.cpp@@ -105,36 +105,48 @@ void Verbose::printInfo() {written_total += size;};- auto formatMemDesc = [&](const dnnl_memory_desc_t& desc, std::string& prefix) {+ auto formatMemDesc = [&](const MemoryDescPtr& desc, std::string& prefix) {prefix = colorize(BLUE, prefix);written = snprintf(portsInfo + written_total, CPU_VERBOSE_DAT_LEN - written_total, " ");shift(written);written = snprintf(portsInfo + written_total, CPU_VERBOSE_DAT_LEN - written_total, "%s", prefix.c_str());shift(written);- std::string fmt_str = dnnl::impl::md2fmt_str("", desc, dnnl::impl::format_kind_t::dnnl_format_kind_undef);+ std::string fmt_str = {};+ std::string dim_str = {};+ if (DnnlExtensionUtils::ElementTypeToDataType(desc->getPrecision(), DnnlExtensionUtils::nothrow_tag{})) {+ if (auto dnnl_desc = MemoryDescUtils::convertToDnnlMemoryDesc(desc)->getDnnlDesc()) {+ fmt_str = dnnl::impl::md2fmt_str("", dnnl_desc.get(), dnnl::impl::format_kind_t::dnnl_format_kind_undef);+ std::string dim_str = dnnl::impl::md2dim_str(dnnl_desc.get());+ } else {+ fmt_str = "empty";+ }+ } else {+ fmt_str = desc->getPrecision().to_string();+ if (const auto& dims = desc->getShape().getDims(); !dims.empty()) {+ dim_str = dim2str(dims.front());+ std::for_each(++(dims.begin()), dims.end(), [&dim_str](size_t dim) {+ dim_str.append("x" + std::to_string(dim));+ });+ }+ }written = snprintf(portsInfo + written_total, CPU_VERBOSE_DAT_LEN - written_total, "%s", fmt_str.c_str());shift(written);written = snprintf(portsInfo + written_total, CPU_VERBOSE_DAT_LEN - written_total, ":");shift(written);- std::string dim_str = dnnl::impl::md2dim_str(desc);written = snprintf(portsInfo + written_total, CPU_VERBOSE_DAT_LEN - written_total, "%s", dim_str.c_str());shift(written);};for (size_t i = 0; i < node->getParentEdges().size(); i++) {std::string prefix("src:" + std::to_string(i) + ':');- formatMemDesc(MemoryDescUtils::convertToDnnlMemoryDesc(node->getParentEdgeAt(i)->getMemory().getDesc().clone())- ->getDnnlDesc()- .get(),- prefix);+ const auto& desc = node->getParentEdgeAt(i)->getMemory().getDescPtr();+ formatMemDesc(desc, prefix);}for (size_t i = 0; i < node->getChildEdges().size(); i++) {std::string prefix("dst:" + std::to_string(i) + ':');- formatMemDesc(MemoryDescUtils::convertToDnnlMemoryDesc(node->getChildEdgeAt(i)->getMemory().getDesc().clone())- ->getDnnlDesc()- .get(),- prefix);+ const auto& desc = node->getChildEdgeAt(i)->getMemory().getDescPtr();+ formatMemDesc(desc, prefix);}std::string post_ops;