aai-institute / nnbench

A small framework for benchmarking machine learning models.
https://aai-institute.github.io/nnbench/
Apache License 2.0
10 stars 3 forks source link

Add global memo cache and integrate with the setUp and teardown injection #130

Closed maxmynter closed 6 months ago

maxmynter commented 6 months ago

Closes #126 Needs #127

nicholasjng commented 6 months ago

Before you continue: Let's try with a bare dict with lock in nnbench.types.memo as a cache first, since all methods you implemented are class-scoped.

Likewise, getting a memo from cache should prompt a key lookup first:

# this in a decorator applied to Memo.__call__():
_sid = id(self)
if _sid in _memo_cache:
    return _memo_cache[_sid]
return self.__call__()