From ab880b1b8f7bd7962ba3e29c804429443c99d052 Mon Sep 17 00:00:00 2001 From: qazal Date: Tue, 25 Mar 2025 17:30:29 +0800 Subject: [PATCH] add NULL=1 backend --- tinygrad/runtime/ops_null.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tinygrad/runtime/ops_null.py diff --git a/tinygrad/runtime/ops_null.py b/tinygrad/runtime/ops_null.py new file mode 100644 index 0000000000..e73edb2f8d --- /dev/null +++ b/tinygrad/runtime/ops_null.py @@ -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)