Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions cuda_core/cuda/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def _import_versioned_module():
VirtualMemoryResource,
VirtualMemoryResourceOptions,
)
from cuda.core._memoryview import (
StridedMemoryView,
args_viewable_as_strided_memory,
)
from cuda.core._module import Kernel, ObjectCode
from cuda.core._program import Program, ProgramOptions
from cuda.core._stream import (
Expand Down
6 changes: 2 additions & 4 deletions cuda_core/docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,14 @@ Types
system.Device
system.NvlinkInfo

.. module:: cuda.core.utils

Utility functions
-----------------

.. autosummary::
:toctree: generated/

args_viewable_as_strided_memory
utils.args_viewable_as_strided_memory

:template: autosummary/cyclass.rst

StridedMemoryView
utils.StridedMemoryView
5 changes: 5 additions & 0 deletions cuda_core/docs/source/release/1.0.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ Breaking changes
- :obj:`cuda.core.typing.DevicePointerT` -> :obj:`cuda.core.typing.DevicePointerType`
- :obj:`cuda.core.typing.IsStreamT` -> :obj:`cuda.core.typing.IsStreamType`

- :func:`args_viewable_as_strided_memory` and :class:`StridedMemoryView` are now
longer at the top-level in :mod:`cuda.core`. They are available publicly from the
:mod:`cuda.core.utils` module.
(`#2028 <https://github.com/NVIDIA/cuda-python/issues/2028>`__)
Comment on lines +128 to +131
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW they were always meant to be available via utils, it seems we slipped in the v0.4 - v0.5 timeframe.


Fixes and enhancements
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion cuda_core/examples/tma_tensor_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
LaunchConfig,
Program,
ProgramOptions,
StridedMemoryView,
launch,
)
from cuda.core.utils import StridedMemoryView
from cuda.pathfinder import get_cuda_path_or_home

# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
Buffer,
Device,
GraphicsResource,
StridedMemoryView,
)
from cuda.core.utils import StridedMemoryView

# ---------------------------------------------------------------------------
# GL context + buffer helpers
Expand Down
24 changes: 24 additions & 0 deletions cuda_core/tests/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,3 +1603,27 @@ def test_memory_resource_alloc_zero_bytes(init_cuda, memory_resource_factory):
assert buffer.handle >= 0
assert buffer.size == 0
assert buffer.device_id == mr.device_id


def test_strided_memory_view_not_in_top_level_namespace():
# Regression test for issue #2027: StridedMemoryView and
# args_viewable_as_strided_memory must only be exposed via
# cuda.core.utils, not the top-level cuda.core namespace.
import cuda.core
import cuda.core.utils

assert not hasattr(cuda.core, "StridedMemoryView")
assert not hasattr(cuda.core, "args_viewable_as_strided_memory")

assert hasattr(cuda.core.utils, "StridedMemoryView")
assert hasattr(cuda.core.utils, "args_viewable_as_strided_memory")


def test_top_level_namespace_excludes_known_leaks():
# Hardening test: lock the public top-level namespace against
# accidental re-introduction of known-leaked symbols.
import cuda.core

public = {n for n in dir(cuda.core) if not n.startswith("_")}
leaked = {"StridedMemoryView", "args_viewable_as_strided_memory"}
assert not (public & leaked)
2 changes: 1 addition & 1 deletion cuda_core/tests/test_tensor_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from cuda.core import (
Device,
ManagedMemoryResourceOptions,
StridedMemoryView,
TensorMapDescriptor,
system,
)
Expand All @@ -23,6 +22,7 @@
TensorMapSwizzle,
_require_view_device,
)
from cuda.core.utils import StridedMemoryView


@pytest.fixture
Expand Down
Loading