cunumpy 0.7.1__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cunumpy-0.7.1/src/cunumpy.egg-info → cunumpy-0.7.2}/PKG-INFO +8 -1
- {cunumpy-0.7.1 → cunumpy-0.7.2}/pyproject.toml +11 -1
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/__init__.py +9 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/__init__.pyi +1 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_algorithms.py +20 -15
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_cuda_kernel.py +350 -347
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_device.py +28 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_dispatch.py +86 -81
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_fake_cupy_impl.py +74 -72
- cunumpy-0.7.2/src/cunumpy/_kernel_package.py +218 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_linalg.py +3 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_mirror.py +43 -39
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_morton.py +3 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_mpi.py +23 -18
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_optimize.py +4 -0
- cunumpy-0.7.2/src/cunumpy/_profile_tags.py +9 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_pyccel_cache.py +88 -20
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_scipy_host.py +8 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_transfers.py +17 -16
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/__init__.py +2 -0
- cunumpy-0.7.2/src/cunumpy/interop/__init__.py +9 -0
- cunumpy-0.7.2/src/cunumpy/interop/_common.py +96 -0
- cunumpy-0.7.2/src/cunumpy/interop/dlpack.py +54 -0
- cunumpy-0.7.2/src/cunumpy/interop/jax.py +76 -0
- cunumpy-0.7.2/src/cunumpy/interop/mlx.py +71 -0
- cunumpy-0.7.2/src/cunumpy/interop/torch.py +72 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/kernels.py +6 -1
- {cunumpy-0.7.1 → cunumpy-0.7.2/src/cunumpy.egg-info}/PKG-INFO +8 -1
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy.egg-info/SOURCES.txt +9 -1
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy.egg-info/requires.txt +12 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/LICENSE.txt +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/README.md +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/setup.cfg +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/LLM_GUIDE.md +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_emulation.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_fake_cupy.py +10 -10
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_fake_cupyx.py +36 -36
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_fusion.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_host.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_kernel.py +58 -58
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_metal_kernel.py +12 -12
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_philox.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_profiling.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_random_streams.py +8 -8
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_scipy_backend.py +25 -25
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_staging.py +6 -6
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/_streams.py +6 -6
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/algorithms.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/arguments.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/array_view.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/atomic.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/index.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/morton.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/random.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/reduce.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/cuda/include/cunumpy/scan.cuh +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/integrate.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/kernel_testing.py +10 -10
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/memory.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/mpi.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/optimize.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/petsc.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/profiling.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/py.typed +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/rng.py +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy/xp.py +56 -56
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy.egg-info/dependency_links.txt +0 -0
- {cunumpy-0.7.1 → cunumpy-0.7.2}/src/cunumpy.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cunumpy
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
|
|
5
5
|
Author: Max
|
|
6
6
|
License: MIT License
|
|
@@ -40,6 +40,7 @@ License-File: LICENSE.txt
|
|
|
40
40
|
Requires-Dist: array-api-compat
|
|
41
41
|
Requires-Dist: maybempi>=0.1.2
|
|
42
42
|
Requires-Dist: numpy
|
|
43
|
+
Requires-Dist: scope-profiler>=0.7.5
|
|
43
44
|
Provides-Extra: dev
|
|
44
45
|
Requires-Dist: cunumpy[docs,test-compiled]; extra == "dev"
|
|
45
46
|
Requires-Dist: pre-commit; extra == "dev"
|
|
@@ -50,6 +51,12 @@ Requires-Dist: griffe; extra == "docs"
|
|
|
50
51
|
Requires-Dist: ipykernel; extra == "docs"
|
|
51
52
|
Provides-Extra: metal
|
|
52
53
|
Requires-Dist: mlx; (sys_platform == "darwin" and platform_machine == "arm64") and extra == "metal"
|
|
54
|
+
Provides-Extra: jax
|
|
55
|
+
Requires-Dist: jax; extra == "jax"
|
|
56
|
+
Provides-Extra: mlx
|
|
57
|
+
Requires-Dist: mlx; (sys_platform == "darwin" and platform_machine == "arm64") and extra == "mlx"
|
|
58
|
+
Provides-Extra: torch
|
|
59
|
+
Requires-Dist: torch; extra == "torch"
|
|
53
60
|
Provides-Extra: test
|
|
54
61
|
Requires-Dist: coverage; extra == "test"
|
|
55
62
|
Requires-Dist: pytest; extra == "test"
|
|
@@ -5,7 +5,7 @@ requires = [ "setuptools", "wheel" ]
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "cunumpy"
|
|
8
|
-
version = "0.7.
|
|
8
|
+
version = "0.7.2"
|
|
9
9
|
description = "Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
keywords = [ "python" ]
|
|
@@ -25,6 +25,7 @@ dependencies = [
|
|
|
25
25
|
"array-api-compat",
|
|
26
26
|
"maybempi>=0.1.2",
|
|
27
27
|
"numpy",
|
|
28
|
+
"scope-profiler>=0.7.5",
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
optional-dependencies.dev = [
|
|
@@ -37,6 +38,9 @@ optional-dependencies.dev = [
|
|
|
37
38
|
# the shared docs workflow registers an ipykernel even without notebooks
|
|
38
39
|
optional-dependencies.docs = [ "griffe", "ipykernel" ]
|
|
39
40
|
optional-dependencies.metal = [ "mlx; sys_platform == 'darwin' and platform_machine == 'arm64'" ]
|
|
41
|
+
optional-dependencies.jax = [ "jax" ]
|
|
42
|
+
optional-dependencies.mlx = [ "mlx; sys_platform == 'darwin' and platform_machine == 'arm64'" ]
|
|
43
|
+
optional-dependencies.torch = [ "torch" ]
|
|
40
44
|
optional-dependencies.test = [ "coverage", "pytest", "scipy" ]
|
|
41
45
|
optional-dependencies.test-compiled = [ "cunumpy[test]", "pyccel" ]
|
|
42
46
|
urls."Source" = "https://github.com/max-models/cunumpy"
|
|
@@ -47,6 +51,12 @@ where = [ "src" ]
|
|
|
47
51
|
[tool.setuptools.package-data]
|
|
48
52
|
cunumpy = [ "py.typed", "*.pyi", "LLM_GUIDE.md", "cuda/include/cunumpy/*.cuh" ]
|
|
49
53
|
|
|
54
|
+
# PRs to devel test against the devel branches of the max-models packages; PRs to main
|
|
55
|
+
# and the release use PyPI only.
|
|
56
|
+
[tool.uv.sources]
|
|
57
|
+
maybempi = { git = "https://github.com/max-models/maybempi", branch = "devel" }
|
|
58
|
+
scope-profiler = { git = "https://github.com/max-models/scope-profiler", branch = "devel" }
|
|
59
|
+
|
|
50
60
|
[tool.ruff]
|
|
51
61
|
# agent worktrees and scratch scripts are local copies, not part of the project
|
|
52
62
|
extend-exclude = [ ".claude" ]
|
|
@@ -15,11 +15,14 @@ active backend is NumPy or CuPy (prefer :func:`get_backend` for the name).
|
|
|
15
15
|
import re as _re
|
|
16
16
|
from importlib.metadata import PackageNotFoundError, version
|
|
17
17
|
|
|
18
|
+
import scope_profiler as _sp
|
|
19
|
+
|
|
18
20
|
from cunumpy import (
|
|
19
21
|
algorithms,
|
|
20
22
|
arguments,
|
|
21
23
|
cuda,
|
|
22
24
|
integrate,
|
|
25
|
+
interop,
|
|
23
26
|
kernels,
|
|
24
27
|
memory,
|
|
25
28
|
mpi,
|
|
@@ -30,6 +33,7 @@ from cunumpy import (
|
|
|
30
33
|
xp,
|
|
31
34
|
)
|
|
32
35
|
from cunumpy._host import evaluate_on_host, host_call, setup_on_host
|
|
36
|
+
from cunumpy._profile_tags import _PROFILE_TAGS
|
|
33
37
|
from cunumpy._scipy_backend import scipy
|
|
34
38
|
from cunumpy._staging import to_host_async
|
|
35
39
|
from cunumpy.xp import (
|
|
@@ -54,6 +58,10 @@ from cunumpy.xp import (
|
|
|
54
58
|
use_backend,
|
|
55
59
|
)
|
|
56
60
|
|
|
61
|
+
# cunumpy's scope-profiler regions are off unless the application enables the
|
|
62
|
+
# "cunumpy" tag
|
|
63
|
+
_sp.register_opt_in_tag(*_PROFILE_TAGS)
|
|
64
|
+
|
|
57
65
|
try:
|
|
58
66
|
__version__ = version("cunumpy")
|
|
59
67
|
"""The installed version of cunumpy; ``"0.0.0+unknown"`` without package metadata."""
|
|
@@ -116,6 +124,7 @@ __all__ = [
|
|
|
116
124
|
"get_backend",
|
|
117
125
|
"host_call",
|
|
118
126
|
"integrate",
|
|
127
|
+
"interop",
|
|
119
128
|
"is_cpu",
|
|
120
129
|
"is_gpu",
|
|
121
130
|
"kernels",
|
|
@@ -12,6 +12,7 @@ from cunumpy import algorithms as algorithms
|
|
|
12
12
|
from cunumpy import arguments as arguments
|
|
13
13
|
from cunumpy import cuda as cuda
|
|
14
14
|
from cunumpy import integrate as integrate
|
|
15
|
+
from cunumpy import interop as interop
|
|
15
16
|
from cunumpy import kernels as kernels
|
|
16
17
|
from cunumpy import memory as memory
|
|
17
18
|
from cunumpy import mpi as mpi
|
|
@@ -7,8 +7,10 @@ import operator
|
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
9
|
import array_api_compat.numpy as np
|
|
10
|
+
import scope_profiler as sp
|
|
10
11
|
|
|
11
12
|
from cunumpy import _fake_cupy
|
|
13
|
+
from cunumpy._profile_tags import _PROFILE_TAGS
|
|
12
14
|
from cunumpy.xp import assert_same_backend, get_array_backend, get_array_module
|
|
13
15
|
|
|
14
16
|
|
|
@@ -202,6 +204,7 @@ class SegmentPlan:
|
|
|
202
204
|
"""Number of output segments, fixed when the plan is created."""
|
|
203
205
|
return self._n_segments
|
|
204
206
|
|
|
207
|
+
@sp.profile("cunumpy.SegmentPlan.sum", tags=_PROFILE_TAGS)
|
|
205
208
|
def sum(self, values: Any, *, out: Any = None) -> Any:
|
|
206
209
|
"""Sum the rows of `values` per segment.
|
|
207
210
|
|
|
@@ -371,6 +374,22 @@ def _radix_argsort(keys: np.ndarray) -> np.ndarray:
|
|
|
371
374
|
return order.astype(np.int64, copy=False)
|
|
372
375
|
|
|
373
376
|
|
|
377
|
+
def _take_along_axis(xpm: Any, array: Any, order: Any, axis: int) -> Any:
|
|
378
|
+
"""Return `array` taken at `order` along `axis`, as a new C-contiguous array.
|
|
379
|
+
|
|
380
|
+
A component-major ``(ncomp, n)`` NumPy array is gathered one contiguous row at a
|
|
381
|
+
time, which is about twice as fast as ``take`` along its last axis; everything
|
|
382
|
+
else, and CuPy, goes through ``take``.
|
|
383
|
+
"""
|
|
384
|
+
if xpm is np and array.ndim == 2 and axis == 1:
|
|
385
|
+
gathered = np.empty((array.shape[0], order.shape[0]), dtype=array.dtype)
|
|
386
|
+
for row in range(array.shape[0]):
|
|
387
|
+
gathered[row] = array[row][order]
|
|
388
|
+
return gathered
|
|
389
|
+
return xpm.take(array, order, axis=axis)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
@sp.profile("cunumpy.sort_by_key", tags=_PROFILE_TAGS)
|
|
374
393
|
def sort_by_key(keys: Any, *arrays: Any, axis: int = 0) -> tuple[Any, ...]:
|
|
375
394
|
"""Sort `keys` and reorder every array the same way, in one stable argsort.
|
|
376
395
|
|
|
@@ -445,21 +464,7 @@ def sort_by_key(keys: Any, *arrays: Any, axis: int = 0) -> tuple[Any, ...]:
|
|
|
445
464
|
)
|
|
446
465
|
|
|
447
466
|
|
|
448
|
-
|
|
449
|
-
"""Return `array` taken at `order` along `axis`, as a new C-contiguous array.
|
|
450
|
-
|
|
451
|
-
A component-major ``(ncomp, n)`` NumPy array is gathered one contiguous row at a
|
|
452
|
-
time, which is about twice as fast as ``take`` along its last axis; everything
|
|
453
|
-
else, and CuPy, goes through ``take``.
|
|
454
|
-
"""
|
|
455
|
-
if xpm is np and array.ndim == 2 and axis == 1:
|
|
456
|
-
gathered = np.empty((array.shape[0], order.shape[0]), dtype=array.dtype)
|
|
457
|
-
for row in range(array.shape[0]):
|
|
458
|
-
gathered[row] = array[row][order]
|
|
459
|
-
return gathered
|
|
460
|
-
return xpm.take(array, order, axis=axis)
|
|
461
|
-
|
|
462
|
-
|
|
467
|
+
@sp.profile("cunumpy.compact_by_mask", tags=_PROFILE_TAGS)
|
|
463
468
|
def compact_by_mask(mask: Any, *arrays: Any, axis: int = 0) -> int:
|
|
464
469
|
"""Move the entries where `mask` is True to the front of every array, in place.
|
|
465
470
|
|