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

Commit

Permalink
Added axes sorting (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Roberts authored Oct 12, 2020
1 parent 0805faf commit 8bdf29c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensornetwork/network_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,10 @@ def contract_between(
np.mean(node1_output_axes) > np.mean(node2_output_axes)):
node1, node2 = node2, node1
axes1, axes2 = axes2, axes1

# Sorting the indicies improves performance.
ind_sort = [axes1.index(l) for l in sorted(axes1)]
axes1 = [axes1[i] for i in ind_sort]
axes2 = [axes2[i] for i in ind_sort]
new_tensor = backend.tensordot(node1.tensor, node2.tensor, [axes1, axes2])
new_node = Node(tensor=new_tensor, name=name, backend=backend)
# node1 and node2 get new edges in _remove_edges
Expand Down

0 comments on commit 8bdf29c

Please sign in to comment.