small cleanups [pr] (#8343)

* small cleanups [pr]

* GPU suppress
This commit is contained in:
George Hotz
2024-12-19 21:20:46 -08:00
committed by GitHub
parent 9f306e12ac
commit adcdc583a2
3 changed files with 13 additions and 21 deletions

View File

@@ -41,9 +41,8 @@ class CLProgram:
self.kernel = checked(cl.clCreateKernel(self.program, name.encode(), status := ctypes.c_int32()), status)
def __del__(self):
with contextlib.suppress(TypeError):
with contextlib.suppress(AttributeError): check(cl.clReleaseKernel(self.kernel))
with contextlib.suppress(AttributeError): check(cl.clReleaseProgram(self.program))
with contextlib.suppress(TypeError, AttributeError): check(cl.clReleaseKernel(self.kernel))
with contextlib.suppress(TypeError, AttributeError): check(cl.clReleaseProgram(self.program))
def __call__(self, *bufs:Tuple[ctypes._CData, BufferSpec], global_size:Tuple[int,int,int]=(1,1,1), local_size:Optional[Tuple[int,int,int]]=None, vals:Tuple[int, ...]=(), wait=False) -> Optional[float]: # noqa: E501
for i,(b,_) in enumerate(bufs): cl.clSetKernelArg(self.kernel, i, ctypes.sizeof(b), ctypes.byref(b))