TensorNetwork
TensorNetwork copied to clipboard
Fix `base` contraction
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])
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.