Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Use get_partial_shape to get dynamic shape (#26907)

Artemy Skrebkov0882ff606a7f
diff --git a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp
index 0e02bb48f3a..af7682bc1ae 100644
--- a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp
+++ b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp
@@ -4,7 +4,6 @@
#include "zero_compiler_in_driver.hpp"
-#include <fstream>
#include <regex>
#include <string_view>
@@ -272,13 +271,19 @@ std::string LevelZeroCompilerInDriver<TableExtension>::serializeIOInfo(const std
inputsPrecisionSS << INPUTS_PRECISIONS_KEY << KEY_VALUE_SEPARATOR << VALUE_DELIMITER;
inputsLayoutSS << INPUTS_LAYOUTS_KEY << KEY_VALUE_SEPARATOR << VALUE_DELIMITER;
+ const auto getRankOrThrow = [](const ov::PartialShape& shape) -> size_t {
+ if (shape.rank().is_dynamic()) {
+ OPENVINO_THROW("Dynamic rank is not supported for NPU plugin");
+ }
+ return shape.rank().get_length();
+ };
if (!parameters.empty()) {
size_t parameterIndex = 0;
for (const std::shared_ptr<ov::op::v0::Parameter>& parameter : parameters) {
- const ov::element::Type& precision = parameter->get_element_type();
- const size_t rank = parameter->get_shape().size();
+ const auto precision = parameter->get_element_type();
+ const auto rank = getRankOrThrow(parameter->get_partial_shape());
if (parameterIndex != 0) {
inputsPrecisionSS << VALUES_SEPARATOR;
@@ -310,10 +315,9 @@ std::string LevelZeroCompilerInDriver<TableExtension>::serializeIOInfo(const std
outputsLayoutSS << OUTPUTS_LAYOUTS_KEY << KEY_VALUE_SEPARATOR << VALUE_DELIMITER;
size_t resultIndex = 0;
-
for (const std::shared_ptr<ov::op::v0::Result>& result : results) {
- const ov::element::Type_t precision = result->get_element_type();
- const size_t rank = result->get_shape().size();
+ const auto precision = result->get_element_type();
+ const auto rank = getRankOrThrow(result->get_output_partial_shape(0));
if (resultIndex != 0) {
outputsPrecisionSS << VALUES_SEPARATOR;