Fix: BEAM search with PTX fails (#3786)

* Pass Uopgraph instead of list

* Add search compile linearizer test

* Rename

* fix lint

* Remove test. Add  UOpGraph type
This commit is contained in:
Elias Wahl
2024-03-18 16:13:32 -04:00
committed by GitHub
parent 629757eaa1
commit 7af7467f22
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ from tinygrad.helpers import ansilen, DEBUG, getenv, colored, BEAM, NOOPT, all_i
from tinygrad.helpers import prod
from tinygrad.shape.symbolic import Variable, sym_infer, sint
from tinygrad.ops import LazyOp, get_lazyop_info, GlobalCounters
from tinygrad.codegen.uops import UOpGraph
from dataclasses import dataclass
if TYPE_CHECKING:
@@ -183,7 +184,7 @@ MallocAllocator = _MallocAllocator()
class Compiler:
linearizer_opts: ClassVar[LinearizerOptions]
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 render(self, name:str, uops:UOpGraph) -> 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:
if self.cachekey is None or (lib := diskcache_get(self.cachekey, src)) is None:
+1 -1
View File
@@ -49,7 +49,7 @@ def _time_program(variables:List[Variable], outcount:int, rdev:Compiled, lib:byt
def _compile_linearizer(compiler:Compiler, lin:Linearizer, name:Optional[str]=None) -> Tuple[bytes, Optional[List[int]], Optional[List[int]],
List[Variable], int]:
lin.linearize()
src = compiler.render(name if name is not None else to_function_name(lin.name), lin.uops.uops) # NOTE: these all have the same name for deduping
src = compiler.render(name if name is not None else to_function_name(lin.name), lin.uops) # NOTE: these all have the same name for deduping
if DEBUG >= 5: print(src)
return compiler.compile(src), lin.global_size, lin.local_size, lin.uops.vars(), len(lin.outbufs)