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
update mem_bandwidth_pressure_tolerance() for CPU plugin (#30832)
Wanglei Shena4f1a0dcfda4
diff --git a/src/inference/dev_api/openvino/runtime/performance_heuristics.hpp b/src/inference/dev_api/openvino/runtime/performance_heuristics.hppindex 0de2714110f..f57da5f2f59 100644--- a/src/inference/dev_api/openvino/runtime/performance_heuristics.hpp+++ b/src/inference/dev_api/openvino/runtime/performance_heuristics.hpp@@ -31,9 +31,10 @@ struct MemBandwidthPressure {static constexpr float LIMITED = 0.5f; // conservatively assume 1/2 utilization of the cache};-OPENVINO_RUNTIME_API MemBandwidthPressure mem_bandwidth_pressure_tolerance(- const std::shared_ptr<ov::Model> model,- const float cache_size,- const float memThresholdAssumeLimited = MemBandwidthPressure::LIMITED);+OPENVINO_RUNTIME_API MemBandwidthPressure+mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::Model> model,+ const float cache_size,+ const float mem_threshold_assume_limited = MemBandwidthPressure::LIMITED,+ const ov::element::Type& target_type = ov::element::f32);} // namespace ovdiff --git a/src/inference/src/dev/performance_heuristics.cpp b/src/inference/src/dev/performance_heuristics.cppindex 8ef27fada2a..a0bf9f96fa8 100644--- a/src/inference/src/dev/performance_heuristics.cpp+++ b/src/inference/src/dev/performance_heuristics.cpp@@ -8,7 +8,8 @@ namespace ov {MemBandwidthPressure mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::Model> model,const float cache_size,- const float memThresholdAssumeLimited) {+ const float mem_threshold_assume_limited,+ const ov::element::Type& target_type) {int total_convs = 0, mem_limited_convs = 0, compute_convs = 0, total_gemms = 0, mem_limited_gemms = 0,total_deconvs = 0, compute_deconvs = 0, mem_limited_deconvs = 0;auto memLimitedFactor = [&](size_t size_data_moved, int datatype_size = 4) -> float {@@ -34,7 +35,9 @@ MemBandwidthPressure mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::}continue;}- auto type1 = node->input_value(1).get_element_type(); // weights+ const auto& in1_type = node->get_input_element_type(1); // weights+ const auto& type1 =+ ((in1_type == ov::element::f32) && (target_type != ov::element::f32)) ? target_type : in1_type;const bool isINT8 = isLowPrecision(type1);const bool isBF16orFP16 = isHalfPrecision(type1);const int data_type_size = isINT8 ? 1 : isBF16orFP16 ? 2 : 4;@@ -60,7 +63,7 @@ MemBandwidthPressure mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::const auto total_data = dataSizeInput0 + non_const * dataSizeInput1 + dataSizeOutput;total_gemms++;const auto factor = memLimitedFactor(total_data, data_type_size);- mem_limited_gemms += factor < memThresholdAssumeLimited;+ mem_limited_gemms += factor < mem_threshold_assume_limited;worst_case = std::min(factor, worst_case);}} else if (!std::strcmp("Convolution", node_name)) {@@ -89,7 +92,7 @@ MemBandwidthPressure mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::dataSizeOutput =std::accumulate(shapeOutput.begin(), shapeOutput.end(), size_t(1), std::multiplies<size_t>());const auto factor = memLimitedFactor(static_cast<int>(dataSizeInput + dataSizeOutput), data_type_size);- mem_limited_convs += factor < memThresholdAssumeLimited;+ mem_limited_convs += factor < mem_threshold_assume_limited;worst_case = std::min(factor, worst_case);}} else if (!std::strcmp("ConvolutionBackpropData", node_name)) {@@ -110,7 +113,7 @@ MemBandwidthPressure mem_bandwidth_pressure_tolerance(const std::shared_ptr<ov::dataSizeOutput =std::accumulate(shapeOutput.begin(), shapeOutput.end(), size_t(1), std::multiplies<size_t>());const auto factor = memLimitedFactor(static_cast<int>(dataSizeInput + dataSizeOutput), data_type_size);- mem_limited_deconvs += factor < memThresholdAssumeLimited;+ mem_limited_deconvs += factor < mem_threshold_assume_limited;worst_case = std::min(factor, worst_case);}}diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.cppindex 55088cf04ea..36c477dc80f 100644--- a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp+++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp@@ -628,7 +628,10 @@ int get_model_prefer_threads(const int num_streams,const float memThresholdAssumeLimitedForISA = ov::MemBandwidthPressure::LIMITED / isaSpecificThreshold;const float L2_cache_size = dnnl::utils::get_cache_size(2 /*level*/, true /*per core */);ov::MemBandwidthPressure networkToleranceForLowCache =- ov::mem_bandwidth_pressure_tolerance(model, L2_cache_size, memThresholdAssumeLimitedForISA);+ ov::mem_bandwidth_pressure_tolerance(model,+ L2_cache_size,+ memThresholdAssumeLimitedForISA,+ config.inferencePrecision);# if (defined(OPENVINO_ARCH_ARM) && defined(__linux__))config.modelPreferThreads = 4;