no exceptions in __del__ when module creation is failed in hip/cuda (#3107)

This commit is contained in:
nimlgen
2024-01-13 12:03:55 -05:00
committed by GitHub
parent 12f28ac9d4
commit cf1d0a6704
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ class CUDAProgram:
self.prg = prg if not CUDACPU else lib
def __del__(self):
if not CUDACPU: check(cuda.cuModuleUnload(self.module))
if hasattr(self, 'module'): check(cuda.cuModuleUnload(self.module))
def __call__(self, *bufs, global_size:Tuple[int,int,int], local_size:Tuple[int,int,int], vals:Tuple[int, ...]=(), wait=False):
if not CUDACPU: check(cuda.cuCtxSetCurrent(self.device.context))
+1 -1
View File
@@ -33,7 +33,7 @@ class HIPProgram:
self.prg = init_c_var(hip.hipFunction_t(), lambda x: check(hip.hipModuleGetFunction(ctypes.byref(x), self.module, name.encode("utf-8"))))
def __del__(self):
if not MOCKHIP: check(hip.hipModuleUnload(self.module))
if hasattr(self, 'module'): check(hip.hipModuleUnload(self.module))
def __call__(self, *args, global_size:Tuple[int,int,int], local_size:Tuple[int,int,int], vals:Tuple[int, ...]=(), wait=False):
if MOCKHIP: return float("inf")