Skip to content

Commit

Permalink
contract: fallback to cotengra provided einsum+tensordot
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed May 20, 2024
1 parent 1eef888 commit 931f459
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cotengra/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,17 @@ def __call__(self, *arrays, **kwargs):
if implementation == "cotengra":
_einsum, _tensordot = einsum, tensordot
elif implementation == "autoray":
_einsum = get_lib_fn(backend, "einsum")
_tensordot = get_lib_fn(backend, "tensordot")
try:
_einsum = get_lib_fn(backend, "einsum")
except ImportError:
# fallback to cotengra (matmul) implementation
_einsum = einsum

try:
_tensordot = get_lib_fn(backend, "tensordot")
except ImportError:
# fallback to cotengra (matmul) implementation
_tensordot = tensordot
else:
# manually supplied
_einsum, _tensordot = implementation
Expand Down

0 comments on commit 931f459

Please sign in to comment.