Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 8bdf29c

Browse files
author
Chase Roberts
authored
Added axes sorting (#854)
1 parent 0805faf commit 8bdf29c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tensornetwork/network_components.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,10 @@ def contract_between(
20742074
np.mean(node1_output_axes) > np.mean(node2_output_axes)):
20752075
node1, node2 = node2, node1
20762076
axes1, axes2 = axes2, axes1
2077-
2077+
# Sorting the indicies improves performance.
2078+
ind_sort = [axes1.index(l) for l in sorted(axes1)]
2079+
axes1 = [axes1[i] for i in ind_sort]
2080+
axes2 = [axes2[i] for i in ind_sort]
20782081
new_tensor = backend.tensordot(node1.tensor, node2.tensor, [axes1, axes2])
20792082
new_node = Node(tensor=new_tensor, name=name, backend=backend)
20802083
# node1 and node2 get new edges in _remove_edges

0 commit comments

Comments
 (0)