Skip to content

Commit 59bd9b8

Browse files
committed
MAINT: address a review comment
1 parent 53447cd commit 59bd9b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

torch_np/_funcs_impl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import annotations
99

1010
import builtins
11+
import itertools
1112
import math
1213
import operator
1314
from typing import Optional, Sequence
@@ -1280,7 +1281,9 @@ def einsum(*operands, out=None, optimize=False, **kwargs):
12801281
# recombine operands
12811282
sublists = operands[1::2]
12821283
sublistout = (operands[-1],) if len(operands) % 2 == 1 else ()
1283-
operands = builtins.sum((_ for _ in zip(tensors, sublists)), ()) + sublistout
1284+
operands = list(itertools.chain(*zip(tensors, sublists)))
1285+
if len(operands) % 2 == 1:
1286+
operands.append(sublistout)
12841287

12851288
result = torch.einsum(*operands)
12861289
else:

0 commit comments

Comments
 (0)