Skip to content

Commit

Permalink
Merge branch 'lwawrzyniak/avoid-kernel-strong-references' into 'main'
Browse files Browse the repository at this point in the history
Avoid keeping strong references to kernels

See merge request omniverse/warp!843
  • Loading branch information
mmacklin committed Nov 6, 2024
2 parents 6b3023e + 18c8537 commit 29421d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions warp/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ def __init__(self, module):
self.functions_in_progress = set()

# all unique kernels for codegen, filtered by hash
self.unique_kernels = {} # (hash: kernel)
self.unique_kernels = weakref.WeakValueDictionary() # (hash: kernel)

# start hashing the module
ch = hashlib.sha256()
Expand Down Expand Up @@ -1555,7 +1555,7 @@ def __init__(self, module, options, hasher=None):
hasher = ModuleHasher(module)

# build all unique kernels
self.kernels = hasher.get_unique_kernels()
self.kernels = weakref.WeakSet(hasher.get_unique_kernels())
for kernel in self.kernels:
self.build_kernel(kernel)

Expand Down Expand Up @@ -1680,7 +1680,7 @@ def __init__(self, handle, module_hash, device):
self.handle = handle
self.module_hash = module_hash
self.device = device
self.kernel_hooks = {}
self.kernel_hooks = weakref.WeakKeyDictionary()

# release the loaded module
def __del__(self):
Expand Down

0 comments on commit 29421d1

Please sign in to comment.