Probably using the base Graph API for node creation and insertion is the cleanest. For an example of how to take “foreign” Node*s not owned by a graph and copy them into the graph, the Graph::copy method is a useful example: https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/ir/ir.cpp#L680 14