提交 53ec6b83 编写于 作者: M Megvii Engine Team

fix(mge): fix graph binding refcnt

GitOrigin-RevId: c955eb260ac3d366cbdb8761e1fef3b12449f6f6
上级 94f1f634
...@@ -25,7 +25,7 @@ class GraphNodePtr { ...@@ -25,7 +25,7 @@ class GraphNodePtr {
T* m_node; T* m_node;
public: public:
GraphNodePtr(T* node) : GraphNodePtr(T* node) :
m_graph(node ? nullptr : node->owner_graph()->shared_from_this()), m_graph(node ? node->owner_graph()->shared_from_this() : nullptr),
m_node(node) {} m_node(node) {}
T* operator->() {return m_node;} T* operator->() {return m_node;}
T& operator*() {return *m_node;} T& operator*() {return *m_node;}
......
...@@ -89,3 +89,12 @@ def test_graph_traversal(): ...@@ -89,3 +89,12 @@ def test_graph_traversal():
_, var_idx = var2oprs[input_var.id][0] _, var_idx = var2oprs[input_var.id][0]
assert var_idx == 0 assert var_idx == 0
def test_load_refcnt():
graph = mgb_graph.Graph()
varnode = graph.make_const(0)
buf, _ = mgb_graph.dump_graph([varnode])
graph, _, (varnode,) = mgb_graph.load_graph(io.BytesIO(buf))
del graph
varnode.owner
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册