Skip to content

Commit c6a9b73

Browse files
committed
add docstring
1 parent b329831 commit c6a9b73

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

numba_cuda/numba/cuda/cudadrv/managed_module.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66

77
class _CuFuncProxy:
8+
"""See `ManagedModule` for more details
9+
"""
810
def __init__(self, module, cufunc):
911
self._module = module
1012
self._cufunc = cufunc
@@ -21,6 +23,14 @@ def __getattr__(self, name):
2123

2224
class ManagedModule:
2325
def __init__(self, module, setup_callbacks, teardown_callbacks):
26+
"""ctypes module with setup and teardown callbacks
27+
The use of managedmodule is the same as a ctypes module,
28+
with the exception of `get_function`, which returns a wrapped
29+
cufunc object. The wrapped object provides `init_module`
30+
and `lazy_finalize_module` method. Which are used
31+
to initialize and finalize the module when stream is available
32+
in the later stage of the compilation pipeline.
33+
"""
2434
# To be updated to object code
2535
if not isinstance(module, CtypesModule):
2636
raise TypeError("module must be a CtypesModule")
@@ -43,11 +53,14 @@ def __init__(self, module, setup_callbacks, teardown_callbacks):
4353
self._teardown_callbacks = teardown_callbacks
4454

4555
def _init(self, stream):
56+
"""Eagerly call the setup functions for cumodule on `stream`
57+
"""
4658
for setup in self._setup_callbacks:
4759
setup(self._module, stream)
4860

4961
def _lazy_finalize(self, stream):
50-
62+
"""Set teardown function for cumodule via weakref finalizer.
63+
"""
5164
def lazy_callback(callbacks, module, stream):
5265
for teardown in callbacks:
5366
teardown(module, stream)
@@ -69,6 +82,8 @@ def lazy_callback(callbacks, module, stream):
6982
)
7083

7184
def get_function(self, name):
85+
"""Returns wrapped CtypesFunc object.
86+
"""
7287
ctypesfunc = self._module.get_function(name)
7388
return _CuFuncProxy(self, ctypesfunc)
7489

0 commit comments

Comments
 (0)