Commit 81d8c25
authored
feat(core): Dependency Graph (#65)
Here’s a draft GitHub PR description you can drop into your merge
request:
This PR introduces a `torch.fx.Graph` style **doubly‐linked** dependency
graph
- Nodes wrap an opaque "statement" plus its input/output variables
- Maintains:
- a `stmt_to_node` map to find a node by its statement
- a `var_to_producer` map from each variable to the node that produces
it
- a `var_to_consumers` map from each variable to all nodes that consume
it
- Provides safe, consistent APIs to:
- create, insert (before/after), replace, erase nodes
- query producers/consumers by node or by variable
### Why it matters
- Enables IR-level transformations and analyses that need to track data
dependencies
- Guarantees correctness of producer/consumer relationships as the graph
is edited
- Lays the groundwork for scheduling passes (topological sort, liveness,
CSE, fusion, etc.)
### Unittests
50 pytest cases covering:
- basic chain graphs, branching graphs, empty/inputs‐only graphs
- all API calls, success & failure modes (invalid anchors, duplicate
stmts/vars, head/leaf errors)
- identity vs. equality, iteration‐stop, idempotent clears, and more1 parent f63b829 commit 81d8c25
File tree
5 files changed
+1211
-0
lines changed- cpp
- python/mlc
- core
- tests/python
5 files changed
+1211
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
0 commit comments