mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
type annotation for Compiler.cachekey and minor cleanup (#3298)
This commit is contained in:
@@ -264,12 +264,11 @@ def _get_interpreted_fxn(fxn_for_op:Dict[Op, Callable], ast:LazyOp) -> Interpret
|
||||
|
||||
class Compiler:
|
||||
linearizer_opts: ClassVar[LinearizerOptions]
|
||||
def __init__(self, cachekey=None): self.cachekey = None if getenv("DISABLE_COMPILER_CACHE") else cachekey
|
||||
def __init__(self, cachekey:Optional[str]=None): self.cachekey = None if getenv("DISABLE_COMPILER_CACHE") else cachekey
|
||||
def render(self, name:str, uops) -> str: raise NotImplementedError("need a render function")
|
||||
def compile(self, src:str) -> bytes: raise NotImplementedError("need a compile function")
|
||||
def compile_cached(self, src:str) -> bytes:
|
||||
lib = diskcache_get(self.cachekey, src) if self.cachekey is not None else None
|
||||
if lib is None:
|
||||
if self.cachekey is None or (lib := diskcache_get(self.cachekey, src)) is None:
|
||||
lib = self.compile(src)
|
||||
if self.cachekey is not None: diskcache_put(self.cachekey, src, lib)
|
||||
return lib
|
||||
|
||||
Reference in New Issue
Block a user