Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs for module-level API #1091

Merged
merged 13 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conda/environments/rmm_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
- cython>=0.29,<0.30
- gcovr>=5.0
- cuda-python>=11.5,<11.7.1
- sphinx_rtd_theme
1 change: 1 addition & 0 deletions conda/environments/rmm_dev_cuda11.6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
- cython>=0.29,<0.30
- gcovr>=5.0
- cuda-python>=11.6,11.7.1
- sphinx_rtd_theme
15 changes: 3 additions & 12 deletions python/docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
API Reference
==============

High-level API
--------------
Module Contents
---------------

.. automodule:: rmm.rmm
.. automodule:: rmm
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -17,12 +17,3 @@ Memory Resources
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: rmm
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion python/docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ This can be done in two ways:

1. Setting the environment variable `NUMBA_CUDA_MEMORY_MANAGER`:

```python
```bash
$ NUMBA_CUDA_MEMORY_MANAGER=rmm python (args)
```

Expand Down
25 changes: 8 additions & 17 deletions python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
# -- Project information -----------------------------------------------------

project = "rmm"
copyright = "2020, NVIDIA"
copyright = "2020-2022, NVIDIA"
author = "NVIDIA"

# The full version, including alpha/beta/rc tags
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "22.10"
# The full version, including alpha/beta/rc tags.
release = "22.10.00"


Expand All @@ -39,7 +45,6 @@
"IPython.sphinxext.ipython_directive",
"nbsphinx",
"recommonmark",
"sphinx.ext.napoleon",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this extension was causing havoc with the docs. A lot of things weren't rendering properly, and I would guess it was because of napoleon interacting poorly with Cython-generated docs or a conflict with some other Sphinx extension. The numpydoc extension is sufficient to use on its own nowadays, and napoleon isn't needed here.

]


Expand All @@ -59,20 +64,6 @@
# The master toctree document.
master_doc = "index"

# General information about the project.
project = "rmm"
copyright = "2020, NVIDIA"
author = "NVIDIA"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "22.10"
# The full version, including alpha/beta/rc tags.
release = "22.10.00"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ requires = [

[tool.black]
line-length = 79
target-version = ["py36"]
target-version = ["py38"]
include = '\.py?$'
exclude = '''
/(
Expand Down
17 changes: 17 additions & 0 deletions python/rmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,21 @@
unregister_reinitialize_hook,
)

__all__ = [
"DeviceBuffer",
"RMMError",
"RMMNumbaManager",
"_numba_memory_manager",
bdice marked this conversation as resolved.
Show resolved Hide resolved
"disable_logging",
"enable_logging",
"get_log_filenames",
"get_versions",
"is_initialized",
"mr",
"register_reinitialize_hook",
"reinitialize",
"rmm_cupy_allocator",
"unregister_reinitialize_hook",
]

__version__ = get_versions()["version"]
3 changes: 3 additions & 0 deletions python/rmm/_lib/device_buffer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ cdef class DeviceBuffer:

@property
def nbytes(self):
"""Gets the size of the buffer in bytes."""
return self.size

@property
def ptr(self):
"""Gets a pointer to the underlying data."""
return int(<uintptr_t>self.c_data())

@property
def size(self):
"""Gets the size of the buffer in bytes."""
return int(self.c_size())

def __reduce__(self):
Expand Down
2 changes: 1 addition & 1 deletion python/rmm/_lib/memory_resource.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor):

cdef class BinningMemoryResource(UpstreamResourceAdaptor):

cdef readonly list bin_mrs
cdef list _bin_mrs
bdice marked this conversation as resolved.
Show resolved Hide resolved

cpdef add_bin(
self,
Expand Down
15 changes: 10 additions & 5 deletions python/rmm/_lib/memory_resource.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor):
int8_t max_size_exponent=-1,
):

self.bin_mrs = []
self._bin_mrs = []

if (min_size_exponent == -1 or max_size_exponent == -1):
self.c_obj.reset(
Expand Down Expand Up @@ -460,15 +460,15 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor):

If min_size_exponent and max_size_exponent are specified, initializes
with one or more FixedSizeMemoryResource bins in the range
[2^min_size_exponent, 2^max_size_exponent].
``[2**min_size_exponent, 2**max_size_exponent]``.

Call add_bin to add additional bin allocators.
Call :py:meth:`~.add_bin` to add additional bin allocators.

Parameters
----------
upstream_mr : DeviceMemoryResource
The memory resource to use for allocations larger than any of the
bins
bins.
min_size_exponent : size_t
The base-2 exponent of the minimum size FixedSizeMemoryResource
bin to create.
Expand Down Expand Up @@ -506,13 +506,18 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor):
self.c_obj.get()))[0].add_bin(allocation_size)
else:
# Save the ref to the new bin resource to ensure its lifetime
self.bin_mrs.append(bin_resource)
self._bin_mrs.append(bin_resource)

(<binning_memory_resource[device_memory_resource]*>(
self.c_obj.get()))[0].add_bin(
allocation_size,
bin_resource.get_mr())

@property
def bin_mrs(self) -> list:
"""Get the list of binned memory resources."""
return self._bin_mrs


cdef void* _allocate_callback_wrapper(
size_t nbytes,
Expand Down