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

Fix base contraction #974

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

y-richie-y
Copy link

Deals with scalar tensors in the network, where opt_einsum may include a 1-element tuples in the opt_path.

Current behaviour:

This errs

import numpy as np
import tensornetwork as tn

a = tn.Node(np.array(2))
b = tn.Node(np.array(3))

tn.contractors.auto([a, b])

This errs

import numpy as np
import tensornetwork as tn

a = tn.Node(np.array(2))
b = tn.Node(np.array([1, 2]))
c = tn.Node(np.array([3, 4]))

tn.connect(b[0], c[0])
tn.contractors.auto([a, b, c])

But this works.

import numpy as np
import tensornetwork as tn

a = tn.Node(np.array([1, 2]))
b = tn.Node(np.array([3, 4]))
c = tn.Node(np.array([1, 2]))
d = tn.Node(np.array([3, 4]))

tn.connect(a[0], b[0])
tn.connect(c[0], d[0])
tn.contractors.auto([a, b, c, d])

@google-cla
Copy link

google-cla bot commented Sep 4, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant