add NULL=1 backend

This commit is contained in:
qazal
2025-03-25 17:30:29 +08:00
parent b60d9976b4
commit ab880b1b8f

View File

@@ -0,0 +1,17 @@
from tinygrad.device import Compiled, Compiler, MallocAllocator, Renderer, Allocator
class NullRenderer(Renderer):
def render(self, uops:list) -> str: return ""
class NullProgram:
def __init__(self, name:str, lib:bytes): pass
def __call__(self, *bufs, global_size:tuple[int,int,int]=(1,1,1), local_size:tuple[int,int,int]=(1,1,1), vals:tuple[int, ...]=(), wait=False):
pass
class NullAllocator(Allocator):
def _alloc(self, size, options): return "null"
def _copyin(self, dest, src:memoryview): pass
def _copyout(self, dest:memoryview, src): pass
class NullDevice(Compiled):
def __init__(self, device:str): super().__init__(device, NullAllocator(), NullRenderer(), Compiler(), NullProgram)