Browse Source

fix(mge): fix graph binding refcnt

GitOrigin-RevId: c955eb260a
release-1.1
Megvii Engine Team 4 years ago
parent
commit
53ec6b833e
2 changed files with 10 additions and 1 deletions
  1. +1
    -1
      imperative/python/src/graph_rt.h
  2. +9
    -0
      imperative/python/test/unit/test_cgtools.py

+ 1
- 1
imperative/python/src/graph_rt.h View File

@@ -25,7 +25,7 @@ class GraphNodePtr {
T* m_node;
public:
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) {}
T* operator->() {return m_node;}
T& operator*() {return *m_node;}


+ 9
- 0
imperative/python/test/unit/test_cgtools.py View File

@@ -89,3 +89,12 @@ def test_graph_traversal():
_, var_idx = var2oprs[input_var.id][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

Loading…
Cancel
Save