Skip to content

Commit

Permalink
speed
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Jul 3, 2024
1 parent 5d911e2 commit 94385ab
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/gpt/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __init__(self):
self.n_lattices = None
self.tt = timer("compiler")
self.verbose = g.default.is_verbose("compiler_performance")
self.lattice_cache = []
self.lattice_cache_index = 0

def code(self):
return coder(self)
Expand All @@ -68,6 +70,7 @@ def execute(self):

self.lattices = []
self.lattice_index = {}
self.lattice_cache_index = 0

if self.verbose:
g.message(self.tt)
Expand All @@ -84,10 +87,14 @@ def __call__(self, first, second=None, ac=False):
self.tt("code eval")
if second is None:
second = first
grid, otype, return_list, nlat = first.container()
assert nlat == 1 and not return_list

first = g.lattice(grid, otype)
if not self.compiled:
grid, otype, return_list, nlat = first.container()
assert nlat == 1 and not return_list
first = g.lattice(grid, otype)
self.lattice_cache.append(first)
else:
first = self.lattice_cache[self.lattice_cache_index]
self.lattice_cache_index += 1

if self.representative is None:
self.representative = first
Expand Down

0 comments on commit 94385ab

Please sign in to comment.