15 auto cg_vert_to_mrrg = std::map<ConfigGraph::VertexID, MRRG::NodeDescriptor>{};
18 for (
const auto& v : config.
allNodes()) {
20 const bool isVal = v_attrs.
hasKey(
"maps_to_val");
21 const bool isOp = v_attrs.hasKey(
"maps_to_op");
23 if (!(isVal || isOp)) {
24 throw make_from_stream<cgrame_error>([&](
auto&& s) {
25 s <<
"mrrg node: " << config.
name(v) <<
" is not mapped to anything";
29 std::string mrrg_node_name = config.
name(v);
32 op_name = v_attrs.getString(
"maps_to_val");
35 op_name = v_attrs.getString(
"maps_to_op");
37 auto mrrg_ndesc = mrrg.
getNode(v_attrs.getInt(
"cycle"), v_attrs.getString(
"name"));
38 if (mrrg_ndesc ==
nullptr) {
39 throw make_from_stream<cgrame_error>([&](
auto&& s) {
40 s <<
"[ERROR]: mrrg node: " << v_attrs.getInt(
"cycle") <<
":" << v_attrs.getString(
"name") <<
" is not part of specified architecture";
54 cg_vert_to_mrrg[v] = mrrg_ndesc;
62 std::unordered_map<MRRG::NodeDescriptor, MappingGraph::NodeDescriptor> fromMRRG;
63 std::unordered_map<MappingGraph::NodeDescriptor, MRRG::NodeDescriptor, MappingGraph::NodeDescriptorHash> toMRRG;
66 for (
auto & opToMRRGNodeList : mapping) {
67 for (
auto & mrrgNode : opToMRRGNodeList.second) {
68 auto mgNode = mg.
insert({opToMRRGNodeList.first}).first;
69 toMRRG.emplace(mgNode, mrrgNode);
70 fromMRRG.emplace(mrrgNode, mgNode);
75 for (
const auto& v : config.
allNodes()) {
76 for (
const auto& out_edge : config.
outEdges(v)) {
77 mg.
link(fromMRRG[cg_vert_to_mrrg.at(v)], fromMRRG[cg_vert_to_mrrg.at(config.
target(out_edge))]);
80 return {mg, fromMRRG, toMRRG};