Skip to content

Commit 81d8c25

Browse files
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 more
1 parent f63b829 commit 81d8c25

File tree

5 files changed

+1211
-0
lines changed

5 files changed

+1211
-0
lines changed

cpp/c_api.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "./dep_graph.h"
12
#include "./registry.h"
23
#include <mlc/core/all.h>
34

0 commit comments

Comments
 (0)