Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes operands could not be broadcast error when the subscripts contain ellipsis and the operands are shapes. #236

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opt_einsum/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def parse_einsum_input(operands: Any, shapes: bool = False) -> Tuple[str, str, L
subscripts, operands = convert_interleaved_input(operands)

if shapes:
operand_shapes = operands
operand_shapes = [list(s) for s in operands]
else:
operand_shapes = [o.shape for o in operands]

Expand Down
9 changes: 9 additions & 0 deletions opt_einsum/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ def test_parse_einsum_input_shapes() -> None:
assert input_subscripts == eq
assert output_subscript == "ad"
assert np.allclose([possibly_convert_to_numpy(shp) for shp in shps], operands)


def test_parse_with_ellisis():
eq = "...a,ab"
shps = [(2, 3), (3, 4)]
input_subscripts, output_subscript, operands = parse_einsum_input([eq, *shps], shapes=True)
assert input_subscripts == "da,ab"
assert output_subscript == "db"
assert np.allclose([possibly_convert_to_numpy(shp) for shp in shps], operands)
Loading