fix deepwalk ctx check (#1536)

This commit is contained in:
YiMing Han
2023-08-14 02:03:17 -04:00
committed by GitHub
parent 2fd7004980
commit e00acb1eaf
2 changed files with 8 additions and 1 deletions

View File

@@ -207,7 +207,7 @@ class Tensor:
def deepwalk(self):
def _deepwalk(node, visited, nodes):
visited.add(node)
if node._ctx:
if getattr(node, "_ctx", None):
for i in node._ctx.parents:
if i not in visited: _deepwalk(i, visited, nodes)
nodes.append(node)