Skip to content

Commit

Permalink
Merge branch 'master' into gha/pgzip_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mryzhov authored Oct 14, 2024
2 parents 7bbfdaf + 87e463e commit 0ad3375
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ void Partitioner::identifySubgraphs() {
}
LOG_INFO("Caching done: " << node_id_cache.size() << " layers.");

// Accumulate knowledge about known OV layers when walking
// over a topologically-sorted list.
std::unordered_set<NodeSPtr> nodes_known_now;

// FIXME: Need to do some sanity checks here. What if partitioning
// has been generated for another variation of this model?
// What if that was a completely different model?
Expand Down Expand Up @@ -458,16 +462,19 @@ void Partitioner::identifySubgraphs() {
continue;
} else if ((ov::is_type<ov::op::v8::Slice>(input_node) ||
ov::is_type<ov::op::v0::Convert>(input_node)) &&
!nodes_known_now.count(input_node) &&
ov::op::util::is_parameter(input_node->input(0).get_source_output().get_node_shared_ptr())) {
// So the situation is:
// - a group has an input layer
// - a group has an input layer
// - which reads from a Slice or Convert
// - which reads from a Parameter
// - not a part of any prior group
// This happens when an offline plan is used with a kvcache
// model extended with slices to maintain zero-copy (LLM case)
auto extra_param = input_node->input(0).get_source_output().get_node_shared_ptr();
input_mapping[input_node] = extra_param;
extra_params.insert(extra_param);
LOG_DEBUG("Registered extra param " << extra_param);
} else {
// Ok, this input is connected to some other node's output
// Replace this connection with a link to a newly created Parameter
Expand Down Expand Up @@ -671,7 +678,8 @@ void Partitioner::identifySubgraphs() {
}
}
this_group_idx++; // FIXME: indexed() is better!
} // for (partitions)
nodes_known_now.insert(group_nodes.begin(), group_nodes.end());
} // for (partitions)

// Return what we've got here
std::vector<Subgraph>& result = P.subgraphs;
Expand Down Expand Up @@ -1387,14 +1395,16 @@ void Partitioner::matchParameters(const std::string& func_name) {
this_model_nodes.insert(node_ptr.get());
}
for (auto&& node : call->get_ordered_ops()) {
using ov::npuw::util::at::_;

if (ov::op::util::is_parameter(node)) {
PKey pkey;
for (auto&& iport : node->output(0).get_target_inputs()) {
if (this_model_nodes.count(iport.get_node()) > 0) {
LOG_DEBUG("Register link " << iport.get_node()->get_friendly_name() << " : "
<< iport.get_index());
pkey.insert(
PReader{layer_to_prototype.at(iport.get_node()->get_friendly_name()), iport.get_index()});
pkey.insert(PReader{_(layer_to_prototype).at(iport.get_node()->get_friendly_name()),
iport.get_index()});
}
}
LOG_DEBUG("Find orig parameter for " << node);
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/intel_npu/src/plugin/npuw/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ ov::Tensor permute(const ov::Tensor& t, const std::vector<std::size_t>& axes);
ov::Tensor concat(const std::vector<ov::Tensor>& tt, std::size_t axis);

namespace at {
template <class M>
template <class M_>
struct Impl {
using M = typename std::decay<M_>::type;
using V = typename M::mapped_type;

M* m = nullptr;
Expand Down Expand Up @@ -96,6 +97,11 @@ Impl<M> _(M* pM) {
return Impl<M>(pM);
}

template <typename M>
Impl<M> _(M&& m) {
return Impl<M>(&m);
}

template <typename M>
Impl<M> _(std::shared_ptr<M> pM) {
return Impl<M>(pM.get());
Expand Down

0 comments on commit 0ad3375

Please sign in to comment.