forked from textiles-lab/autoknit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed_DAG.hpp
42 lines (34 loc) · 1.08 KB
/
embed_DAG.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include "ScheduleCost.hpp"
#include <vector>
typedef ScheduleCost DAGCost;
typedef uint32_t DAGNodeIndex;
typedef uint32_t DAGEdgeIndex;
struct DAGEdge {
DAGNodeIndex from = -1U;
DAGNodeIndex to = -1U;
uint32_t from_shapes = 0;
uint32_t to_shapes = 0;
std::vector< DAGCost > costs;
//If from != -1U && to != -1U: cost[f * to_shapes + t] --> cost given from/to shape
//If from == -1U: cost[t] is min-cost given to shape
//If to == -1U: cost[f] is min-cost given from shape
};
struct DAGOption {
DAGCost cost;
std::vector< DAGEdgeIndex > in_order;
std::vector< DAGEdgeIndex > out_order;
std::vector< uint32_t > in_shapes;
std::vector< uint32_t > out_shapes;
};
struct DAGNode {
std::vector< DAGOption > options;
};
//NOTE: edges must have from < to (i.e., nodes should be topologically sorted)
bool embed_DAG(
std::vector< DAGNode > const &nodes,
std::vector< DAGEdge > const &edges,
std::vector< uint32_t > *node_options,
std::vector< int32_t > *node_positions, //positions give total left-to-right order of edges/nodes
std::vector< int32_t > *edge_positions
);