Skip to content

Commit b303501

Browse files
committed
Improve error message in einsum
1 parent 3c3b4a4 commit b303501

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • src/torchjd/sparse/_aten_function_overrides

src/torchjd/sparse/_aten_function_overrides/einsum.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ def group_indices(indices: list[tuple[int, int]]) -> None:
141141
physicals.append(t.physical)
142142
for pdims, index in zip(t.v_to_ps, indices):
143143
if index in indices_to_n_pdims:
144-
assert indices_to_n_pdims[index] == len(pdims)
144+
if indices_to_n_pdims[index] != len(pdims):
145+
raise NotImplementedError(
146+
"einsum currently does not support having a different number of physical "
147+
"dimensions corresponding to matching virtual dimensions of different "
148+
f"tensors. Found {[(t.debug_info(), indices) for t, indices in args]}, "
149+
f"output_indices={output}."
150+
)
145151
else:
146152
indices_to_n_pdims[index] = len(pdims)
147153
p_to_vs = p_to_vs_from_v_to_ps(t.v_to_ps)

0 commit comments

Comments
 (0)