|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp"
|
|
|
|
|
|
#include <iostream>
|
|
|
#include <sstream>
|
|
|
#include <fstream>
|
|
|
#include <map>
|
|
|
|
|
|
#include <ade/passes/check_cycles.hpp>
|
|
|
#include <ade/util/zip_range.hpp>
|
|
|
|
|
|
#include <opencv2/gapi/gproto.hpp>
|
|
|
#include "compiler/gmodel.hpp"
|
|
|
#include "compiler/gislandmodel.hpp"
|
|
|
#include "compiler/passes/passes.hpp"
|
|
|
|
|
|
namespace cv { namespace gimpl { namespace passes {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addStreaming(ade::passes::PassContext &ctx)
|
|
|
{
|
|
|
GModel::Graph gm(ctx.graph);
|
|
|
if (!gm.metadata().contains<Streaming>()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto igr = gm.metadata().get<IslandModel>().model;
|
|
|
GIslandModel::Graph igm(*igr);
|
|
|
|
|
|
|
|
|
|
|
|
using M = std::unordered_map
|
|
|
< ade::NodeHandle
|
|
|
, ade::NodeHandle
|
|
|
, ade::HandleHasher<ade::Node>
|
|
|
>;
|
|
|
M orig_to_isl;
|
|
|
for (auto &&nh : igm.nodes()) {
|
|
|
if (igm.metadata(nh).get<NodeKind>().k == NodeKind::SLOT) {
|
|
|
const auto &orig_nh = igm.metadata(nh).get<DataSlot>().original_data_node;
|
|
|
orig_to_isl[orig_nh] = nh;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto proto = gm.metadata().get<Protocol>();
|
|
|
for (auto &&it : ade::util::indexed(proto.in_nhs)) {
|
|
|
const auto in_idx = ade::util::index(it);
|
|
|
const auto in_nh = ade::util::value(it);
|
|
|
auto emit_nh = GIslandModel::mkEmitNode(igm, in_idx);
|
|
|
igm.link(emit_nh, orig_to_isl.at(in_nh));
|
|
|
}
|
|
|
|
|
|
|
|
|
for (auto &&it : ade::util::indexed(proto.out_nhs)) {
|
|
|
const auto out_idx = ade::util::index(it);
|
|
|
const auto out_nh = ade::util::value(it);
|
|
|
auto sink_nh = GIslandModel::mkSinkNode(igm, out_idx);
|
|
|
igm.link(orig_to_isl.at(out_nh), sink_nh);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}}}
|
|
|
|