mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
fix deep copy of empty graph (#141660)
Differential Revision: D66532131 Pull Request resolved: https://github.com/pytorch/pytorch/pull/141660 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
41e59754b4
commit
74eb92ed6e
@ -1099,12 +1099,13 @@ class Graph:
|
||||
g = Graph(tracer_cls=self._tracer_cls)
|
||||
output_vals = g.graph_copy(self, val_map=memo, return_output_node=True)
|
||||
g._codegen = copy.deepcopy(self._codegen)
|
||||
assert isinstance(output_vals, tuple)
|
||||
output_val, old_output_node = output_vals
|
||||
new_output_node = g.output(
|
||||
output_val, type_expr=getattr(old_output_node, "type", None)
|
||||
)
|
||||
new_output_node.meta = copy.copy(old_output_node.meta)
|
||||
if output_vals is not None:
|
||||
assert isinstance(output_vals, tuple)
|
||||
output_val, old_output_node = output_vals
|
||||
new_output_node = g.output(
|
||||
output_val, type_expr=getattr(old_output_node, "type", None)
|
||||
)
|
||||
new_output_node.meta = copy.copy(old_output_node.meta)
|
||||
return g
|
||||
|
||||
@compatibility(is_backward_compatible=True)
|
||||
|
Reference in New Issue
Block a user