Skip to content

Commit 3c3b4a4

Browse files
committed
Rename variables in einsum
1 parent 93e3a61 commit 3c3b4a4

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • src/torchjd/sparse/_aten_function_overrides

src/torchjd/sparse/_aten_function_overrides/einsum.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def einsum(*args: tuple[StructuredSparseTensor, list[int]], output: list[int]) -
111111
# (i, 1) and (j, 0) will be clustered together (and end up being mapped to the same indice in
112112
# the resulting einsum).
113113
# Note that this is a problem if two virtual dimensions (from possibly different
114-
# DiagonaSparseTensors) have the same size but not the same decomposition into physical
114+
# StructuredSparseTensors) have the same size but not the same decomposition into physical
115115
# dimension sizes. For now lets leave the responsibility to care about that in the calling
116116
# functions, if we can factor code later on we will.
117117

@@ -134,16 +134,16 @@ def group_indices(indices: list[tuple[int, int]]) -> None:
134134
index_parents[curr_representative] = first_representative
135135

136136
new_indices_pair = list[list[tuple[int, int]]]()
137-
tensors = list[Tensor]()
137+
physicals = list[Tensor]()
138138
indices_to_n_pdims = dict[int, int]()
139139
for t, indices in args:
140140
assert isinstance(t, StructuredSparseTensor)
141-
tensors.append(t.physical)
142-
for ps, index in zip(t.v_to_ps, indices):
141+
physicals.append(t.physical)
142+
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(ps)
144+
assert indices_to_n_pdims[index] == len(pdims)
145145
else:
146-
indices_to_n_pdims[index] = len(ps)
146+
indices_to_n_pdims[index] = len(pdims)
147147
p_to_vs = p_to_vs_from_v_to_ps(t.v_to_ps)
148148
for indices_ in p_to_vs:
149149
# elements in indices[indices_] map to the same dimension, they should be clustered
@@ -181,7 +181,7 @@ def unique_int(pair: tuple[int, int]) -> int:
181181
new_output.append(k)
182182
v_to_ps.append(current_v_to_ps)
183183

184-
physical = torch.einsum(*[x for y in zip(tensors, new_indices) for x in y], new_output)
184+
physical = torch.einsum(*[x for y in zip(physicals, new_indices) for x in y], new_output)
185185
# Need to use the safe constructor, otherwise the dimensions may not be maximally grouped.
186186
# Maybe there is a way to fix that though.
187187
return to_most_efficient_tensor(physical, v_to_ps)

0 commit comments

Comments
 (0)