def test_copy_with_subgraph_dup_tensors(self): inp = Variable("input", dtype=np.float32, shape=(4, 5)) graph = Graph(inputs=[inp]) # We'll use shape to distinguish inner/outer tensor subgraph_inp = Variable("input", dtype=np.float32, shape=(1, 2)) subgraph = Graph(inputs=[subgraph_inp]) graph.outputs = [graph.nested(inp, subgraph)] graph_copy = graph.copy() assert graph_copy.nodes[0].attrs["body"].inputs[0].shape == (1, 2)
def test_copy_with_subgraph_dup_const_tensors(self): inp = Constant("input", values=np.ones(dtype=np.float32, shape=(4, 5))) graph = Graph() # We'll use shape to distinguish inner/outer tensor subgraph_inp = Constant("input", values=np.ones(dtype=np.float32, shape=(1, 2))) subgraph = Graph() subgraph.outputs = [subgraph.identity(subgraph_inp)] graph.outputs = [graph.nested(inp, subgraph)] graph_copy = graph.copy() assert graph_copy.nodes[0].attrs["body"].nodes[0].inputs[0].shape == ( 1, 2)
def test_basic(self): graph = Graph( nodes=[Node(op="Test")], inputs=[Variable("test")], outputs=[Variable("test")], name="test-name", doc_string="test-docstring", import_domains=["fake-import-domain"], opset=-1, ) new_graph = graph.copy() assert new_graph == graph assert new_graph.nodes == graph.nodes assert new_graph.inputs == graph.inputs assert new_graph.outputs == graph.outputs assert new_graph.name == graph.name assert new_graph.doc_string == graph.doc_string assert new_graph.import_domains == graph.import_domains assert new_graph.opset == graph.opset