示例#1
0
    def _patch_order(self, graph, order):
        from acqdp.tensor_network.contraction_tree import ContractionTree
        graph_copy = graph.copy()
        graph_copy.fix()
        tree = ContractionTree.from_order(graph_copy, order)

        res = tree.patch(self.patch_size)
        return res
示例#2
0
 def _order_patch(self, tn, order, split_edges, **kwargs):
     if self.do_patch:
         from acqdp.tensor_network.contraction_tree import ContractionTree
         tn_copy = tn.copy()
         tn_copy.open_edges += [i[1] for i in split_edges]
         tn_copy.fix()
         for edge_name in list(tn_copy.edges_by_name):
             if (len(tn_copy.network[(1, edge_name)])
                     == 0) and edge_name not in tn_copy.open_edges:
                 tn_copy.network.remove_node((1, edge_name))
         assert tn_copy.dtype == tn.dtype
         order = ContractionTree.from_order(tn_copy, order).full_order
         init_order, final_order = self._reorg_order(tn_copy, order)
         tn_copy.open_edges = [
             i for i in tn_copy.open_edges if (1, i) not in split_edges
         ]
         for i in split_edges:
             tn_copy.fix_edge(i[1])
         tn_copy.fix()
         if len(final_order) > 0:
             final_order = self._patch_order(tn_copy, final_order)
         return init_order, final_order
     else:
         return [], order
示例#3
0
 def order_to_subscripts_tree(self, tn, order):
     from acqdp.tensor_network.contraction_tree import ContractionTree
     tree = ContractionTree.from_order(tn, order)
     return tree.full_subscripts, tree.full_order