Skip to content

Commit b0c8f3a

Browse files
committed
fail early retrieving dtypes/shapes if node is removed from graph
1 parent 52b574d commit b0c8f3a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tf2onnx/graph.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,16 @@ def need_skip(self):
169169
@property
170170
def output_shapes(self):
171171
"""Get output shapes."""
172+
utils.make_sure(self.graph is not None, "Node %s not belonging any graph",
173+
self.name)
172174
val = [self.graph.get_shape(n) for n in self._output]
173175
return val
174176

175177
@property
176178
def output_dtypes(self):
177179
"""Get output dtypes."""
180+
utils.make_sure(self.graph is not None, "Node %s not belonging any graph",
181+
self.name)
178182
val = [self.graph.get_dtype(n) for n in self._output]
179183
return val
180184

@@ -452,6 +456,7 @@ def remove_node(self, node_name):
452456
del self._dtypes[op_output]
453457

454458
self._nodes.remove(node)
459+
node.graph = None
455460

456461
def reset_nodes(self, ops):
457462
"""Reset the graph with node list."""

0 commit comments

Comments
 (0)