Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lehner/gpt
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Feb 28, 2024
2 parents 0357054 + 17f78a3 commit 5b8aae6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/gpt/core/einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,24 @@ def process_indices(names, values, epsilon_tensors, sign0):
else:
index_value[j] = 0

# now sort by target index
code = sorted(code, key=lambda c: c[1])

# now verify that segmentation works
assert len(code) % nsegment == 0
use_segmentation = all(
[
len(set([c[1] for c in code[i : i + nsegment]])) == 1
for i in range(0, len(code), nsegment)
]
)
if not use_segmentation:
nsegment = 1

# create segmentation
segments = [(len(code) // nsegment, nsegment)]

# and tensor
ein = g.stencil.tensor(tensors_destination[0], [(0, 0, 0, 0)], code, segments)

def exec(*src):
Expand Down

0 comments on commit 5b8aae6

Please sign in to comment.