pyopencl 2024.3__cp39-cp39-win_amd64.whl → 2025.1__cp39-cp39-win_amd64.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.

Binary file
pyopencl/array.py CHANGED
@@ -32,7 +32,7 @@ import builtins
32
32
  from dataclasses import dataclass
33
33
  from functools import reduce
34
34
  from numbers import Number
35
- from typing import Any, Dict, Hashable, List, Optional, Tuple, Union
35
+ from typing import Any, Dict, List, Optional, Tuple, Union
36
36
  from warnings import warn
37
37
 
38
38
  import numpy as np
@@ -58,20 +58,14 @@ else:
58
58
  _SVMPointer_or_nothing = ()
59
59
 
60
60
 
61
- _NUMPY_PRE_2 = np.__version__.startswith("1.")
62
-
63
-
64
61
  # {{{ _get_common_dtype
65
62
 
66
- _COMMON_DTYPE_CACHE: Dict[Tuple[Hashable, ...], np.dtype] = {}
67
-
68
-
69
63
  class DoubleDowncastWarning(UserWarning):
70
64
  pass
71
65
 
72
66
 
73
67
  _DOUBLE_DOWNCAST_WARNING = (
74
- "The operation you requested would result in a double-precisision "
68
+ "The operation you requested would result in a double-precision "
75
69
  "quantity according to numpy semantics. Since your device does not "
76
70
  "support double precision, a single-precision quantity is being returned.")
77
71
 
@@ -81,78 +75,12 @@ def _get_common_dtype(obj1, obj2, queue):
81
75
  raise ValueError("PyOpenCL array has no queue; call .with_queue() to "
82
76
  "add one in order to be able to perform operations")
83
77
 
84
- allow_double = has_double_support(queue.device)
85
- cache_key = None
86
- o1_is_array = isinstance(obj1, Array)
87
- o2_is_array = isinstance(obj2, Array)
88
-
89
- if o1_is_array and o2_is_array:
90
- o1_dtype = obj1.dtype
91
- o2_dtype = obj2.dtype
92
- cache_key = (obj1.dtype, obj2.dtype, allow_double)
93
- else:
94
- o1_dtype = getattr(obj1, "dtype", type(obj1))
95
- o2_dtype = getattr(obj2, "dtype", type(obj2))
96
-
97
- o1_is_integral = np.issubdtype(o1_dtype, np.integer)
98
- o2_is_integral = np.issubdtype(o1_dtype, np.integer)
99
-
100
- o1_key = obj1 if o1_is_integral and not o1_is_array else o1_dtype
101
- o2_key = obj2 if o2_is_integral and not o2_is_array else o2_dtype
78
+ # Note: We are calling np.result_type with pyopencl arrays here.
79
+ # Luckily, np.result_type only looks at the dtype of input arrays up until
80
+ # at least numpy v2.1.
81
+ result = np.result_type(obj1, obj2)
102
82
 
103
- cache_key = (o1_key, o2_key, o1_is_array, o2_is_array, allow_double)
104
-
105
- try:
106
- return _COMMON_DTYPE_CACHE[cache_key]
107
- except KeyError:
108
- pass
109
-
110
- # Numpy's behavior around integers is a bit bizarre, and definitely value-
111
- # and not just type-sensitive when it comes to scalars. We'll just do our
112
- # best to emulate it.
113
- #
114
- # Some samples that are true as of numpy 1.23.1.
115
- #
116
- # >>> a = np.zeros(1, dtype=np.int16)
117
- # >>> (a + 123123123312).dtype
118
- # dtype('int64')
119
- # >>> (a + 12312).dtype
120
- # dtype('int16')
121
- # >>> (a + 12312444).dtype
122
- # dtype('int32')
123
- # >>> (a + np.int32(12312444)).dtype
124
- # dtype('int32')
125
- # >>> (a + np.int32(1234)).dtype
126
- # dtype('int16')
127
- #
128
- # Note that np.find_common_type, while appealing, won't be able to tell
129
- # the full story.
130
-
131
- if (_NUMPY_PRE_2
132
- and not (o1_is_array and o2_is_array)
133
- and o1_is_integral and o2_is_integral):
134
- if o1_is_array:
135
- obj1 = np.zeros(1, dtype=o1_dtype)
136
- if o2_is_array:
137
- obj2 = np.zeros(1, dtype=o2_dtype)
138
-
139
- result = (obj1 + obj2).dtype
140
- else:
141
- array_types = []
142
- scalars = []
143
-
144
- if o1_is_array:
145
- array_types.append(o1_dtype)
146
- else:
147
- scalars.append(obj1)
148
- if o2_is_array:
149
- array_types.append(o2_dtype)
150
- else:
151
- scalars.append(obj2)
152
-
153
- result = np.result_type(*array_types, *scalars)
154
-
155
- if not allow_double:
83
+ if not has_double_support(queue.device):
156
84
  if result == np.float64:
157
85
  result = np.dtype(np.float32)
158
86
  warn(_DOUBLE_DOWNCAST_WARNING, DoubleDowncastWarning, stacklevel=3)
@@ -160,9 +88,6 @@ def _get_common_dtype(obj1, obj2, queue):
160
88
  result = np.dtype(np.complex64)
161
89
  warn(_DOUBLE_DOWNCAST_WARNING, DoubleDowncastWarning, stacklevel=3)
162
90
 
163
- if cache_key is not None:
164
- _COMMON_DTYPE_CACHE[cache_key] = result
165
-
166
91
  return result
167
92
 
168
93
  # }}}
@@ -2518,7 +2443,7 @@ def arange(queue, *args, **kwargs):
2518
2443
  raise TypeError("arange requires a dtype argument")
2519
2444
 
2520
2445
  from math import ceil
2521
- size = int(ceil((stop-start)/step))
2446
+ size = ceil((stop-start)/step)
2522
2447
 
2523
2448
  result = Array(queue, (size,), dtype, allocator=inf.allocator)
2524
2449
  result.add_event(_arange_knl(result, start, step, queue=queue))
pyopencl/cltypes.py CHANGED
@@ -50,7 +50,7 @@ double = np.float64
50
50
  # {{{ vector types
51
51
 
52
52
  def _create_vector_types():
53
- _mapping = [(k, globals()[k]) for k in
53
+ mapping = [(k, globals()[k]) for k in
54
54
  ["char", "uchar", "short", "ushort", "int",
55
55
  "uint", "long", "ulong", "float", "double"]]
56
56
 
@@ -64,7 +64,7 @@ def _create_vector_types():
64
64
 
65
65
  counts = [2, 3, 4, 8, 16]
66
66
 
67
- for base_name, base_type in _mapping:
67
+ for base_name, base_type in mapping:
68
68
  for count in counts:
69
69
  name = "%s%d" % (base_name, count)
70
70
 
pyopencl/version.py CHANGED
@@ -3,7 +3,7 @@ from importlib import metadata
3
3
 
4
4
 
5
5
  VERSION_TEXT = metadata.version("pyopencl")
6
- _match = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
6
+ _match = re.match(r"^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
7
7
  assert _match is not None
8
8
  VERSION_STATUS = _match.group(2)
9
9
  VERSION = tuple(int(nr) for nr in _match.group(1).split("."))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyopencl
3
- Version: 2024.3
3
+ Version: 2025.1
4
4
  Summary: Python wrapper for OpenCL
5
5
  Author-Email: Andreas Kloeckner <inform@tiker.net>
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -1,9 +1,9 @@
1
1
  pyopencl/__init__.py,sha256=wCR09HsGaQ532Dc5vdU8WiyZGZ0qtHBbJQrPQMEGpYI,83853
2
- pyopencl/_cl.cp39-win_amd64.pyd,sha256=frihMFKY_UF30rxQF59fUGovpl55HPqT3fXclocL5C4,580096
2
+ pyopencl/_cl.cp39-win_amd64.pyd,sha256=RmZH6nDKs6fs4QyCr7_Suc6KiMzytJSj_hrJd-5GLCg,633344
3
3
  pyopencl/_cluda.py,sha256=5coLt4eR5BOLgfUesgnaTx_nUhZ6BBhYi9dodvl7cbc,2128
4
4
  pyopencl/_mymako.py,sha256=55mRxOnOH9N7ltPWPND19GD4cszQrB2dhiMUlouoWKU,634
5
5
  pyopencl/algorithm.py,sha256=7ilnIG3c4YMDUBP4w4e10UMDHj9nbFITg1oLnEEsej0,52742
6
- pyopencl/array.py,sha256=Ij8euQy7zxxyxyjw7IM841K0MirNV5Zgr690_wMWmAA,115210
6
+ pyopencl/array.py,sha256=WFKzJt9dAoOzu_iildla41PcWWiKxPmh5e8zYA2LxB8,112974
7
7
  pyopencl/bitonic_sort.py,sha256=r5Jy-C7LE5ml-Qt0KwD4E0g-Cf4DwpmO_3d25KLNUwY,8263
8
8
  pyopencl/bitonic_sort_templates.py,sha256=XQjUiHS9KjFIUYIil1Ls9293hy751AOsJmszlNS-IFk,16745
9
9
  pyopencl/cache.py,sha256=HMS-dEURWulvFOzEY33LzNSw3notDY_Rsv_L16OiSuo,16535
@@ -23,7 +23,7 @@ pyopencl/cl/pyopencl-random123/philox.cl,sha256=KqPbLt54UwrHPvBe7v4ZMzqI2oGrzp0c
23
23
  pyopencl/cl/pyopencl-random123/threefry.cl,sha256=bC78-HJVuc4AFiNppglDQiN8cZRD45hG1PPdi4Sdt-o,55563
24
24
  pyopencl/clmath.py,sha256=GL9s0YwKpCgvsGl6ndoWXEngPFWAqRRR_HOoQm57OA8,8502
25
25
  pyopencl/clrandom.py,sha256=baRE9GgAqGcp2xy9FgI0E4oEygLqyjZqwIs6YvB35ok,13453
26
- pyopencl/cltypes.py,sha256=2jCvMMBtkhXxfbBFBfM4NSFKRg7kEo1tlwGJQlyiwmQ,4955
26
+ pyopencl/cltypes.py,sha256=HL-df-L7ivztkHVXN8ef3TxhjfDVHxs-dXudvycd_P0,4953
27
27
  pyopencl/compyte/.gitignore,sha256=PFMRSJycIqPtcpEn7VqbcenWJqHFDuYtwQm_tLbADt8,189
28
28
  pyopencl/compyte/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  pyopencl/compyte/array.py,sha256=IJzw-dSS_injEiLVNHLlSRi0R2F1sO_8xeeK-XezsSo,7636
@@ -35,8 +35,8 @@ pyopencl/ipython_ext.py,sha256=e-K-Yjd6sTP9-9d69v0k_1_ifdK77JWMhbynn1FBDH4,1983
35
35
  pyopencl/reduction.py,sha256=QoXRhi2_RjUpGDhcfWiMzHHXoBZJuRncnBTn5xwJgR4,26319
36
36
  pyopencl/scan.py,sha256=5YoKCBdIHoPha9onGna_65ne2maU0RZ7nR7X2L47YrA,67553
37
37
  pyopencl/tools.py,sha256=Pzjm7juH52NZ5fF7ppgCy-p9kR-Jhtw8xqnh-qCEjfs,47467
38
- pyopencl/version.py,sha256=Fp_v5G59_24Um9NujHpex3VRwdffKTwtN8tjiQl5QOQ,276
39
- pyopencl-2024.3.dist-info/METADATA,sha256=3Y2AW8BahKcnAPNcX0jR65xiQPsUluv8sTbrVsCtZZc,4783
40
- pyopencl-2024.3.dist-info/WHEEL,sha256=s-IzttuPuPJp8zDv-jm-zGvTOCxdFCvjX9dIQ9zqnM8,104
41
- pyopencl-2024.3.dist-info/licenses/LICENSE,sha256=jib9h6nV8oAvCkKPKDecpLakmQi1SktCn4YXmllgySY,15566
42
- pyopencl-2024.3.dist-info/RECORD,,
38
+ pyopencl/version.py,sha256=sFqCA3Ga7hdYRf_43asDOP4gFoFRrZxfkMoyN-HAgNo,277
39
+ pyopencl-2025.1.dist-info/METADATA,sha256=WUY6JEb89dxhMwOVvX9OJVBYPqzlqPNt1TypeIxsCkQ,4783
40
+ pyopencl-2025.1.dist-info/WHEEL,sha256=s-IzttuPuPJp8zDv-jm-zGvTOCxdFCvjX9dIQ9zqnM8,104
41
+ pyopencl-2025.1.dist-info/licenses/LICENSE,sha256=jib9h6nV8oAvCkKPKDecpLakmQi1SktCn4YXmllgySY,15566
42
+ pyopencl-2025.1.dist-info/RECORD,,