pyopencl 2025.1__cp313-cp313-macosx_11_0_arm64.whl → 2025.2.2__cp313-cp313-macosx_11_0_arm64.whl
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.
Potentially problematic release.
This version of pyopencl might be problematic. Click here for more details.
- pyopencl/__init__.py +582 -997
- pyopencl/_cl.cpython-313-darwin.so +0 -0
- pyopencl/_cl.pyi +2006 -0
- pyopencl/_cluda.py +3 -0
- pyopencl/_monkeypatch.py +1063 -0
- pyopencl/_mymako.py +3 -0
- pyopencl/algorithm.py +29 -24
- pyopencl/array.py +300 -255
- pyopencl/bitonic_sort.py +5 -2
- pyopencl/bitonic_sort_templates.py +3 -0
- pyopencl/cache.py +5 -5
- pyopencl/capture_call.py +31 -8
- pyopencl/characterize/__init__.py +26 -19
- pyopencl/characterize/performance.py +3 -0
- pyopencl/clmath.py +2 -0
- pyopencl/clrandom.py +3 -0
- pyopencl/cltypes.py +67 -2
- pyopencl/compyte/.basedpyright/baseline.json +1272 -0
- pyopencl/compyte/array.py +36 -9
- pyopencl/compyte/dtypes.py +61 -29
- pyopencl/compyte/pyproject.toml +17 -22
- pyopencl/elementwise.py +13 -10
- pyopencl/invoker.py +13 -17
- pyopencl/ipython_ext.py +2 -0
- pyopencl/py.typed +0 -0
- pyopencl/reduction.py +72 -43
- pyopencl/scan.py +31 -30
- pyopencl/tools.py +128 -90
- pyopencl/typing.py +57 -0
- pyopencl/version.py +2 -0
- {pyopencl-2025.1.dist-info → pyopencl-2025.2.2.dist-info}/METADATA +11 -10
- pyopencl-2025.2.2.dist-info/RECORD +47 -0
- {pyopencl-2025.1.dist-info → pyopencl-2025.2.2.dist-info}/WHEEL +2 -1
- pyopencl-2025.1.dist-info/RECORD +0 -42
- {pyopencl-2025.1.dist-info → pyopencl-2025.2.2.dist-info}/licenses/LICENSE +0 -0
pyopencl/_mymako.py
CHANGED
pyopencl/algorithm.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Algorithms built on scans."""
|
|
2
|
+
from __future__ import annotations
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
__copyright__ = """
|
|
@@ -30,7 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
33
|
from dataclasses import dataclass
|
|
33
|
-
from typing import
|
|
34
|
+
from typing import TYPE_CHECKING
|
|
34
35
|
|
|
35
36
|
import numpy as np
|
|
36
37
|
from mako.template import Template
|
|
@@ -38,12 +39,15 @@ from mako.template import Template
|
|
|
38
39
|
from pytools import memoize, memoize_method
|
|
39
40
|
|
|
40
41
|
import pyopencl as cl
|
|
41
|
-
import pyopencl.array
|
|
42
|
-
from pyopencl.elementwise import ElementwiseKernel
|
|
42
|
+
import pyopencl.array as cl_array
|
|
43
43
|
from pyopencl.scan import GenericScanKernel, ScanTemplate
|
|
44
44
|
from pyopencl.tools import dtype_to_ctype, get_arg_offset_adjuster_code
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
if TYPE_CHECKING:
|
|
48
|
+
from pyopencl.elementwise import ElementwiseKernel
|
|
49
|
+
|
|
50
|
+
|
|
47
51
|
# {{{ "extra args" handling utility
|
|
48
52
|
|
|
49
53
|
def _extract_extra_args_types_values(extra_args):
|
|
@@ -55,7 +59,7 @@ def _extract_extra_args_types_values(extra_args):
|
|
|
55
59
|
extra_args_values = []
|
|
56
60
|
extra_wait_for = []
|
|
57
61
|
for name, val in extra_args:
|
|
58
|
-
if isinstance(val,
|
|
62
|
+
if isinstance(val, cl_array.Array):
|
|
59
63
|
extra_args_types.append(VectorArg(val.dtype, name, with_offset=False))
|
|
60
64
|
extra_args_values.append(val)
|
|
61
65
|
extra_wait_for.extend(val.events)
|
|
@@ -117,7 +121,7 @@ def copy_if(ary, predicate, extra_args=None, preamble="", queue=None, wait_for=N
|
|
|
117
121
|
type_aliases=(("scan_t", scan_dtype), ("item_t", ary.dtype)),
|
|
118
122
|
var_values=(("predicate", predicate),),
|
|
119
123
|
more_preamble=preamble, more_arguments=extra_args_types)
|
|
120
|
-
out =
|
|
124
|
+
out = cl_array.empty_like(ary)
|
|
121
125
|
count = ary._new_with_changes(data=None, offset=0,
|
|
122
126
|
shape=(), strides=(), dtype=scan_dtype)
|
|
123
127
|
|
|
@@ -207,8 +211,8 @@ def partition(ary, predicate, extra_args=None, preamble="",
|
|
|
207
211
|
var_values=(("predicate", predicate),),
|
|
208
212
|
more_preamble=preamble, more_arguments=extra_args_types)
|
|
209
213
|
|
|
210
|
-
out_true =
|
|
211
|
-
out_false =
|
|
214
|
+
out_true = cl_array.empty_like(ary)
|
|
215
|
+
out_false = cl_array.empty_like(ary)
|
|
212
216
|
count = ary._new_with_changes(data=None, offset=0,
|
|
213
217
|
shape=(), strides=(), dtype=scan_dtype)
|
|
214
218
|
|
|
@@ -279,7 +283,7 @@ def unique(ary, is_equal_expr="a == b", extra_args=None, preamble="",
|
|
|
279
283
|
var_values=(("macro_is_equal_expr", is_equal_expr),),
|
|
280
284
|
more_preamble=preamble, more_arguments=extra_args_types)
|
|
281
285
|
|
|
282
|
-
out =
|
|
286
|
+
out = cl_array.empty_like(ary)
|
|
283
287
|
count = ary._new_with_changes(data=None, offset=0,
|
|
284
288
|
shape=(), strides=(), dtype=scan_dtype)
|
|
285
289
|
|
|
@@ -556,7 +560,7 @@ class RadixSort:
|
|
|
556
560
|
base_bit = 0
|
|
557
561
|
while base_bit < key_bits:
|
|
558
562
|
sorted_args = [
|
|
559
|
-
|
|
563
|
+
cl_array.empty(queue, n, arg_descr.dtype, allocator=allocator)
|
|
560
564
|
for arg_descr in self.arguments
|
|
561
565
|
if arg_descr.name in self.sort_arg_names]
|
|
562
566
|
|
|
@@ -574,7 +578,7 @@ class RadixSort:
|
|
|
574
578
|
base_bit += self.bits
|
|
575
579
|
|
|
576
580
|
return [arg_val
|
|
577
|
-
for arg_descr, arg_val in zip(self.arguments, args)
|
|
581
|
+
for arg_descr, arg_val in zip(self.arguments, args, strict=True)
|
|
578
582
|
if arg_descr.name in self.sort_arg_names], last_evt
|
|
579
583
|
|
|
580
584
|
# }}}
|
|
@@ -725,12 +729,12 @@ def _get_arg_list(arg_list, prefix=""):
|
|
|
725
729
|
|
|
726
730
|
@dataclass
|
|
727
731
|
class BuiltList:
|
|
728
|
-
count:
|
|
729
|
-
starts:
|
|
730
|
-
lists:
|
|
731
|
-
num_nonempty_lists:
|
|
732
|
-
nonempty_indices:
|
|
733
|
-
compressed_indices:
|
|
732
|
+
count: int | None
|
|
733
|
+
starts: cl_array.Array | None
|
|
734
|
+
lists: cl_array.Array | None = None
|
|
735
|
+
num_nonempty_lists: int | None = None
|
|
736
|
+
nonempty_indices: cl_array.Array | None = None
|
|
737
|
+
compressed_indices: cl_array.Array | None = None
|
|
734
738
|
|
|
735
739
|
|
|
736
740
|
class ListOfListsBuilder:
|
|
@@ -1139,7 +1143,8 @@ class ListOfListsBuilder:
|
|
|
1139
1143
|
compress_kernel = self.get_compress_kernel(index_dtype)
|
|
1140
1144
|
|
|
1141
1145
|
data_args = []
|
|
1142
|
-
for i, (arg_descr, arg_val) in enumerate(
|
|
1146
|
+
for i, (arg_descr, arg_val) in enumerate(
|
|
1147
|
+
zip(self.arg_decls, args, strict=True)):
|
|
1143
1148
|
from pyopencl.tools import VectorArg
|
|
1144
1149
|
if isinstance(arg_descr, VectorArg):
|
|
1145
1150
|
from pyopencl import MemoryObject
|
|
@@ -1179,7 +1184,7 @@ class ListOfListsBuilder:
|
|
|
1179
1184
|
count_list_args.append(None)
|
|
1180
1185
|
continue
|
|
1181
1186
|
|
|
1182
|
-
counts =
|
|
1187
|
+
counts = cl_array.empty(queue,
|
|
1183
1188
|
(n_objects + 1), index_dtype, allocator=allocator)
|
|
1184
1189
|
counts[-1] = 0
|
|
1185
1190
|
wait_for = wait_for + counts.events
|
|
@@ -1219,14 +1224,14 @@ class ListOfListsBuilder:
|
|
|
1219
1224
|
if name not in self.eliminate_empty_output_lists:
|
|
1220
1225
|
continue
|
|
1221
1226
|
|
|
1222
|
-
compressed_counts =
|
|
1227
|
+
compressed_counts = cl_array.empty(
|
|
1223
1228
|
queue, (n_objects + 1,), index_dtype, allocator=allocator)
|
|
1224
1229
|
info_record = result[name]
|
|
1225
|
-
info_record.nonempty_indices =
|
|
1230
|
+
info_record.nonempty_indices = cl_array.empty(
|
|
1226
1231
|
queue, (n_objects + 1,), index_dtype, allocator=allocator)
|
|
1227
|
-
info_record.num_nonempty_lists =
|
|
1232
|
+
info_record.num_nonempty_lists = cl_array.empty(
|
|
1228
1233
|
queue, (1,), index_dtype, allocator=allocator)
|
|
1229
|
-
info_record.compressed_indices =
|
|
1234
|
+
info_record.compressed_indices = cl_array.empty(
|
|
1230
1235
|
queue, (n_objects + 1,), index_dtype, allocator=allocator)
|
|
1231
1236
|
info_record.compressed_indices[0] = 0
|
|
1232
1237
|
|
|
@@ -1301,7 +1306,7 @@ class ListOfListsBuilder:
|
|
|
1301
1306
|
else:
|
|
1302
1307
|
info_record = result[name]
|
|
1303
1308
|
|
|
1304
|
-
info_record.lists =
|
|
1309
|
+
info_record.lists = cl_array.empty(queue,
|
|
1305
1310
|
info_record.count, dtype, allocator=allocator)
|
|
1306
1311
|
write_list_args.append(info_record.lists.data)
|
|
1307
1312
|
|
|
@@ -1431,7 +1436,7 @@ class KeyValueSorter:
|
|
|
1431
1436
|
(values_sorted_by_key, keys_sorted_by_key), evt = knl_info.by_target_sorter(
|
|
1432
1437
|
values, keys, queue=queue, wait_for=wait_for)
|
|
1433
1438
|
|
|
1434
|
-
starts = (
|
|
1439
|
+
starts = (cl_array.empty(queue, (nkeys+1), starts_dtype, allocator=allocator)
|
|
1435
1440
|
.fill(len(values_sorted_by_key), wait_for=[evt]))
|
|
1436
1441
|
evt, = starts.events
|
|
1437
1442
|
|