numba-cuda 0.21.1__cp313-cp313-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.
Files changed (488) hide show
  1. _numba_cuda_redirector.pth +4 -0
  2. _numba_cuda_redirector.py +89 -0
  3. numba_cuda/VERSION +1 -0
  4. numba_cuda/__init__.py +6 -0
  5. numba_cuda/_version.py +11 -0
  6. numba_cuda/numba/cuda/__init__.py +70 -0
  7. numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
  8. numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
  9. numba_cuda/numba/cuda/api.py +577 -0
  10. numba_cuda/numba/cuda/api_util.py +76 -0
  11. numba_cuda/numba/cuda/args.py +72 -0
  12. numba_cuda/numba/cuda/bf16.py +397 -0
  13. numba_cuda/numba/cuda/cache_hints.py +287 -0
  14. numba_cuda/numba/cuda/cext/__init__.py +2 -0
  15. numba_cuda/numba/cuda/cext/_devicearray.cp313-win_amd64.pyd +0 -0
  16. numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
  17. numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
  18. numba_cuda/numba/cuda/cext/_dispatcher.cp313-win_amd64.pyd +0 -0
  19. numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
  20. numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
  21. numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
  22. numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
  23. numba_cuda/numba/cuda/cext/_helperlib.cp313-win_amd64.pyd +0 -0
  24. numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
  25. numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
  26. numba_cuda/numba/cuda/cext/_typeconv.cp313-win_amd64.pyd +0 -0
  27. numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
  28. numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
  29. numba_cuda/numba/cuda/cext/_typeof.h +19 -0
  30. numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
  31. numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
  32. numba_cuda/numba/cuda/cext/mviewbuf.cp313-win_amd64.pyd +0 -0
  33. numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
  34. numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
  35. numba_cuda/numba/cuda/cg.py +67 -0
  36. numba_cuda/numba/cuda/cgutils.py +1294 -0
  37. numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
  38. numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
  39. numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
  40. numba_cuda/numba/cuda/codegen.py +541 -0
  41. numba_cuda/numba/cuda/compiler.py +1396 -0
  42. numba_cuda/numba/cuda/core/analysis.py +758 -0
  43. numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
  44. numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
  45. numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
  46. numba_cuda/numba/cuda/core/base.py +1332 -0
  47. numba_cuda/numba/cuda/core/boxing.py +1411 -0
  48. numba_cuda/numba/cuda/core/bytecode.py +728 -0
  49. numba_cuda/numba/cuda/core/byteflow.py +2346 -0
  50. numba_cuda/numba/cuda/core/caching.py +744 -0
  51. numba_cuda/numba/cuda/core/callconv.py +392 -0
  52. numba_cuda/numba/cuda/core/codegen.py +171 -0
  53. numba_cuda/numba/cuda/core/compiler.py +199 -0
  54. numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
  55. numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
  56. numba_cuda/numba/cuda/core/config.py +650 -0
  57. numba_cuda/numba/cuda/core/consts.py +124 -0
  58. numba_cuda/numba/cuda/core/controlflow.py +989 -0
  59. numba_cuda/numba/cuda/core/entrypoints.py +57 -0
  60. numba_cuda/numba/cuda/core/environment.py +66 -0
  61. numba_cuda/numba/cuda/core/errors.py +917 -0
  62. numba_cuda/numba/cuda/core/event.py +511 -0
  63. numba_cuda/numba/cuda/core/funcdesc.py +330 -0
  64. numba_cuda/numba/cuda/core/generators.py +387 -0
  65. numba_cuda/numba/cuda/core/imputils.py +509 -0
  66. numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
  67. numba_cuda/numba/cuda/core/interpreter.py +3617 -0
  68. numba_cuda/numba/cuda/core/ir.py +1812 -0
  69. numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
  70. numba_cuda/numba/cuda/core/optional.py +129 -0
  71. numba_cuda/numba/cuda/core/options.py +262 -0
  72. numba_cuda/numba/cuda/core/postproc.py +249 -0
  73. numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
  74. numba_cuda/numba/cuda/core/registry.py +46 -0
  75. numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
  76. numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
  77. numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
  78. numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
  79. numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
  80. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
  81. numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
  82. numba_cuda/numba/cuda/core/sigutils.py +68 -0
  83. numba_cuda/numba/cuda/core/ssa.py +498 -0
  84. numba_cuda/numba/cuda/core/targetconfig.py +330 -0
  85. numba_cuda/numba/cuda/core/tracing.py +231 -0
  86. numba_cuda/numba/cuda/core/transforms.py +956 -0
  87. numba_cuda/numba/cuda/core/typed_passes.py +867 -0
  88. numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
  89. numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
  90. numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
  91. numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
  92. numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
  93. numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
  94. numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
  95. numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
  96. numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
  97. numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
  98. numba_cuda/numba/cuda/cpython/iterators.py +167 -0
  99. numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
  100. numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
  101. numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
  102. numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
  103. numba_cuda/numba/cuda/cpython/slicing.py +322 -0
  104. numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
  105. numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
  106. numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
  107. numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
  108. numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
  109. numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
  110. numba_cuda/numba/cuda/cuda_paths.py +691 -0
  111. numba_cuda/numba/cuda/cudadecl.py +556 -0
  112. numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
  113. numba_cuda/numba/cuda/cudadrv/devicearray.py +951 -0
  114. numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
  115. numba_cuda/numba/cuda/cudadrv/driver.py +3222 -0
  116. numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
  117. numba_cuda/numba/cuda/cudadrv/dummyarray.py +558 -0
  118. numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
  119. numba_cuda/numba/cuda/cudadrv/error.py +48 -0
  120. numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
  121. numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
  122. numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
  123. numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
  124. numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
  125. numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
  126. numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
  127. numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
  128. numba_cuda/numba/cuda/cudaimpl.py +995 -0
  129. numba_cuda/numba/cuda/cudamath.py +149 -0
  130. numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
  131. numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
  132. numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
  133. numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
  134. numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
  135. numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
  136. numba_cuda/numba/cuda/datamodel/manager.py +11 -0
  137. numba_cuda/numba/cuda/datamodel/models.py +9 -0
  138. numba_cuda/numba/cuda/datamodel/packer.py +9 -0
  139. numba_cuda/numba/cuda/datamodel/registry.py +11 -0
  140. numba_cuda/numba/cuda/datamodel/testing.py +11 -0
  141. numba_cuda/numba/cuda/debuginfo.py +903 -0
  142. numba_cuda/numba/cuda/decorators.py +294 -0
  143. numba_cuda/numba/cuda/descriptor.py +35 -0
  144. numba_cuda/numba/cuda/device_init.py +158 -0
  145. numba_cuda/numba/cuda/deviceufunc.py +1021 -0
  146. numba_cuda/numba/cuda/dispatcher.py +2463 -0
  147. numba_cuda/numba/cuda/errors.py +72 -0
  148. numba_cuda/numba/cuda/extending.py +697 -0
  149. numba_cuda/numba/cuda/flags.py +178 -0
  150. numba_cuda/numba/cuda/fp16.py +357 -0
  151. numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
  152. numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
  153. numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
  154. numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
  155. numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
  156. numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
  157. numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
  158. numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
  159. numba_cuda/numba/cuda/initialize.py +24 -0
  160. numba_cuda/numba/cuda/intrinsic_wrapper.py +41 -0
  161. numba_cuda/numba/cuda/intrinsics.py +382 -0
  162. numba_cuda/numba/cuda/itanium_mangler.py +214 -0
  163. numba_cuda/numba/cuda/kernels/__init__.py +2 -0
  164. numba_cuda/numba/cuda/kernels/reduction.py +265 -0
  165. numba_cuda/numba/cuda/kernels/transpose.py +65 -0
  166. numba_cuda/numba/cuda/libdevice.py +3386 -0
  167. numba_cuda/numba/cuda/libdevicedecl.py +20 -0
  168. numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
  169. numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
  170. numba_cuda/numba/cuda/locks.py +19 -0
  171. numba_cuda/numba/cuda/lowering.py +1951 -0
  172. numba_cuda/numba/cuda/mathimpl.py +374 -0
  173. numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
  174. numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
  175. numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
  176. numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
  177. numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
  178. numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
  179. numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
  180. numba_cuda/numba/cuda/misc/appdirs.py +594 -0
  181. numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
  182. numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
  183. numba_cuda/numba/cuda/misc/dump_style.py +41 -0
  184. numba_cuda/numba/cuda/misc/findlib.py +75 -0
  185. numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
  186. numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
  187. numba_cuda/numba/cuda/misc/literal.py +28 -0
  188. numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
  189. numba_cuda/numba/cuda/misc/special.py +94 -0
  190. numba_cuda/numba/cuda/models.py +56 -0
  191. numba_cuda/numba/cuda/np/arraymath.py +5130 -0
  192. numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
  193. numba_cuda/numba/cuda/np/extensions.py +11 -0
  194. numba_cuda/numba/cuda/np/linalg.py +3087 -0
  195. numba_cuda/numba/cuda/np/math/__init__.py +0 -0
  196. numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
  197. numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
  198. numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
  199. numba_cuda/numba/cuda/np/npdatetime.py +969 -0
  200. numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
  201. numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
  202. numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
  203. numba_cuda/numba/cuda/np/numpy_support.py +798 -0
  204. numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
  205. numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
  206. numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
  207. numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
  208. numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
  209. numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
  210. numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
  211. numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
  212. numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
  213. numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
  214. numba_cuda/numba/cuda/nvvmutils.py +254 -0
  215. numba_cuda/numba/cuda/printimpl.py +126 -0
  216. numba_cuda/numba/cuda/random.py +308 -0
  217. numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
  218. numba_cuda/numba/cuda/serialize.py +267 -0
  219. numba_cuda/numba/cuda/simulator/__init__.py +63 -0
  220. numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
  221. numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
  222. numba_cuda/numba/cuda/simulator/api.py +179 -0
  223. numba_cuda/numba/cuda/simulator/bf16.py +4 -0
  224. numba_cuda/numba/cuda/simulator/compiler.py +38 -0
  225. numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
  226. numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
  227. numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
  228. numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
  229. numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
  230. numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
  231. numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
  232. numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
  233. numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
  234. numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
  235. numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
  236. numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
  237. numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
  238. numba_cuda/numba/cuda/simulator/kernel.py +320 -0
  239. numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
  240. numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
  241. numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
  242. numba_cuda/numba/cuda/simulator/reduction.py +19 -0
  243. numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
  244. numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
  245. numba_cuda/numba/cuda/simulator_init.py +18 -0
  246. numba_cuda/numba/cuda/stubs.py +635 -0
  247. numba_cuda/numba/cuda/target.py +505 -0
  248. numba_cuda/numba/cuda/testing.py +347 -0
  249. numba_cuda/numba/cuda/tests/__init__.py +62 -0
  250. numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
  251. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
  252. numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
  253. numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
  254. numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
  255. numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
  256. numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
  257. numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
  258. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
  259. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
  260. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
  261. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
  262. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
  263. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +187 -0
  264. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
  265. numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
  266. numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
  267. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +198 -0
  268. numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
  269. numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
  270. numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
  271. numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
  272. numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
  273. numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
  274. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
  275. numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
  276. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
  277. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
  278. numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
  279. numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
  280. numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
  281. numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
  282. numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
  283. numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
  284. numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
  285. numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
  286. numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
  287. numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
  288. numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
  289. numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
  290. numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
  291. numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
  292. numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
  293. numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
  294. numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
  295. numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
  296. numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
  297. numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
  298. numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
  299. numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
  300. numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
  301. numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
  302. numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
  303. numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
  304. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
  305. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
  306. numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
  307. numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
  308. numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
  309. numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
  310. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
  311. numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
  312. numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
  313. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
  314. numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
  315. numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
  316. numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
  317. numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
  318. numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
  319. numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
  320. numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
  321. numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
  322. numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
  323. numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
  324. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +889 -0
  325. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
  326. numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
  327. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
  328. numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
  329. numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
  330. numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
  331. numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
  332. numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
  333. numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
  334. numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
  335. numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
  336. numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
  337. numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
  338. numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
  339. numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
  340. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
  341. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
  342. numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
  343. numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
  344. numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
  345. numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
  346. numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
  347. numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
  348. numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
  349. numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
  350. numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
  351. numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
  352. numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
  353. numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
  354. numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
  355. numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
  356. numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
  357. numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
  358. numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
  359. numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
  360. numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
  361. numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
  362. numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
  363. numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
  364. numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
  365. numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
  366. numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
  367. numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
  368. numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
  369. numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
  370. numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
  371. numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
  372. numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
  373. numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
  374. numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
  375. numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
  376. numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
  377. numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
  378. numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
  379. numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
  380. numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
  381. numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
  382. numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
  383. numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
  384. numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
  385. numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
  386. numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
  387. numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
  388. numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
  389. numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
  390. numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
  391. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
  392. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
  393. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
  394. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
  395. numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
  396. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +331 -0
  397. numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
  398. numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
  399. numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
  400. numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
  401. numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
  402. numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
  403. numba_cuda/numba/cuda/tests/data/error.cu +12 -0
  404. numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
  405. numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
  406. numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
  407. numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
  408. numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
  409. numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
  410. numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
  411. numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
  412. numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
  413. numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
  414. numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
  415. numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
  416. numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
  417. numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
  418. numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
  419. numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
  420. numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
  421. numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
  422. numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
  423. numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
  424. numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
  425. numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
  426. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +391 -0
  427. numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
  428. numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
  429. numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
  430. numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
  431. numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
  432. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
  433. numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
  434. numba_cuda/numba/cuda/tests/support.py +900 -0
  435. numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
  436. numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
  437. numba_cuda/numba/cuda/typeconv/rules.py +63 -0
  438. numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
  439. numba_cuda/numba/cuda/types/__init__.py +233 -0
  440. numba_cuda/numba/cuda/types/__init__.pyi +167 -0
  441. numba_cuda/numba/cuda/types/abstract.py +9 -0
  442. numba_cuda/numba/cuda/types/common.py +9 -0
  443. numba_cuda/numba/cuda/types/containers.py +9 -0
  444. numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
  445. numba_cuda/numba/cuda/types/cuda_common.py +110 -0
  446. numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
  447. numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
  448. numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
  449. numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
  450. numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
  451. numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
  452. numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
  453. numba_cuda/numba/cuda/types/ext_types.py +101 -0
  454. numba_cuda/numba/cuda/types/function_type.py +11 -0
  455. numba_cuda/numba/cuda/types/functions.py +9 -0
  456. numba_cuda/numba/cuda/types/iterators.py +9 -0
  457. numba_cuda/numba/cuda/types/misc.py +9 -0
  458. numba_cuda/numba/cuda/types/npytypes.py +9 -0
  459. numba_cuda/numba/cuda/types/scalars.py +9 -0
  460. numba_cuda/numba/cuda/typing/__init__.py +19 -0
  461. numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
  462. numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
  463. numba_cuda/numba/cuda/typing/bufproto.py +70 -0
  464. numba_cuda/numba/cuda/typing/builtins.py +1209 -0
  465. numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
  466. numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
  467. numba_cuda/numba/cuda/typing/collections.py +138 -0
  468. numba_cuda/numba/cuda/typing/context.py +782 -0
  469. numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
  470. numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
  471. numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
  472. numba_cuda/numba/cuda/typing/listdecl.py +147 -0
  473. numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
  474. numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
  475. numba_cuda/numba/cuda/typing/npydecl.py +749 -0
  476. numba_cuda/numba/cuda/typing/setdecl.py +115 -0
  477. numba_cuda/numba/cuda/typing/templates.py +1446 -0
  478. numba_cuda/numba/cuda/typing/typeof.py +301 -0
  479. numba_cuda/numba/cuda/ufuncs.py +746 -0
  480. numba_cuda/numba/cuda/utils.py +724 -0
  481. numba_cuda/numba/cuda/vector_types.py +214 -0
  482. numba_cuda/numba/cuda/vectorizers.py +260 -0
  483. numba_cuda-0.21.1.dist-info/METADATA +109 -0
  484. numba_cuda-0.21.1.dist-info/RECORD +488 -0
  485. numba_cuda-0.21.1.dist-info/WHEEL +5 -0
  486. numba_cuda-0.21.1.dist-info/licenses/LICENSE +26 -0
  487. numba_cuda-0.21.1.dist-info/licenses/LICENSE.numba +24 -0
  488. numba_cuda-0.21.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,560 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ """
5
+ Implement the cmath module functions.
6
+ """
7
+
8
+ import cmath
9
+ import math
10
+
11
+ from numba.cuda.core.imputils import impl_ret_untracked, Registry
12
+ from numba.cuda import types
13
+ from numba.cuda.typing import signature
14
+ from numba.cuda.cpython import mathimpl
15
+ from numba.cuda.extending import overload
16
+
17
+
18
+ registry = Registry("cmathimpl")
19
+ lower = registry.lower
20
+
21
+
22
+ def is_nan(builder, z):
23
+ return builder.fcmp_unordered("uno", z.real, z.imag)
24
+
25
+
26
+ def is_inf(builder, z):
27
+ return builder.or_(
28
+ mathimpl.is_inf(builder, z.real), mathimpl.is_inf(builder, z.imag)
29
+ )
30
+
31
+
32
+ def is_finite(builder, z):
33
+ return builder.and_(
34
+ mathimpl.is_finite(builder, z.real), mathimpl.is_finite(builder, z.imag)
35
+ )
36
+
37
+
38
+ @lower(cmath.isnan, types.Complex)
39
+ def isnan_float_impl(context, builder, sig, args):
40
+ [typ] = sig.args
41
+ [value] = args
42
+ z = context.make_complex(builder, typ, value=value)
43
+ res = is_nan(builder, z)
44
+ return impl_ret_untracked(context, builder, sig.return_type, res)
45
+
46
+
47
+ @lower(cmath.isinf, types.Complex)
48
+ def isinf_float_impl(context, builder, sig, args):
49
+ [typ] = sig.args
50
+ [value] = args
51
+ z = context.make_complex(builder, typ, value=value)
52
+ res = is_inf(builder, z)
53
+ return impl_ret_untracked(context, builder, sig.return_type, res)
54
+
55
+
56
+ @lower(cmath.isfinite, types.Complex)
57
+ def isfinite_float_impl(context, builder, sig, args):
58
+ [typ] = sig.args
59
+ [value] = args
60
+ z = context.make_complex(builder, typ, value=value)
61
+ res = is_finite(builder, z)
62
+ return impl_ret_untracked(context, builder, sig.return_type, res)
63
+
64
+
65
+ @overload(cmath.rect)
66
+ def impl_cmath_rect(r, phi):
67
+ if all([isinstance(typ, types.Float) for typ in [r, phi]]):
68
+
69
+ def impl(r, phi):
70
+ if not math.isfinite(phi):
71
+ if not r:
72
+ # cmath.rect(0, phi={inf, nan}) = 0
73
+ return abs(r)
74
+ if math.isinf(r):
75
+ # cmath.rect(inf, phi={inf, nan}) = inf + j phi
76
+ return complex(r, phi)
77
+ real = math.cos(phi)
78
+ imag = math.sin(phi)
79
+ if real == 0.0 and math.isinf(r):
80
+ # 0 * inf would return NaN, we want to keep 0 but xor the sign
81
+ real /= r
82
+ else:
83
+ real *= r
84
+ if imag == 0.0 and math.isinf(r):
85
+ # ditto
86
+ imag /= r
87
+ else:
88
+ imag *= r
89
+ return complex(real, imag)
90
+
91
+ return impl
92
+
93
+
94
+ def intrinsic_complex_unary(inner_func):
95
+ def wrapper(context, builder, sig, args):
96
+ [typ] = sig.args
97
+ [value] = args
98
+ z = context.make_complex(builder, typ, value=value)
99
+ x = z.real
100
+ y = z.imag
101
+ # Same as above: math.isfinite() is unavailable on 2.x so we precompute
102
+ # its value and pass it to the pure Python implementation.
103
+ x_is_finite = mathimpl.is_finite(builder, x)
104
+ y_is_finite = mathimpl.is_finite(builder, y)
105
+ inner_sig = signature(
106
+ sig.return_type, *(typ.underlying_float,) * 2 + (types.boolean,) * 2
107
+ )
108
+ res = context.compile_internal(
109
+ builder, inner_func, inner_sig, (x, y, x_is_finite, y_is_finite)
110
+ )
111
+ return impl_ret_untracked(context, builder, sig, res)
112
+
113
+ return wrapper
114
+
115
+
116
+ NAN = float("nan")
117
+ INF = float("inf")
118
+
119
+
120
+ @lower(cmath.exp, types.Complex)
121
+ @intrinsic_complex_unary
122
+ def exp_impl(x, y, x_is_finite, y_is_finite):
123
+ """cmath.exp(x + y j)"""
124
+ if x_is_finite:
125
+ if y_is_finite:
126
+ c = math.cos(y)
127
+ s = math.sin(y)
128
+ r = math.exp(x)
129
+ return complex(r * c, r * s)
130
+ else:
131
+ return complex(NAN, NAN)
132
+ elif math.isnan(x):
133
+ if y:
134
+ return complex(x, x) # nan + j nan
135
+ else:
136
+ return complex(x, y) # nan + 0j
137
+ elif x > 0.0:
138
+ # x == +inf
139
+ if y_is_finite:
140
+ real = math.cos(y)
141
+ imag = math.sin(y)
142
+ # Avoid NaNs if math.cos(y) or math.sin(y) == 0
143
+ # (e.g. cmath.exp(inf + 0j) == inf + 0j)
144
+ if real != 0:
145
+ real *= x
146
+ if imag != 0:
147
+ imag *= x
148
+ return complex(real, imag)
149
+ else:
150
+ return complex(x, NAN)
151
+ else:
152
+ # x == -inf
153
+ if y_is_finite:
154
+ r = math.exp(x)
155
+ c = math.cos(y)
156
+ s = math.sin(y)
157
+ return complex(r * c, r * s)
158
+ else:
159
+ r = 0
160
+ return complex(r, r)
161
+
162
+
163
+ @lower(cmath.log, types.Complex)
164
+ @intrinsic_complex_unary
165
+ def log_impl(x, y, x_is_finite, y_is_finite):
166
+ """cmath.log(x + y j)"""
167
+ a = math.log(math.hypot(x, y))
168
+ b = math.atan2(y, x)
169
+ return complex(a, b)
170
+
171
+
172
+ @lower(cmath.log, types.Complex, types.Complex)
173
+ def log_base_impl(context, builder, sig, args):
174
+ """cmath.log(z, base)"""
175
+ [z, base] = args
176
+
177
+ def log_base(z, base):
178
+ return cmath.log(z) / cmath.log(base)
179
+
180
+ res = context.compile_internal(builder, log_base, sig, args)
181
+ return impl_ret_untracked(context, builder, sig, res)
182
+
183
+
184
+ @overload(cmath.log10)
185
+ def impl_cmath_log10(z):
186
+ if not isinstance(z, types.Complex):
187
+ return
188
+
189
+ LN_10 = 2.302585092994045684
190
+
191
+ def log10_impl(z):
192
+ """cmath.log10(z)"""
193
+ z = cmath.log(z)
194
+ # This formula gives better results on +/-inf than cmath.log(z, 10)
195
+ # See http://bugs.python.org/issue22544
196
+ return complex(z.real / LN_10, z.imag / LN_10)
197
+
198
+ return log10_impl
199
+
200
+
201
+ @overload(cmath.phase)
202
+ def phase_impl(x):
203
+ """cmath.phase(x + y j)"""
204
+
205
+ if not isinstance(x, types.Complex):
206
+ return
207
+
208
+ def impl(x):
209
+ return math.atan2(x.imag, x.real)
210
+
211
+ return impl
212
+
213
+
214
+ @overload(cmath.polar)
215
+ def polar_impl(x):
216
+ if not isinstance(x, types.Complex):
217
+ return
218
+
219
+ def impl(x):
220
+ r, i = x.real, x.imag
221
+ return math.hypot(r, i), math.atan2(i, r)
222
+
223
+ return impl
224
+
225
+
226
+ @lower(cmath.sqrt, types.Complex)
227
+ def sqrt_impl(context, builder, sig, args):
228
+ # We risk spurious overflow for components >= FLT_MAX / (1 + sqrt(2)).
229
+
230
+ SQRT2 = 1.414213562373095048801688724209698079e0
231
+ ONE_PLUS_SQRT2 = 1.0 + SQRT2
232
+ theargflt = sig.args[0].underlying_float
233
+ # Get a type specific maximum value so scaling for overflow is based on that
234
+ MAX = mathimpl.DBL_MAX if theargflt.bitwidth == 64 else mathimpl.FLT_MAX
235
+ # THRES will be double precision, should not impact typing as it's just
236
+ # used for comparison, there *may* be a few values near THRES which
237
+ # deviate from e.g. NumPy due to rounding that occurs in the computation
238
+ # of this value in the case of a 32bit argument.
239
+ THRES = MAX / ONE_PLUS_SQRT2
240
+
241
+ def sqrt_impl(z):
242
+ """cmath.sqrt(z)"""
243
+ # This is NumPy's algorithm, see npy_csqrt() in npy_math_complex.c.src
244
+ a = z.real
245
+ b = z.imag
246
+ if a == 0.0 and b == 0.0:
247
+ return complex(abs(b), b)
248
+ if math.isinf(b):
249
+ return complex(abs(b), b)
250
+ if math.isnan(a):
251
+ return complex(a, a)
252
+ if math.isinf(a):
253
+ if a < 0.0:
254
+ return complex(abs(b - b), math.copysign(a, b))
255
+ else:
256
+ return complex(a, math.copysign(b - b, b))
257
+
258
+ # The remaining special case (b is NaN) is handled just fine by
259
+ # the normal code path below.
260
+
261
+ # Scale to avoid overflow
262
+ if abs(a) >= THRES or abs(b) >= THRES:
263
+ a *= 0.25
264
+ b *= 0.25
265
+ scale = True
266
+ else:
267
+ scale = False
268
+ # Algorithm 312, CACM vol 10, Oct 1967
269
+ if a >= 0:
270
+ t = math.sqrt((a + math.hypot(a, b)) * 0.5)
271
+ real = t
272
+ imag = b / (2 * t)
273
+ else:
274
+ t = math.sqrt((-a + math.hypot(a, b)) * 0.5)
275
+ real = abs(b) / (2 * t)
276
+ imag = math.copysign(t, b)
277
+ # Rescale
278
+ if scale:
279
+ return complex(real * 2, imag)
280
+ else:
281
+ return complex(real, imag)
282
+
283
+ res = context.compile_internal(builder, sqrt_impl, sig, args)
284
+ return impl_ret_untracked(context, builder, sig, res)
285
+
286
+
287
+ @lower(cmath.cos, types.Complex)
288
+ def cos_impl(context, builder, sig, args):
289
+ def cos_impl(z):
290
+ """cmath.cos(z) = cmath.cosh(z j)"""
291
+ return cmath.cosh(complex(-z.imag, z.real))
292
+
293
+ res = context.compile_internal(builder, cos_impl, sig, args)
294
+ return impl_ret_untracked(context, builder, sig, res)
295
+
296
+
297
+ @overload(cmath.cosh)
298
+ def impl_cmath_cosh(z):
299
+ if not isinstance(z, types.Complex):
300
+ return
301
+
302
+ def cosh_impl(z):
303
+ """cmath.cosh(z)"""
304
+ x = z.real
305
+ y = z.imag
306
+ if math.isinf(x):
307
+ if math.isnan(y):
308
+ # x = +inf, y = NaN => cmath.cosh(x + y j) = inf + Nan * j
309
+ real = abs(x)
310
+ imag = y
311
+ elif y == 0.0:
312
+ # x = +inf, y = 0 => cmath.cosh(x + y j) = inf + 0j
313
+ real = abs(x)
314
+ imag = y
315
+ else:
316
+ real = math.copysign(x, math.cos(y))
317
+ imag = math.copysign(x, math.sin(y))
318
+ if x < 0.0:
319
+ # x = -inf => negate imaginary part of result
320
+ imag = -imag
321
+ return complex(real, imag)
322
+ return complex(math.cos(y) * math.cosh(x), math.sin(y) * math.sinh(x))
323
+
324
+ return cosh_impl
325
+
326
+
327
+ @lower(cmath.sin, types.Complex)
328
+ def sin_impl(context, builder, sig, args):
329
+ def sin_impl(z):
330
+ """cmath.sin(z) = -j * cmath.sinh(z j)"""
331
+ r = cmath.sinh(complex(-z.imag, z.real))
332
+ return complex(r.imag, -r.real)
333
+
334
+ res = context.compile_internal(builder, sin_impl, sig, args)
335
+ return impl_ret_untracked(context, builder, sig, res)
336
+
337
+
338
+ @overload(cmath.sinh)
339
+ def impl_cmath_sinh(z):
340
+ if not isinstance(z, types.Complex):
341
+ return
342
+
343
+ def sinh_impl(z):
344
+ """cmath.sinh(z)"""
345
+ x = z.real
346
+ y = z.imag
347
+ if math.isinf(x):
348
+ if math.isnan(y):
349
+ # x = +/-inf, y = NaN => cmath.sinh(x + y j) = x + NaN * j
350
+ real = x
351
+ imag = y
352
+ else:
353
+ real = math.cos(y)
354
+ imag = math.sin(y)
355
+ if real != 0.0:
356
+ real *= x
357
+ if imag != 0.0:
358
+ imag *= abs(x)
359
+ return complex(real, imag)
360
+ return complex(math.cos(y) * math.sinh(x), math.sin(y) * math.cosh(x))
361
+
362
+ return sinh_impl
363
+
364
+
365
+ @lower(cmath.tan, types.Complex)
366
+ def tan_impl(context, builder, sig, args):
367
+ def tan_impl(z):
368
+ """cmath.tan(z) = -j * cmath.tanh(z j)"""
369
+ r = cmath.tanh(complex(-z.imag, z.real))
370
+ return complex(r.imag, -r.real)
371
+
372
+ res = context.compile_internal(builder, tan_impl, sig, args)
373
+ return impl_ret_untracked(context, builder, sig, res)
374
+
375
+
376
+ @overload(cmath.tanh)
377
+ def impl_cmath_tanh(z):
378
+ if not isinstance(z, types.Complex):
379
+ return
380
+
381
+ def tanh_impl(z):
382
+ """cmath.tanh(z)"""
383
+ x = z.real
384
+ y = z.imag
385
+ if math.isinf(x):
386
+ real = math.copysign(1.0, x)
387
+ if math.isinf(y):
388
+ imag = 0.0
389
+ else:
390
+ imag = math.copysign(0.0, math.sin(2.0 * y))
391
+ return complex(real, imag)
392
+ # This is CPython's algorithm (see c_tanh() in cmathmodule.c).
393
+ # XXX how to force float constants into single precision?
394
+ tx = math.tanh(x)
395
+ ty = math.tan(y)
396
+ cx = 1.0 / math.cosh(x)
397
+ txty = tx * ty
398
+ denom = 1.0 + txty * txty
399
+ return complex(tx * (1.0 + ty * ty) / denom, ((ty / denom) * cx) * cx)
400
+
401
+ return tanh_impl
402
+
403
+
404
+ @lower(cmath.acos, types.Complex)
405
+ def acos_impl(context, builder, sig, args):
406
+ LN_4 = math.log(4)
407
+ THRES = mathimpl.FLT_MAX / 4
408
+
409
+ def acos_impl(z):
410
+ """cmath.acos(z)"""
411
+ # CPython's algorithm (see c_acos() in cmathmodule.c)
412
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
413
+ # Avoid unnecessary overflow for large arguments
414
+ # (also handles infinities gracefully)
415
+ real = math.atan2(abs(z.imag), z.real)
416
+ imag = math.copysign(
417
+ math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, -z.imag
418
+ )
419
+ return complex(real, imag)
420
+ else:
421
+ s1 = cmath.sqrt(complex(1.0 - z.real, -z.imag))
422
+ s2 = cmath.sqrt(complex(1.0 + z.real, z.imag))
423
+ real = 2.0 * math.atan2(s1.real, s2.real)
424
+ imag = math.asinh(s2.real * s1.imag - s2.imag * s1.real)
425
+ return complex(real, imag)
426
+
427
+ res = context.compile_internal(builder, acos_impl, sig, args)
428
+ return impl_ret_untracked(context, builder, sig, res)
429
+
430
+
431
+ @overload(cmath.acosh)
432
+ def impl_cmath_acosh(z):
433
+ if not isinstance(z, types.Complex):
434
+ return
435
+
436
+ LN_4 = math.log(4)
437
+ THRES = mathimpl.FLT_MAX / 4
438
+
439
+ def acosh_impl(z):
440
+ """cmath.acosh(z)"""
441
+ # CPython's algorithm (see c_acosh() in cmathmodule.c)
442
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
443
+ # Avoid unnecessary overflow for large arguments
444
+ # (also handles infinities gracefully)
445
+ real = math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4
446
+ imag = math.atan2(z.imag, z.real)
447
+ return complex(real, imag)
448
+ else:
449
+ s1 = cmath.sqrt(complex(z.real - 1.0, z.imag))
450
+ s2 = cmath.sqrt(complex(z.real + 1.0, z.imag))
451
+ real = math.asinh(s1.real * s2.real + s1.imag * s2.imag)
452
+ imag = 2.0 * math.atan2(s1.imag, s2.real)
453
+ return complex(real, imag)
454
+ # Condensed formula (NumPy)
455
+ # return cmath.log(z + cmath.sqrt(z + 1.) * cmath.sqrt(z - 1.))
456
+
457
+ return acosh_impl
458
+
459
+
460
+ @lower(cmath.asinh, types.Complex)
461
+ def asinh_impl(context, builder, sig, args):
462
+ LN_4 = math.log(4)
463
+ THRES = mathimpl.FLT_MAX / 4
464
+
465
+ def asinh_impl(z):
466
+ """cmath.asinh(z)"""
467
+ # CPython's algorithm (see c_asinh() in cmathmodule.c)
468
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
469
+ real = math.copysign(
470
+ math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, z.real
471
+ )
472
+ imag = math.atan2(z.imag, abs(z.real))
473
+ return complex(real, imag)
474
+ else:
475
+ s1 = cmath.sqrt(complex(1.0 + z.imag, -z.real))
476
+ s2 = cmath.sqrt(complex(1.0 - z.imag, z.real))
477
+ real = math.asinh(s1.real * s2.imag - s2.real * s1.imag)
478
+ imag = math.atan2(z.imag, s1.real * s2.real - s1.imag * s2.imag)
479
+ return complex(real, imag)
480
+
481
+ res = context.compile_internal(builder, asinh_impl, sig, args)
482
+ return impl_ret_untracked(context, builder, sig, res)
483
+
484
+
485
+ @lower(cmath.asin, types.Complex)
486
+ def asin_impl(context, builder, sig, args):
487
+ def asin_impl(z):
488
+ """cmath.asin(z) = -j * cmath.asinh(z j)"""
489
+ r = cmath.asinh(complex(-z.imag, z.real))
490
+ return complex(r.imag, -r.real)
491
+
492
+ res = context.compile_internal(builder, asin_impl, sig, args)
493
+ return impl_ret_untracked(context, builder, sig, res)
494
+
495
+
496
+ @lower(cmath.atan, types.Complex)
497
+ def atan_impl(context, builder, sig, args):
498
+ def atan_impl(z):
499
+ """cmath.atan(z) = -j * cmath.atanh(z j)"""
500
+ r = cmath.atanh(complex(-z.imag, z.real))
501
+ if math.isinf(z.real) and math.isnan(z.imag):
502
+ # XXX this is odd but necessary
503
+ return complex(r.imag, r.real)
504
+ else:
505
+ return complex(r.imag, -r.real)
506
+
507
+ res = context.compile_internal(builder, atan_impl, sig, args)
508
+ return impl_ret_untracked(context, builder, sig, res)
509
+
510
+
511
+ @lower(cmath.atanh, types.Complex)
512
+ def atanh_impl(context, builder, sig, args):
513
+ THRES_LARGE = math.sqrt(mathimpl.FLT_MAX / 4)
514
+ THRES_SMALL = math.sqrt(mathimpl.FLT_MIN)
515
+ PI_12 = math.pi / 2
516
+
517
+ def atanh_impl(z):
518
+ """cmath.atanh(z)"""
519
+ # CPython's algorithm (see c_atanh() in cmathmodule.c)
520
+ if z.real < 0.0:
521
+ # Reduce to case where z.real >= 0., using atanh(z) = -atanh(-z).
522
+ negate = True
523
+ z = -z
524
+ else:
525
+ negate = False
526
+
527
+ ay = abs(z.imag)
528
+ if math.isnan(z.real) or z.real > THRES_LARGE or ay > THRES_LARGE:
529
+ if math.isinf(z.imag):
530
+ real = math.copysign(0.0, z.real)
531
+ elif math.isinf(z.real):
532
+ real = 0.0
533
+ else:
534
+ # may be safe from overflow, depending on hypot's implementation...
535
+ h = math.hypot(z.real * 0.5, z.imag * 0.5)
536
+ real = z.real / 4.0 / h / h
537
+ imag = -math.copysign(PI_12, -z.imag)
538
+ elif z.real == 1.0 and ay < THRES_SMALL:
539
+ # C99 standard says: atanh(1+/-0.) should be inf +/- 0j
540
+ if ay == 0.0:
541
+ real = INF
542
+ imag = z.imag
543
+ else:
544
+ real = -math.log(math.sqrt(ay) / math.sqrt(math.hypot(ay, 2.0)))
545
+ imag = math.copysign(math.atan2(2.0, -ay) / 2, z.imag)
546
+ else:
547
+ sqay = ay * ay
548
+ zr1 = 1 - z.real
549
+ real = math.log1p(4.0 * z.real / (zr1 * zr1 + sqay)) * 0.25
550
+ imag = -math.atan2(-2.0 * z.imag, zr1 * (1 + z.real) - sqay) * 0.5
551
+
552
+ if math.isnan(z.imag):
553
+ imag = NAN
554
+ if negate:
555
+ return complex(-real, -imag)
556
+ else:
557
+ return complex(real, imag)
558
+
559
+ res = context.compile_internal(builder, atanh_impl, sig, args)
560
+ return impl_ret_untracked(context, builder, sig, res)
@@ -0,0 +1,103 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ """
5
+ Implementation of enums.
6
+ """
7
+
8
+ import operator
9
+
10
+ from numba.cuda.core.imputils import Registry, impl_ret_untracked
11
+ from numba.cuda import types
12
+ from numba.cuda.extending import overload_method
13
+
14
+ registry = Registry("enumimpl")
15
+ lower = registry.lower
16
+ lower_getattr = registry.lower_getattr
17
+ lower_getattr_generic = registry.lower_getattr_generic
18
+ lower_cast = registry.lower_cast
19
+ lower_constant = registry.lower_constant
20
+
21
+
22
+ @lower(operator.eq, types.EnumMember, types.EnumMember)
23
+ def enum_eq(context, builder, sig, args):
24
+ tu, tv = sig.args
25
+ u, v = args
26
+ res = context.generic_compare(
27
+ builder, operator.eq, (tu.dtype, tv.dtype), (u, v)
28
+ )
29
+ return impl_ret_untracked(context, builder, sig.return_type, res)
30
+
31
+
32
+ @lower(operator.is_, types.EnumMember, types.EnumMember)
33
+ def enum_is(context, builder, sig, args):
34
+ tu, tv = sig.args
35
+ u, v = args
36
+ if tu == tv:
37
+ res = context.generic_compare(
38
+ builder, operator.eq, (tu.dtype, tv.dtype), (u, v)
39
+ )
40
+ else:
41
+ res = context.get_constant(sig.return_type, False)
42
+ return impl_ret_untracked(context, builder, sig.return_type, res)
43
+
44
+
45
+ @lower(operator.ne, types.EnumMember, types.EnumMember)
46
+ def enum_ne(context, builder, sig, args):
47
+ tu, tv = sig.args
48
+ u, v = args
49
+ res = context.generic_compare(
50
+ builder, operator.ne, (tu.dtype, tv.dtype), (u, v)
51
+ )
52
+ return impl_ret_untracked(context, builder, sig.return_type, res)
53
+
54
+
55
+ @lower_getattr(types.EnumMember, "value")
56
+ def enum_value(context, builder, ty, val):
57
+ return val
58
+
59
+
60
+ @lower_cast(types.IntEnumMember, types.Integer)
61
+ def int_enum_to_int(context, builder, fromty, toty, val):
62
+ """
63
+ Convert an IntEnum member to its raw integer value.
64
+ """
65
+ return context.cast(builder, val, fromty.dtype, toty)
66
+
67
+
68
+ @lower_constant(types.EnumMember)
69
+ def enum_constant(context, builder, ty, pyval):
70
+ """
71
+ Return a LLVM constant representing enum member *pyval*.
72
+ """
73
+ return context.get_constant_generic(builder, ty.dtype, pyval.value)
74
+
75
+
76
+ @lower_getattr_generic(types.EnumClass)
77
+ def enum_class_getattr(context, builder, ty, val, attr):
78
+ """
79
+ Return an enum member by attribute name.
80
+ """
81
+ member = getattr(ty.instance_class, attr)
82
+ return context.get_constant_generic(builder, ty.dtype, member.value)
83
+
84
+
85
+ @lower("static_getitem", types.EnumClass, types.StringLiteral)
86
+ def enum_class_getitem(context, builder, sig, args):
87
+ """
88
+ Return an enum member by index name.
89
+ """
90
+ enum_cls_typ, idx = sig.args
91
+ member = enum_cls_typ.instance_class[idx.literal_value]
92
+ return context.get_constant_generic(
93
+ builder, enum_cls_typ.dtype, member.value
94
+ )
95
+
96
+
97
+ @overload_method(types.IntEnumMember, "__hash__")
98
+ def intenum_hash(val):
99
+ # uses the hash of the value, for IntEnums this will be int.__hash__
100
+ def hash_impl(val):
101
+ return hash(val.value)
102
+
103
+ return hash_impl