Skip to content

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

NPUW: Avoid inserting Convert operations for irregular ov::Parameter case (#33634)

Nikita Kudriavtseva5f37727a937
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/compiler.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/compiler.cpp
index 1caa2fbdbf4..68d9f66ac57 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/compiler.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/compiler.cpp
@@ -29,7 +29,7 @@ void dump_partitioning(const ov::npuw::Ensemble& ens, const std::string& to) {
pugi::xml_node node = doc.append_child("ensemble");
node.append_attribute("gflops") = std::to_string(ens.gflops).data();
- node.append_attribute("irregular_results") = std::to_string(ens.irregular_results).data();
+ node.append_attribute("irregular_io") = std::to_string(ens.irregular_io).data();
pugi::xml_node part = node.append_child("partitioning");
pugi::xml_node rep;
@@ -310,7 +310,7 @@ public:
ov::npuw::Ensemble ens;
ens.gflops = 1.; // FIXME: calculate proper flops
- ens.irregular_results = !m_snapshot->isRegularResultCase();
+ ens.irregular_io = !m_snapshot->isRegularIOCase();
auto graph = m_snapshot->getGraph();
// Iterate in topological order
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.cpp
index bb423504ac7..76c46973e76 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.cpp
@@ -135,6 +135,10 @@ std::shared_ptr<ov::Node> Group::getInitialNode() const {
return *(m_content.begin());
}
+const std::unordered_set<std::shared_ptr<ov::Node>>& Group::getInputs() const {
+ return m_input_layers;
+}
+
const std::unordered_set<std::shared_ptr<ov::Node>>& Group::getOutputs() const {
return m_output_layers;
}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.hpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.hpp
index 83cd16cf9f9..1fa79353645 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.hpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/group.hpp
@@ -49,6 +49,7 @@ public:
own::ade::NodeHandle getHandle() const;
// Note: can only be used during initial group initialization
std::shared_ptr<ov::Node> getInitialNode() const;
+ const std::unordered_set<std::shared_ptr<ov::Node>>& getInputs() const;
const std::unordered_set<std::shared_ptr<ov::Node>>& getOutputs() const;
void addInput(const std::shared_ptr<ov::Node>& node);
void addOutput(const std::shared_ptr<ov::Node>& node);
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
index 9ae6a7378b6..1846de287dd 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
@@ -31,6 +31,7 @@ namespace ov {
namespace npuw {
namespace online {
namespace detail {
+
bool isOp(const std::shared_ptr<ov::Node>& node) {
if (ov::op::util::is_constant(node) || ov::op::util::is_parameter(node) || ov::op::util::is_output(node)) {
return false;
@@ -72,11 +73,136 @@ std::vector<ov::element::Type> getConstsPrecision(const std::shared_ptr<ov::Node
return precisions;
}
+
} // namespace detail
} // namespace online
} // namespace npuw
} // namespace ov
+namespace {
+
+using NodeSPtr = std::shared_ptr<ov::Node>;
+using ov::npuw::online::Repeated;
+using ov::npuw::online::detail::GPtrSet;
+
+bool isRegularResultCase(const std::unordered_map<std::shared_ptr<Repeated>, GPtrSet>& reptag_to_gset,
+ const std::unordered_map<std::string, NodeSPtr>& node_id_cache,
+ const std::map<std::string, std::vector<std::set<std::string>>>& m_layer_matches) {
+ auto getReadersMask = [](const NodeSPtr& node_ptr) {
+ // each element of the vector is
+ // the number of ov::Result readers for the corresponding output
+ std::vector<int> mask;
+ for (auto&& output_desc : node_ptr->outputs()) {
+ auto readers = output_desc.get_target_inputs();
+ int result_count = 0;
+ for (auto&& r : readers) {
+ auto reader_node_ptr = r.get_node()->shared_from_this();
+ if (ov::op::util::is_output(reader_node_ptr)) {
+ result_count++;
+ }
+ }
+ mask.push_back(result_count);
+ }
+ return mask;
+ };
+
+ for (const auto& reptag_and_gset : reptag_to_gset) {
+ auto reptag = reptag_and_gset.first;
+ auto gset = reptag_and_gset.second;
+
+ auto matches = m_layer_matches.at(reptag->id());
+
+ if (gset.size() <= 1) {
+ continue;
+ }
+
+ auto firstGroup = *(gset.begin());
+ for (auto output_layer : firstGroup->getOutputs()) {
+ // this is the reference mask expected from all other matched layers
+ // in the remaining groups of the repeated block
+ auto expected_readers_mask = getReadersMask(output_layer);
+
+ auto this_layer_name = output_layer->get_friendly_name();
+ auto layer_bank_iter = std::find_if(matches.begin(), matches.end(), [&](const std::set<std::string>& lrs) {
+ return lrs.count(this_layer_name) > 0;
+ });
+
+ NPUW_ASSERT(layer_bank_iter != matches.end());
+
+ // match output layers across all groups in the repeated block
+ // and compare their readers mask
+ for (const auto& layer_name : *layer_bank_iter) {
+ auto layer_ptr = node_id_cache.at(layer_name);
+ auto actual_readers_mask = getReadersMask(layer_ptr);
+
+ if (actual_readers_mask != expected_readers_mask) {
+ LOG_INFO("This is NOT a regular result case. Readers mask mismatch found for "
+ << layer_name << " and " << this_layer_name << " output layers.");
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+bool isRegularParameterCase(const std::unordered_map<std::shared_ptr<Repeated>, GPtrSet>& reptag_to_gset,
+ const std::unordered_map<std::string, NodeSPtr>& node_id_cache,
+ const std::map<std::string, std::vector<std::set<std::string>>>& m_layer_matches) {
+ auto getProducersMask = [](const NodeSPtr& node_ptr) {
+ // each element of the vector is
+ // the flag indicating ov::Parameter producer for the corresponding input
+ std::vector<bool> mask;
+ for (auto&& input_desc : node_ptr->inputs()) {
+ auto producer_ptr = input_desc.get_source_output().get_node()->shared_from_this();
+ mask.push_back(ov::op::util::is_parameter(producer_ptr));
+ }
+ return mask;
+ };
+
+ for (const auto& reptag_and_gset : reptag_to_gset) {
+ auto reptag = reptag_and_gset.first;
+ auto gset = reptag_and_gset.second;
+
+ auto matches = m_layer_matches.at(reptag->id());
+
+ if (gset.size() <= 1) {
+ continue;
+ }
+
+ auto firstGroup = *(gset.begin());
+ for (auto input_layer : firstGroup->getInputs()) {
+ // this is the reference mask expected from all other matched layers
+ // in the remaining groups of the repeated block
+ auto expected_producers_mask = getProducersMask(input_layer);
+
+ auto this_layer_name = input_layer->get_friendly_name();
+ auto layer_bank_iter = std::find_if(matches.begin(), matches.end(), [&](const std::set<std::string>& lrs) {
+ return lrs.count(this_layer_name) > 0;
+ });
+
+ NPUW_ASSERT(layer_bank_iter != matches.end());
+
+ // match input layers across all groups in the repeated block
+ // and compare their producers mask
+ for (const auto& layer_name : *layer_bank_iter) {
+ auto layer_ptr = node_id_cache.at(layer_name);
+ auto actual_producers_mask = getProducersMask(layer_ptr);
+ if (actual_producers_mask != expected_producers_mask) {
+ LOG_INFO("This is NOT a regular parameter case. Producers mask mismatch found for "
+ << layer_name << " and " << this_layer_name << " input layers.");
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+} // namespace
+
using ov::npuw::online::detail::getConstsPrecision;
using ov::npuw::online::detail::isOp;
@@ -1270,10 +1396,20 @@ void Snapshot::stripTag(const std::string& tag) {
}
}
-bool Snapshot::isRegularResultCase() const {
- LOG_INFO("Online partitioning: executing isRegularResultCase pass...");
+bool Snapshot::isRegularIOCase() const {
+ LOG_INFO("Online partitioning: executing isRegularIOCase pass...");
LOG_BLOCK();
+ std::unordered_map<std::string, NodeSPtr> node_id_cache;
+ for (auto&& node_ptr : m_model->get_ordered_ops()) {
+ node_id_cache[node_ptr->get_friendly_name()] = node_ptr;
+ }
+
+ auto reptag_to_gset = repeating();
+ if (!reptag_to_gset.empty()) {
+ NPUW_ASSERT(!m_layer_matches.empty());
+ }
+
// This method works around an issue where the final partitioning fails the sanity check
// because of a different number of output Convert across repeated block groups.
// The issue was initially observed in a model where only the final block has an additional ov::Result consumer.
@@ -1293,74 +1429,36 @@ bool Snapshot::isRegularResultCase() const {
// be also eliminated
// Therefore, we disable F16IC early in such cases.
- using NodeSPtr = std::shared_ptr<ov::Node>;
- std::unordered_map<std::string, NodeSPtr> node_id_cache;
- for (auto&& node_ptr : m_model->get_ordered_ops()) {
- node_id_cache[node_ptr->get_friendly_name()] = node_ptr;
- }
-
- auto getReadersMask = [](const NodeSPtr& node_ptr) {
- // each element of the vector is
- // the number of ov::Result readers for the corresponding output
- std::vector<int> mask;
- for (auto&& output_desc : node_ptr->outputs()) {
- auto readers = output_desc.get_target_inputs();
- int result_count = 0;
- for (auto&& r : readers) {
- auto reader_node_ptr = r.get_node()->shared_from_this();
- if (ov::op::util::is_output(reader_node_ptr)) {
- result_count++;
- }
- }
- mask.push_back(result_count);
- }
- return mask;
- };
-
- auto reptag_to_gset = repeating();
- if (!reptag_to_gset.empty()) {
- NPUW_ASSERT(!m_layer_matches.empty());
+ if (!isRegularResultCase(reptag_to_gset, node_id_cache, m_layer_matches)) {
+ LOG_INFO("This is not a regular result case");
+ LOG_INFO("DONE");
+ return false;
}
- for (const auto& reptag_and_gset : reptag_to_gset) {
- auto reptag = reptag_and_gset.first;
- auto gset = reptag_and_gset.second;
-
- auto matches = m_layer_matches.at(reptag->id());
-
- if (gset.size() <= 1) {
- continue;
- }
-
- auto firstGroup = *(gset.begin());
- for (auto output_layer : firstGroup->getOutputs()) {
- // this is the reference mask expected from all other matched layers
- // in the remaining groups of the repeated block
- auto expected_readers_mask = getReadersMask(output_layer);
-
- auto this_layer_name = output_layer->get_friendly_name();
- auto layer_bank_iter = std::find_if(matches.begin(), matches.end(), [&](const std::set<std::string>& lrs) {
- return lrs.count(this_layer_name) > 0;
- });
-
- NPUW_ASSERT(layer_bank_iter != matches.end());
-
- // match output layers across all groups in the repeated block
- // and compare their readers mask
- for (const auto& layer_name : *layer_bank_iter) {
- auto layer_ptr = node_id_cache.at(layer_name);
- auto actual_readers_mask = getReadersMask(layer_ptr);
-
- if (actual_readers_mask != expected_readers_mask) {
- LOG_INFO("This is NOT a regular result case. Readers mask mismatch found for "
- << layer_name << " and " << this_layer_name << " output layers.");
- return false;
- }
- }
- }
+ // This method is similar to isRegularResultCase but checks for irregular input ov::Parameters.
+ // For example, Group[1..31] has only external producers (i.e. producers that belong to other groups):
+ // OpA(external group)
+ // |
+ // -> AddOp
+ // |
+ // OpB(external group)
+ // but the first Group[0] has an ov::Parameter producer:
+ // ov::Parameter
+ // |
+ // -> AddOp
+ // |
+ // OpB(external group)
+ // Later, if NPUW_F16IC is set, "Partitioner::identifySubgraphs" method adds two input Converts to each Group[1..31]
+ // but only one input Convert to Group[0], since it skips adding Convert for ov::Parameter.
+ // Therefore, sanity check fails due to different number of input Converts across repeated block groups.
+
+ if (!isRegularParameterCase(reptag_to_gset, node_id_cache, m_layer_matches)) {
+ LOG_INFO("This is not a regular parameter case");
+ LOG_INFO("DONE");
+ return false;
}
- LOG_INFO("This is a regular result case");
+ LOG_INFO("This is a regular IO case");
LOG_INFO("DONE");
return true;
}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.hpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.hpp
index 41aa4980630..ecb5e4ef68b 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.hpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.hpp
@@ -57,7 +57,7 @@ public:
void stripTag(const std::string& tag);
// Passes to detect corner cases
- bool isRegularResultCase() const;
+ bool isRegularIOCase() const;
// Utility
std::shared_ptr<own::ade::Graph> getGraph() const;
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp
index 3df085c3037..29d4c3adf5a 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp
@@ -183,7 +183,7 @@ ov::npuw::Ensemble load_groups(const std::shared_ptr<ov::Model>& model, const st
LOG_INFO("Found " << repeated.size() << " different repeated block(s)");
return ov::npuw::Ensemble{get_float_attr(root, "gflops"),
- get_bool_attr(root, "irregular_results", false),
+ get_bool_attr(root, "irregular_io", false),
std::move(partitions),
std::move(repeated)};
}
@@ -379,7 +379,7 @@ void Partitioner::identifySubgraphs() {
LOG_INFO("Identifying subgraphs for model " << model->get_friendly_name() << "...");
LOG_BLOCK();
- const bool connect_in_f16 = cfg.get<::intel_npu::NPUW_F16IC>() && !ens.irregular_results;
+ const bool connect_in_f16 = cfg.get<::intel_npu::NPUW_F16IC>() && !ens.irregular_io;
using namespace ov::npuw;
std::vector<ov::npuw::Group>& partitions = ens.groups;
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.hpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.hpp
index a85271d1ade..9c0a8ed6d1c 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.hpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.hpp
@@ -158,7 +158,7 @@ struct RepeatedBlock {
struct Ensemble {
float gflops;
- bool irregular_results;
+ bool irregular_io;
std::vector<Group> groups;
// Just a map as I don't expect 100s of _different_
diff --git a/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.cpp b/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.cpp
index ab0175c782c..4029367a6a5 100644
--- a/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.cpp
+++ b/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.cpp
@@ -4,6 +4,9 @@
#include "model_generator.hpp"
+#include <algorithm>
+#include <unordered_map>
+
#include "openvino/op/ops.hpp"
#include "openvino/openvino.hpp"
#include "openvino/opsets/opset11.hpp"
@@ -120,6 +123,82 @@ std::shared_ptr<ov::Model> ModelGenerator::get_model_with_repeated_blocks_and_re
return std::make_shared<ov::Model>(results, params);
}
+std::shared_ptr<ov::Model> ModelGenerator::get_model_with_repeated_blocks_and_parameters(
+ std::size_t repetitions,
+ const std::vector<std::size_t>& block_indices) {
+ if (repetitions == 0) {
+ repetitions = 1; // keep the model non-empty
+ }
+
+ auto input = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{1, 1, 8});
+ m_nodes.push_back(input);
+
+ ov::ParameterVector params = {input};
+
+ // Pre-create Parameters that will feed selected blocks (indexed by block_indices)
+ std::vector<std::size_t> sorted_indices = block_indices;
+ std::sort(sorted_indices.begin(), sorted_indices.end());
+ sorted_indices.erase(std::unique(sorted_indices.begin(), sorted_indices.end()), sorted_indices.end());
+
+ std::unordered_map<std::size_t, std::shared_ptr<ov::opset11::Parameter>> block_params;
+ for (std::size_t idx : sorted_indices) {
+ if (idx >= repetitions) {
+ continue; // ignore out-of-range indices
+ }
+
+ auto param = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{1, 1, 8});
+ m_nodes.push_back(param);
+ block_params.emplace(idx, param);
+ params.push_back(param);
+ }
+
+ auto scale_const = ov::opset11::Constant::create(ov::element::f32, ov::Shape{1}, {1.f});
+ auto bias_const = ov::opset11::Constant::create(ov::element::f32, ov::Shape{1, 1, 8}, std::vector<float>(8, 0.5f));
+ auto head_const = ov::opset11::Constant::create(ov::element::f32, ov::Shape{1, 1, 8}, std::vector<float>(8, 1.f));
+ m_nodes.push_back(scale_const);
+ m_nodes.push_back(bias_const);
+ m_nodes.push_back(head_const);
+
+ auto head_add = std::make_shared<ov::opset11::Add>(input, head_const);
+ auto head_relu = std::make_shared<ov::opset11::Relu>(head_add);
+ m_nodes.push_back(head_add);
+ m_nodes.push_back(head_relu);
+
+ ov::Output<ov::Node> current = head_relu;
+
+ for (std::size_t i = 0; i < repetitions; ++i) {
+ auto it = block_params.find(i);
+ ov::Output<ov::Node> rhs = (it != block_params.end()) ? it->second : current;
+
+ auto add = std::make_shared<ov::opset11::Add>(current, rhs);
+ m_nodes.push_back(add);
+
+ auto mul = std::make_shared<ov::opset11::Multiply>(add, scale_const);
+ m_nodes.push_back(mul);
+
+ auto relu = std::make_shared<ov::opset11::Relu>(mul);
+ m_nodes.push_back(relu);
+
+ auto add_bias = std::make_shared<ov::opset11::Add>(relu, bias_const);
+ m_nodes.push_back(add_bias);
+
+ current = add_bias;
+ }
+
+ auto tail_const = ov::opset11::Constant::create(ov::element::f32, ov::Shape{1, 1, 8}, std::vector<float>(8, 2.f));
+ m_nodes.push_back(tail_const);
+
+ auto tail_mul = std::make_shared<ov::opset11::Multiply>(current, tail_const);
+ auto tail_add = std::make_shared<ov::opset11::Add>(tail_mul, tail_const);
+ m_nodes.push_back(tail_mul);
+ m_nodes.push_back(tail_add);
+
+ auto result = std::make_shared<ov::opset11::Result>(tail_add);
+ m_nodes.push_back(result);
+
+ return std::make_shared<ov::Model>(ov::ResultVector{result}, params);
+}
+
std::shared_ptr<ov::Model> ModelGenerator::get_model_with_multi_output_repeating_blocks(
std::size_t repetitions,
bool last_block_has_direct_result) {
diff --git a/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.hpp b/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.hpp
index 58ef563b687..8b42b881b1d 100644
--- a/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.hpp
+++ b/src/plugins/intel_npu/tests/unit/npuw/model_generator/model_generator.hpp
@@ -23,6 +23,14 @@ public:
std::size_t repetitions,
const std::vector<std::size_t>& block_indices);
+ // Build model with repeating blocks where selected blocks accept external ov::Parameter inputs.
+ // - repetitions: number of repeating blocks (minimum 1)
+ // - block_indices: vector of block indices (0-based) that should consume a distinct ov::Parameter as one of the
+ // first op inputs; indices outside [0, repetitions) are ignored
+ std::shared_ptr<ov::Model> get_model_with_repeated_blocks_and_parameters(
+ std::size_t repetitions,
+ const std::vector<std::size_t>& block_indices);
+
// Build model with repeating blocks where the final op in each block has multiple outputs (TopK values + indices).
// - repetitions: number of repeating blocks
// - last_block_has_direct_result:
diff --git a/src/plugins/intel_npu/tests/unit/npuw/online_partitioning.cpp b/src/plugins/intel_npu/tests/unit/npuw/online_partitioning.cpp
index 554716b15e3..1f9308da887 100644
--- a/src/plugins/intel_npu/tests/unit/npuw/online_partitioning.cpp
+++ b/src/plugins/intel_npu/tests/unit/npuw/online_partitioning.cpp
@@ -101,6 +101,8 @@ bool isEqualEns(ov::npuw::Ensemble& ens1, ov::npuw::Ensemble& ens2) {
}
class IsRegularResultCaseParametrized : public ::testing::TestWithParam<std::tuple<std::vector<std::size_t>, bool>> {};
+class IsRegularParameterCaseParametrized : public ::testing::TestWithParam<std::tuple<std::vector<std::size_t>, bool>> {
+};
}; // namespace
@@ -570,33 +572,35 @@ TEST(OnlinePartitioningTest, Partitioning_Avoids_Pipeline_None) {
EXPECT_EQ(ens.groups.size(), 3);
}
-TEST(OnlinePartitioningTest, IsRegularResultCaseMultipleOutputs) {
+TEST(OnlinePartitioningTest, IsRegularIOCaseWhenNoRB) {
+ bool expected_result = false;
+
ModelGenerator mg;
- std::vector<std::pair<std::shared_ptr<ov::Model>, bool>> model_expected = {
- {mg.get_model_with_multi_output_repeating_blocks(10, /*irregular_results=*/true), /*irregular_results=*/true},
- {mg.get_model_with_multi_output_repeating_blocks(10, /*irregular_results=*/false),
- /*irregular_results=*/false}};
+ std::vector<std::shared_ptr<ov::Model>> models = {mg.get_model_with_one_op(),
+ mg.get_model_without_repeated_blocks()};
- for (auto [model, expected_result] : model_expected) {
- auto cfg = createConfigWithKeepBlockSize(3);
+ for (auto model : models) {
+ auto cfg = createConfigWithKeepBlockSize(9);
auto ens = ov::npuw::online::buildPartitioning(model, cfg);
- EXPECT_EQ(ens.irregular_results, expected_result);
+ EXPECT_EQ(ens.repeated.size(), 0); // sanity check that we don't have repeated blocks
+ EXPECT_EQ(ens.irregular_io, expected_result);
}
}
-TEST(OnlinePartitioningTest, IsRegularResultCaseWhenNoRB) {
- bool expected_result = false;
-
+TEST(OnlinePartitioningTest, IsRegularResultCaseMultipleOutputs) {
ModelGenerator mg;
- std::vector<std::shared_ptr<ov::Model>> models = {mg.get_model_with_one_op(),
- mg.get_model_without_repeated_blocks()};
+ std::vector<std::pair<std::shared_ptr<ov::Model>, bool>> model_expected = {
+ {mg.get_model_with_multi_output_repeating_blocks(10, /*irregular_io=*/true), /*irregular_io=*/true},
+ {mg.get_model_with_multi_output_repeating_blocks(10, /*irregular_io=*/false),
+ /*irregular_io=*/false}};
- for (auto model : models) {
- auto cfg = createConfigWithKeepBlockSize(9);
+ for (auto [model, expected_result] : model_expected) {
+ auto cfg = createConfigWithKeepBlockSize(3);
auto ens = ov::npuw::online::buildPartitioning(model, cfg);
- EXPECT_EQ(ens.irregular_results, expected_result);
+ EXPECT_EQ(ens.repeated.size(), 1); // sanity check that we have repeated blocks
+ EXPECT_EQ(ens.irregular_io, expected_result);
}
}
@@ -609,7 +613,8 @@ TEST_P(IsRegularResultCaseParametrized, CheckForDifferentResultConfigs) {
auto cfg = createConfigWithKeepBlockSize(9);
auto ens = ov::npuw::online::buildPartitioning(model, cfg);
- EXPECT_EQ(ens.irregular_results, expected_result);
+ EXPECT_EQ(ens.repeated.size(), 1); // sanity check that we have repeated blocks
+ EXPECT_EQ(ens.irregular_io, expected_result);
}
INSTANTIATE_TEST_SUITE_P(OnlinePartitioningTest,
@@ -617,10 +622,35 @@ INSTANTIATE_TEST_SUITE_P(OnlinePartitioningTest,
::testing::Values(
// All blocks have an ov::Result consumer
std::make_tuple(std::vector<std::size_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
- /*irregular_results=*/false),
+ /*irregular_io=*/false),
// Some blocks have an ov::Result consumer
- std::make_tuple(std::vector<std::size_t>{2, 5, 8}, /*irregular_results=*/true),
+ std::make_tuple(std::vector<std::size_t>{2, 5, 8}, /*irregular_io=*/true),
// Only last block has an additional ov::Result consumer
- std::make_tuple(std::vector<std::size_t>{9}, /*irregular_results=*/true),
- // No blocks have additional ov::Result consumers
- std::make_tuple(std::vector<std::size_t>{}, /*irregular_results=*/false)));
+ std::make_tuple(std::vector<std::size_t>{9}, /*irregular_io=*/true),
+ // No blocks have an additional ov::Result consumers
+ std::make_tuple(std::vector<std::size_t>{}, /*irregular_io=*/false)));
+
+TEST_P(IsRegularParameterCaseParametrized, CheckForDifferentParameterConfigs) {
+ auto [block_indices, expected_result] = GetParam();
+
+ ModelGenerator mg;
+ auto model = mg.get_model_with_repeated_blocks_and_parameters(10, block_indices);
+ auto cfg = createConfigWithKeepBlockSize(4);
+ auto ens = ov::npuw::online::buildPartitioning(model, cfg);
+
+ EXPECT_EQ(ens.repeated.size(), 1); // sanity check that we have repeated blocks
+ EXPECT_EQ(ens.irregular_io, expected_result);
+}
+
+INSTANTIATE_TEST_SUITE_P(OnlinePartitioningTest,
+ IsRegularParameterCaseParametrized,
+ ::testing::Values(
+ // All blocks have an ov::Parameter producer
+ std::make_tuple(std::vector<std::size_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ /*irregular_io=*/false),
+ // Some blocks have an ov::Parameter producer
+ std::make_tuple(std::vector<std::size_t>{1, 2, 3}, /*irregular_io=*/true),
+ // Only one block has an additional ov::Parameter producer
+ std::make_tuple(std::vector<std::size_t>{5}, /*irregular_io=*/true),
+ // No blocks have an additional ov::Parameter producers
+ std::make_tuple(std::vector<std::size_t>{}, /*irregular_io=*/false)));