numba-cuda 0.22.0__cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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 numba-cuda might be problematic. Click here for more details.
- _numba_cuda_redirector.pth +4 -0
- _numba_cuda_redirector.py +89 -0
- numba_cuda/VERSION +1 -0
- numba_cuda/__init__.py +6 -0
- numba_cuda/_version.py +11 -0
- numba_cuda/numba/cuda/__init__.py +70 -0
- numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
- numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
- numba_cuda/numba/cuda/api.py +580 -0
- numba_cuda/numba/cuda/api_util.py +76 -0
- numba_cuda/numba/cuda/args.py +72 -0
- numba_cuda/numba/cuda/bf16.py +397 -0
- numba_cuda/numba/cuda/cache_hints.py +287 -0
- numba_cuda/numba/cuda/cext/__init__.py +2 -0
- numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
- numba_cuda/numba/cuda/cext/_devicearray.cpython-312-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cpython-312-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
- numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
- numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
- numba_cuda/numba/cuda/cext/_helperlib.cpython-312-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
- numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
- numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
- numba_cuda/numba/cuda/cext/_typeconv.cpython-312-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
- numba_cuda/numba/cuda/cext/_typeof.h +19 -0
- numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
- numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
- numba_cuda/numba/cuda/cext/mviewbuf.cpython-312-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
- numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
- numba_cuda/numba/cuda/cg.py +67 -0
- numba_cuda/numba/cuda/cgutils.py +1294 -0
- numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
- numba_cuda/numba/cuda/codegen.py +541 -0
- numba_cuda/numba/cuda/compiler.py +1396 -0
- numba_cuda/numba/cuda/core/analysis.py +758 -0
- numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
- numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
- numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
- numba_cuda/numba/cuda/core/base.py +1332 -0
- numba_cuda/numba/cuda/core/boxing.py +1411 -0
- numba_cuda/numba/cuda/core/bytecode.py +728 -0
- numba_cuda/numba/cuda/core/byteflow.py +2346 -0
- numba_cuda/numba/cuda/core/caching.py +744 -0
- numba_cuda/numba/cuda/core/callconv.py +392 -0
- numba_cuda/numba/cuda/core/codegen.py +171 -0
- numba_cuda/numba/cuda/core/compiler.py +199 -0
- numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
- numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
- numba_cuda/numba/cuda/core/config.py +650 -0
- numba_cuda/numba/cuda/core/consts.py +124 -0
- numba_cuda/numba/cuda/core/controlflow.py +989 -0
- numba_cuda/numba/cuda/core/entrypoints.py +57 -0
- numba_cuda/numba/cuda/core/environment.py +66 -0
- numba_cuda/numba/cuda/core/errors.py +917 -0
- numba_cuda/numba/cuda/core/event.py +511 -0
- numba_cuda/numba/cuda/core/funcdesc.py +330 -0
- numba_cuda/numba/cuda/core/generators.py +387 -0
- numba_cuda/numba/cuda/core/imputils.py +509 -0
- numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
- numba_cuda/numba/cuda/core/interpreter.py +3617 -0
- numba_cuda/numba/cuda/core/ir.py +1812 -0
- numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
- numba_cuda/numba/cuda/core/optional.py +129 -0
- numba_cuda/numba/cuda/core/options.py +262 -0
- numba_cuda/numba/cuda/core/postproc.py +249 -0
- numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
- numba_cuda/numba/cuda/core/registry.py +46 -0
- numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
- numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
- numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
- numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
- numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
- numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
- numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
- numba_cuda/numba/cuda/core/sigutils.py +68 -0
- numba_cuda/numba/cuda/core/ssa.py +498 -0
- numba_cuda/numba/cuda/core/targetconfig.py +330 -0
- numba_cuda/numba/cuda/core/tracing.py +231 -0
- numba_cuda/numba/cuda/core/transforms.py +956 -0
- numba_cuda/numba/cuda/core/typed_passes.py +867 -0
- numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
- numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
- numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
- numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
- numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
- numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
- numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
- numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
- numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
- numba_cuda/numba/cuda/cpython/iterators.py +167 -0
- numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
- numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
- numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
- numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
- numba_cuda/numba/cuda/cpython/slicing.py +322 -0
- numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
- numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
- numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
- numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
- numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
- numba_cuda/numba/cuda/cuda_paths.py +691 -0
- numba_cuda/numba/cuda/cudadecl.py +543 -0
- numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
- numba_cuda/numba/cuda/cudadrv/devicearray.py +954 -0
- numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
- numba_cuda/numba/cuda/cudadrv/driver.py +3238 -0
- numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
- numba_cuda/numba/cuda/cudadrv/dummyarray.py +562 -0
- numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
- numba_cuda/numba/cuda/cudadrv/error.py +48 -0
- numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
- numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
- numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
- numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
- numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
- numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
- numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
- numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
- numba_cuda/numba/cuda/cudaimpl.py +983 -0
- numba_cuda/numba/cuda/cudamath.py +149 -0
- numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
- numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
- numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
- numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
- numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
- numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
- numba_cuda/numba/cuda/datamodel/manager.py +11 -0
- numba_cuda/numba/cuda/datamodel/models.py +9 -0
- numba_cuda/numba/cuda/datamodel/packer.py +9 -0
- numba_cuda/numba/cuda/datamodel/registry.py +11 -0
- numba_cuda/numba/cuda/datamodel/testing.py +11 -0
- numba_cuda/numba/cuda/debuginfo.py +997 -0
- numba_cuda/numba/cuda/decorators.py +294 -0
- numba_cuda/numba/cuda/descriptor.py +35 -0
- numba_cuda/numba/cuda/device_init.py +155 -0
- numba_cuda/numba/cuda/deviceufunc.py +1021 -0
- numba_cuda/numba/cuda/dispatcher.py +2463 -0
- numba_cuda/numba/cuda/errors.py +72 -0
- numba_cuda/numba/cuda/extending.py +697 -0
- numba_cuda/numba/cuda/flags.py +178 -0
- numba_cuda/numba/cuda/fp16.py +357 -0
- numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
- numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
- numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
- numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
- numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
- numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
- numba_cuda/numba/cuda/initialize.py +24 -0
- numba_cuda/numba/cuda/intrinsics.py +531 -0
- numba_cuda/numba/cuda/itanium_mangler.py +214 -0
- numba_cuda/numba/cuda/kernels/__init__.py +2 -0
- numba_cuda/numba/cuda/kernels/reduction.py +265 -0
- numba_cuda/numba/cuda/kernels/transpose.py +65 -0
- numba_cuda/numba/cuda/libdevice.py +3386 -0
- numba_cuda/numba/cuda/libdevicedecl.py +20 -0
- numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
- numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
- numba_cuda/numba/cuda/locks.py +19 -0
- numba_cuda/numba/cuda/lowering.py +1980 -0
- numba_cuda/numba/cuda/mathimpl.py +374 -0
- numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
- numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
- numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
- numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
- numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
- numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
- numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
- numba_cuda/numba/cuda/misc/appdirs.py +594 -0
- numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
- numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
- numba_cuda/numba/cuda/misc/dump_style.py +41 -0
- numba_cuda/numba/cuda/misc/findlib.py +75 -0
- numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
- numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
- numba_cuda/numba/cuda/misc/literal.py +28 -0
- numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
- numba_cuda/numba/cuda/misc/special.py +94 -0
- numba_cuda/numba/cuda/models.py +56 -0
- numba_cuda/numba/cuda/np/arraymath.py +5130 -0
- numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
- numba_cuda/numba/cuda/np/extensions.py +11 -0
- numba_cuda/numba/cuda/np/linalg.py +3087 -0
- numba_cuda/numba/cuda/np/math/__init__.py +0 -0
- numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
- numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
- numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
- numba_cuda/numba/cuda/np/npdatetime.py +969 -0
- numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
- numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
- numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
- numba_cuda/numba/cuda/np/numpy_support.py +798 -0
- numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
- numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
- numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
- numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
- numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
- numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
- numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
- numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
- numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
- numba_cuda/numba/cuda/nvvmutils.py +254 -0
- numba_cuda/numba/cuda/printimpl.py +126 -0
- numba_cuda/numba/cuda/random.py +308 -0
- numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
- numba_cuda/numba/cuda/serialize.py +267 -0
- numba_cuda/numba/cuda/simulator/__init__.py +63 -0
- numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
- numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
- numba_cuda/numba/cuda/simulator/api.py +179 -0
- numba_cuda/numba/cuda/simulator/bf16.py +4 -0
- numba_cuda/numba/cuda/simulator/compiler.py +38 -0
- numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
- numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
- numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
- numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
- numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
- numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
- numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
- numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
- numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
- numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
- numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
- numba_cuda/numba/cuda/simulator/kernel.py +320 -0
- numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
- numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
- numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
- numba_cuda/numba/cuda/simulator/reduction.py +19 -0
- numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
- numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
- numba_cuda/numba/cuda/simulator_init.py +18 -0
- numba_cuda/numba/cuda/stubs.py +624 -0
- numba_cuda/numba/cuda/target.py +505 -0
- numba_cuda/numba/cuda/testing.py +347 -0
- numba_cuda/numba/cuda/tests/__init__.py +62 -0
- numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
- numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
- numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
- numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
- numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
- numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
- numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +191 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +200 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
- numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
- numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
- numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
- numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
- numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
- numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
- numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
- numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
- numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
- numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
- numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
- numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
- numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
- numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
- numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
- numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
- numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
- numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
- numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
- numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
- numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +978 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
- numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
- numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
- numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
- numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
- numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
- numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
- numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
- numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
- numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
- numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
- numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
- numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
- numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
- numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
- numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
- numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
- numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
- numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
- numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
- numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
- numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
- numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
- numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
- numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
- numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
- numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
- numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
- numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
- numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
- numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
- numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
- numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
- numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
- numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
- numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
- numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
- numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
- numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
- numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
- numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
- numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
- numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
- numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
- numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
- numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
- numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +446 -0
- numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
- numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
- numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
- numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
- numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
- numba_cuda/numba/cuda/tests/data/error.cu +12 -0
- numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
- numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
- numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
- numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
- numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
- numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +452 -0
- numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
- numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
- numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
- numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
- numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
- numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
- numba_cuda/numba/cuda/tests/support.py +900 -0
- numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
- numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
- numba_cuda/numba/cuda/typeconv/rules.py +63 -0
- numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
- numba_cuda/numba/cuda/types/__init__.py +233 -0
- numba_cuda/numba/cuda/types/__init__.pyi +167 -0
- numba_cuda/numba/cuda/types/abstract.py +9 -0
- numba_cuda/numba/cuda/types/common.py +9 -0
- numba_cuda/numba/cuda/types/containers.py +9 -0
- numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
- numba_cuda/numba/cuda/types/cuda_common.py +110 -0
- numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
- numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
- numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
- numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
- numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
- numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
- numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
- numba_cuda/numba/cuda/types/ext_types.py +101 -0
- numba_cuda/numba/cuda/types/function_type.py +11 -0
- numba_cuda/numba/cuda/types/functions.py +9 -0
- numba_cuda/numba/cuda/types/iterators.py +9 -0
- numba_cuda/numba/cuda/types/misc.py +9 -0
- numba_cuda/numba/cuda/types/npytypes.py +9 -0
- numba_cuda/numba/cuda/types/scalars.py +9 -0
- numba_cuda/numba/cuda/typing/__init__.py +19 -0
- numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
- numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
- numba_cuda/numba/cuda/typing/bufproto.py +70 -0
- numba_cuda/numba/cuda/typing/builtins.py +1209 -0
- numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
- numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
- numba_cuda/numba/cuda/typing/collections.py +138 -0
- numba_cuda/numba/cuda/typing/context.py +782 -0
- numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
- numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
- numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
- numba_cuda/numba/cuda/typing/listdecl.py +147 -0
- numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
- numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
- numba_cuda/numba/cuda/typing/npydecl.py +749 -0
- numba_cuda/numba/cuda/typing/setdecl.py +115 -0
- numba_cuda/numba/cuda/typing/templates.py +1446 -0
- numba_cuda/numba/cuda/typing/typeof.py +301 -0
- numba_cuda/numba/cuda/ufuncs.py +746 -0
- numba_cuda/numba/cuda/utils.py +724 -0
- numba_cuda/numba/cuda/vector_types.py +214 -0
- numba_cuda/numba/cuda/vectorizers.py +260 -0
- numba_cuda-0.22.0.dist-info/METADATA +109 -0
- numba_cuda-0.22.0.dist-info/RECORD +487 -0
- numba_cuda-0.22.0.dist-info/WHEEL +6 -0
- numba_cuda-0.22.0.dist-info/licenses/LICENSE +26 -0
- numba_cuda-0.22.0.dist-info/licenses/LICENSE.numba +24 -0
- numba_cuda-0.22.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
import collections
|
|
5
|
+
import warnings
|
|
6
|
+
from functools import cached_property
|
|
7
|
+
|
|
8
|
+
from llvmlite import ir
|
|
9
|
+
|
|
10
|
+
from .abstract import DTypeSpec, IteratorType, MutableSequence, Number, Type
|
|
11
|
+
from .common import Buffer, Opaque, SimpleIteratorType
|
|
12
|
+
from numba.cuda.typeconv import Conversion
|
|
13
|
+
from .misc import UnicodeType
|
|
14
|
+
from .containers import Bytes
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CharSeq(Type):
|
|
19
|
+
"""
|
|
20
|
+
A fixed-length 8-bit character sequence.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
mutable = True
|
|
24
|
+
|
|
25
|
+
def __init__(self, count):
|
|
26
|
+
self.count = count
|
|
27
|
+
name = "[char x %d]" % count
|
|
28
|
+
super(CharSeq, self).__init__(name)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def key(self):
|
|
32
|
+
return self.count
|
|
33
|
+
|
|
34
|
+
def can_convert_from(self, typingctx, other):
|
|
35
|
+
if isinstance(other, Bytes):
|
|
36
|
+
return Conversion.safe
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class UnicodeCharSeq(Type):
|
|
40
|
+
"""
|
|
41
|
+
A fixed-length unicode character sequence.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
mutable = True
|
|
45
|
+
|
|
46
|
+
def __init__(self, count):
|
|
47
|
+
self.count = count
|
|
48
|
+
name = "[unichr x %d]" % count
|
|
49
|
+
super(UnicodeCharSeq, self).__init__(name)
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def key(self):
|
|
53
|
+
return self.count
|
|
54
|
+
|
|
55
|
+
def can_convert_to(self, typingctx, other):
|
|
56
|
+
if isinstance(other, UnicodeCharSeq):
|
|
57
|
+
return Conversion.safe
|
|
58
|
+
|
|
59
|
+
def can_convert_from(self, typingctx, other):
|
|
60
|
+
if isinstance(other, UnicodeType):
|
|
61
|
+
# Assuming that unicode_type itemsize is not greater than
|
|
62
|
+
# numpy.dtype('U1').itemsize that UnicodeCharSeq is based
|
|
63
|
+
# on.
|
|
64
|
+
return Conversion.safe
|
|
65
|
+
|
|
66
|
+
def __repr__(self):
|
|
67
|
+
return f"UnicodeCharSeq({self.count})"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
_RecordField = collections.namedtuple(
|
|
71
|
+
"_RecordField",
|
|
72
|
+
"type,offset,alignment,title",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Record(Type):
|
|
77
|
+
"""
|
|
78
|
+
A Record datatype can be mapped to a NumPy structured dtype.
|
|
79
|
+
A record is very flexible since it is laid out as a list of bytes.
|
|
80
|
+
Fields can be mapped to arbitrary points inside it, even if they overlap.
|
|
81
|
+
|
|
82
|
+
*fields* is a list of `(name:str, data:dict)`.
|
|
83
|
+
Where `data` is `{ type: Type, offset: int }`
|
|
84
|
+
*size* is an int; the record size
|
|
85
|
+
*aligned* is a boolean; whether the record is ABI aligned.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
mutable = True
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def make_c_struct(cls, name_types):
|
|
92
|
+
"""Construct a Record type from a list of (name:str, type:Types).
|
|
93
|
+
The layout of the structure will follow C.
|
|
94
|
+
|
|
95
|
+
Note: only scalar types are supported currently.
|
|
96
|
+
"""
|
|
97
|
+
from numba.cuda.core.registry import cpu_target
|
|
98
|
+
|
|
99
|
+
ctx = cpu_target.target_context
|
|
100
|
+
offset = 0
|
|
101
|
+
fields = []
|
|
102
|
+
lltypes = []
|
|
103
|
+
for k, ty in name_types:
|
|
104
|
+
if not isinstance(ty, (Number, NestedArray)):
|
|
105
|
+
msg = "Only Number and NestedArray types are supported, found: {}. "
|
|
106
|
+
raise TypeError(msg.format(ty))
|
|
107
|
+
if isinstance(ty, NestedArray):
|
|
108
|
+
datatype = ctx.data_model_manager[ty].as_storage_type()
|
|
109
|
+
else:
|
|
110
|
+
datatype = ctx.get_data_type(ty)
|
|
111
|
+
lltypes.append(datatype)
|
|
112
|
+
size = ctx.get_abi_sizeof(datatype)
|
|
113
|
+
align = ctx.get_abi_alignment(datatype)
|
|
114
|
+
# align
|
|
115
|
+
misaligned = offset % align
|
|
116
|
+
if misaligned:
|
|
117
|
+
offset += align - misaligned
|
|
118
|
+
fields.append(
|
|
119
|
+
(
|
|
120
|
+
k,
|
|
121
|
+
{
|
|
122
|
+
"type": ty,
|
|
123
|
+
"offset": offset,
|
|
124
|
+
"alignment": align,
|
|
125
|
+
},
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
offset += size
|
|
129
|
+
# Adjust sizeof structure
|
|
130
|
+
abi_size = ctx.get_abi_sizeof(ir.LiteralStructType(lltypes))
|
|
131
|
+
return Record(fields, size=abi_size, aligned=True)
|
|
132
|
+
|
|
133
|
+
def __init__(self, fields, size, aligned):
|
|
134
|
+
fields = self._normalize_fields(fields)
|
|
135
|
+
self.fields = dict(fields)
|
|
136
|
+
self.size = size
|
|
137
|
+
self.aligned = aligned
|
|
138
|
+
|
|
139
|
+
# Create description
|
|
140
|
+
descbuf = []
|
|
141
|
+
fmt = "{}[type={};offset={}{}]"
|
|
142
|
+
for k, infos in fields:
|
|
143
|
+
extra = ""
|
|
144
|
+
if infos.alignment is not None:
|
|
145
|
+
extra += ";alignment={}".format(infos.alignment)
|
|
146
|
+
elif infos.title is not None:
|
|
147
|
+
extra += ";title={}".format(infos.title)
|
|
148
|
+
descbuf.append(fmt.format(k, infos.type, infos.offset, extra))
|
|
149
|
+
|
|
150
|
+
desc = ",".join(descbuf)
|
|
151
|
+
name = "Record({};{};{})".format(desc, self.size, self.aligned)
|
|
152
|
+
super(Record, self).__init__(name)
|
|
153
|
+
|
|
154
|
+
self.bitwidth = self.dtype.itemsize * 8
|
|
155
|
+
|
|
156
|
+
@classmethod
|
|
157
|
+
def _normalize_fields(cls, fields):
|
|
158
|
+
"""
|
|
159
|
+
fields:
|
|
160
|
+
[name: str,
|
|
161
|
+
value: {
|
|
162
|
+
type: Type,
|
|
163
|
+
offset: int,
|
|
164
|
+
[ alignment: int ],
|
|
165
|
+
[ title : str],
|
|
166
|
+
}]
|
|
167
|
+
"""
|
|
168
|
+
res = []
|
|
169
|
+
for name, infos in sorted(fields, key=lambda x: (x[1]["offset"], x[0])):
|
|
170
|
+
fd = _RecordField(
|
|
171
|
+
type=infos["type"],
|
|
172
|
+
offset=infos["offset"],
|
|
173
|
+
alignment=infos.get("alignment"),
|
|
174
|
+
title=infos.get("title"),
|
|
175
|
+
)
|
|
176
|
+
res.append((name, fd))
|
|
177
|
+
return res
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def key(self):
|
|
181
|
+
# Numpy dtype equality doesn't always succeed, use the name instead
|
|
182
|
+
# (https://github.com/numpy/numpy/issues/5715)
|
|
183
|
+
return self.name
|
|
184
|
+
|
|
185
|
+
@property
|
|
186
|
+
def mangling_args(self):
|
|
187
|
+
return self.__class__.__name__, (self._code,)
|
|
188
|
+
|
|
189
|
+
def __len__(self):
|
|
190
|
+
"""Returns the number of fields"""
|
|
191
|
+
return len(self.fields)
|
|
192
|
+
|
|
193
|
+
def offset(self, key):
|
|
194
|
+
"""Get the byte offset of a field from the start of the structure."""
|
|
195
|
+
return self.fields[key].offset
|
|
196
|
+
|
|
197
|
+
def typeof(self, key):
|
|
198
|
+
"""Get the type of a field."""
|
|
199
|
+
return self.fields[key].type
|
|
200
|
+
|
|
201
|
+
def alignof(self, key):
|
|
202
|
+
"""Get the specified alignment of the field.
|
|
203
|
+
|
|
204
|
+
Since field alignment is optional, this may return None.
|
|
205
|
+
"""
|
|
206
|
+
return self.fields[key].alignment
|
|
207
|
+
|
|
208
|
+
def has_titles(self):
|
|
209
|
+
"""Returns True the record uses titles."""
|
|
210
|
+
return any(fd.title is not None for fd in self.fields.values())
|
|
211
|
+
|
|
212
|
+
def is_title(self, key):
|
|
213
|
+
"""Returns True if the field named *key* is a title."""
|
|
214
|
+
return self.fields[key].title == key
|
|
215
|
+
|
|
216
|
+
@property
|
|
217
|
+
def members(self):
|
|
218
|
+
"""An ordered list of (name, type) for the fields."""
|
|
219
|
+
ordered = sorted(self.fields.items(), key=lambda x: x[1].offset)
|
|
220
|
+
return [(k, v.type) for k, v in ordered]
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def dtype(self):
|
|
224
|
+
from numba.cuda.np.numpy_support import as_struct_dtype
|
|
225
|
+
|
|
226
|
+
return as_struct_dtype(self)
|
|
227
|
+
|
|
228
|
+
def can_convert_to(self, typingctx, other):
|
|
229
|
+
"""
|
|
230
|
+
Convert this Record to the *other*.
|
|
231
|
+
|
|
232
|
+
This method only implements width subtyping for records.
|
|
233
|
+
"""
|
|
234
|
+
from numba.cuda.core.errors import NumbaExperimentalFeatureWarning
|
|
235
|
+
|
|
236
|
+
if isinstance(other, Record):
|
|
237
|
+
if len(other.fields) > len(self.fields):
|
|
238
|
+
return
|
|
239
|
+
for other_fd, self_fd in zip(
|
|
240
|
+
other.fields.items(), self.fields.items()
|
|
241
|
+
):
|
|
242
|
+
if not other_fd == self_fd:
|
|
243
|
+
return
|
|
244
|
+
warnings.warn(
|
|
245
|
+
f"{self} has been considered a subtype of {other} "
|
|
246
|
+
f" This is an experimental feature.",
|
|
247
|
+
category=NumbaExperimentalFeatureWarning,
|
|
248
|
+
)
|
|
249
|
+
return Conversion.safe
|
|
250
|
+
|
|
251
|
+
def __repr__(self):
|
|
252
|
+
fields = [
|
|
253
|
+
f"('{f_name}', "
|
|
254
|
+
+ f"{{'type': {repr(f_info.type)}, "
|
|
255
|
+
+ f"'offset': {f_info.offset}, "
|
|
256
|
+
+ f"'alignment': {f_info.alignment}, "
|
|
257
|
+
+ f"'title': {f_info.title}, "
|
|
258
|
+
+ "}"
|
|
259
|
+
+ ")"
|
|
260
|
+
for f_name, f_info in self.fields.items()
|
|
261
|
+
]
|
|
262
|
+
fields = "[" + ", ".join(fields) + "]"
|
|
263
|
+
return f"Record({fields}, {self.size}, {self.aligned})"
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class DType(DTypeSpec, Opaque):
|
|
267
|
+
"""
|
|
268
|
+
Type class associated with the `np.dtype`.
|
|
269
|
+
|
|
270
|
+
i.e. :code:`assert type(np.dtype('int32')) == np.dtype`
|
|
271
|
+
|
|
272
|
+
np.dtype('int32')
|
|
273
|
+
"""
|
|
274
|
+
|
|
275
|
+
def __init__(self, dtype):
|
|
276
|
+
assert isinstance(dtype, Type)
|
|
277
|
+
self._dtype = dtype
|
|
278
|
+
name = "dtype(%s)" % (dtype,)
|
|
279
|
+
super(DTypeSpec, self).__init__(name)
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def key(self):
|
|
283
|
+
return self.dtype
|
|
284
|
+
|
|
285
|
+
@property
|
|
286
|
+
def dtype(self):
|
|
287
|
+
return self._dtype
|
|
288
|
+
|
|
289
|
+
def __getitem__(self, arg):
|
|
290
|
+
res = super(DType, self).__getitem__(arg)
|
|
291
|
+
return res.copy(dtype=self.dtype)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class NumpyFlatType(SimpleIteratorType, MutableSequence):
|
|
295
|
+
"""
|
|
296
|
+
Type class for `ndarray.flat()` objects.
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
def __init__(self, arrty):
|
|
300
|
+
self.array_type = arrty
|
|
301
|
+
yield_type = arrty.dtype
|
|
302
|
+
self.dtype = yield_type
|
|
303
|
+
name = "array.flat({arrayty})".format(arrayty=arrty)
|
|
304
|
+
super(NumpyFlatType, self).__init__(name, yield_type)
|
|
305
|
+
|
|
306
|
+
@property
|
|
307
|
+
def key(self):
|
|
308
|
+
return self.array_type
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class NumpyNdEnumerateType(SimpleIteratorType):
|
|
312
|
+
"""
|
|
313
|
+
Type class for `np.ndenumerate()` objects.
|
|
314
|
+
"""
|
|
315
|
+
|
|
316
|
+
def __init__(self, arrty):
|
|
317
|
+
from . import Tuple, UniTuple, intp
|
|
318
|
+
|
|
319
|
+
self.array_type = arrty
|
|
320
|
+
yield_type = Tuple((UniTuple(intp, arrty.ndim), arrty.dtype))
|
|
321
|
+
name = "ndenumerate({arrayty})".format(arrayty=arrty)
|
|
322
|
+
super(NumpyNdEnumerateType, self).__init__(name, yield_type)
|
|
323
|
+
|
|
324
|
+
@property
|
|
325
|
+
def key(self):
|
|
326
|
+
return self.array_type
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class NumpyNdIterType(IteratorType):
|
|
330
|
+
"""
|
|
331
|
+
Type class for `np.nditer()` objects.
|
|
332
|
+
|
|
333
|
+
The layout denotes in which order the logical shape is iterated on.
|
|
334
|
+
"C" means logical order (corresponding to in-memory order in C arrays),
|
|
335
|
+
"F" means reverse logical order (corresponding to in-memory order in
|
|
336
|
+
F arrays).
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
def __init__(self, arrays):
|
|
340
|
+
# Note inputs arrays can also be scalars, in which case they are
|
|
341
|
+
# broadcast.
|
|
342
|
+
self.arrays = tuple(arrays)
|
|
343
|
+
self.layout = self._compute_layout(self.arrays)
|
|
344
|
+
self.dtypes = tuple(getattr(a, "dtype", a) for a in self.arrays)
|
|
345
|
+
self.ndim = max(getattr(a, "ndim", 0) for a in self.arrays)
|
|
346
|
+
name = "nditer(ndim={ndim}, layout={layout}, inputs={arrays})".format(
|
|
347
|
+
ndim=self.ndim, layout=self.layout, arrays=self.arrays
|
|
348
|
+
)
|
|
349
|
+
super(NumpyNdIterType, self).__init__(name)
|
|
350
|
+
|
|
351
|
+
@classmethod
|
|
352
|
+
def _compute_layout(cls, arrays):
|
|
353
|
+
c = collections.Counter()
|
|
354
|
+
for a in arrays:
|
|
355
|
+
if not isinstance(a, Array):
|
|
356
|
+
continue
|
|
357
|
+
if a.layout in "CF" and a.ndim == 1:
|
|
358
|
+
c["C"] += 1
|
|
359
|
+
c["F"] += 1
|
|
360
|
+
elif a.ndim >= 1:
|
|
361
|
+
c[a.layout] += 1
|
|
362
|
+
return "F" if c["F"] > c["C"] else "C"
|
|
363
|
+
|
|
364
|
+
@property
|
|
365
|
+
def key(self):
|
|
366
|
+
return self.arrays
|
|
367
|
+
|
|
368
|
+
@property
|
|
369
|
+
def views(self):
|
|
370
|
+
"""
|
|
371
|
+
The views yielded by the iterator.
|
|
372
|
+
"""
|
|
373
|
+
return [Array(dtype, 0, "C") for dtype in self.dtypes]
|
|
374
|
+
|
|
375
|
+
@property
|
|
376
|
+
def yield_type(self):
|
|
377
|
+
from . import BaseTuple
|
|
378
|
+
|
|
379
|
+
views = self.views
|
|
380
|
+
if len(views) > 1:
|
|
381
|
+
return BaseTuple.from_types(views)
|
|
382
|
+
else:
|
|
383
|
+
return views[0]
|
|
384
|
+
|
|
385
|
+
@cached_property
|
|
386
|
+
def indexers(self):
|
|
387
|
+
"""
|
|
388
|
+
A list of (kind, start_dim, end_dim, indices) where:
|
|
389
|
+
- `kind` is either "flat", "indexed", "0d" or "scalar"
|
|
390
|
+
- `start_dim` and `end_dim` are the dimension numbers at which
|
|
391
|
+
this indexing takes place
|
|
392
|
+
- `indices` is the indices of the indexed arrays in self.arrays
|
|
393
|
+
"""
|
|
394
|
+
d = collections.OrderedDict()
|
|
395
|
+
layout = self.layout
|
|
396
|
+
ndim = self.ndim
|
|
397
|
+
assert layout in "CF"
|
|
398
|
+
for i, a in enumerate(self.arrays):
|
|
399
|
+
if not isinstance(a, Array):
|
|
400
|
+
indexer = ("scalar", 0, 0)
|
|
401
|
+
elif a.ndim == 0:
|
|
402
|
+
indexer = ("0d", 0, 0)
|
|
403
|
+
else:
|
|
404
|
+
if a.layout == layout or (a.ndim == 1 and a.layout in "CF"):
|
|
405
|
+
kind = "flat"
|
|
406
|
+
else:
|
|
407
|
+
kind = "indexed"
|
|
408
|
+
if layout == "C":
|
|
409
|
+
# If iterating in C order, broadcasting is done on the outer indices
|
|
410
|
+
indexer = (kind, ndim - a.ndim, ndim)
|
|
411
|
+
else:
|
|
412
|
+
indexer = (kind, 0, a.ndim)
|
|
413
|
+
d.setdefault(indexer, []).append(i)
|
|
414
|
+
return list(k + (v,) for k, v in d.items())
|
|
415
|
+
|
|
416
|
+
@cached_property
|
|
417
|
+
def need_shaped_indexing(self):
|
|
418
|
+
"""
|
|
419
|
+
Whether iterating on this iterator requires keeping track of
|
|
420
|
+
individual indices inside the shape. If False, only a single index
|
|
421
|
+
over the equivalent flat shape is required, which can make the
|
|
422
|
+
iterator more efficient.
|
|
423
|
+
"""
|
|
424
|
+
for kind, start_dim, end_dim, _ in self.indexers:
|
|
425
|
+
if kind in ("0d", "scalar"):
|
|
426
|
+
pass
|
|
427
|
+
elif kind == "flat":
|
|
428
|
+
if (start_dim, end_dim) != (0, self.ndim):
|
|
429
|
+
# Broadcast flat iteration needs shaped indexing
|
|
430
|
+
# to know when to restart iteration.
|
|
431
|
+
return True
|
|
432
|
+
else:
|
|
433
|
+
return True
|
|
434
|
+
return False
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
class NumpyNdIndexType(SimpleIteratorType):
|
|
438
|
+
"""
|
|
439
|
+
Type class for `np.ndindex()` objects.
|
|
440
|
+
"""
|
|
441
|
+
|
|
442
|
+
def __init__(self, ndim):
|
|
443
|
+
from . import UniTuple, intp
|
|
444
|
+
|
|
445
|
+
self.ndim = ndim
|
|
446
|
+
yield_type = UniTuple(intp, self.ndim)
|
|
447
|
+
name = "ndindex(ndim={ndim})".format(ndim=ndim)
|
|
448
|
+
super(NumpyNdIndexType, self).__init__(name, yield_type)
|
|
449
|
+
|
|
450
|
+
@property
|
|
451
|
+
def key(self):
|
|
452
|
+
return self.ndim
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
class Array(Buffer):
|
|
456
|
+
"""
|
|
457
|
+
Type class for Numpy arrays.
|
|
458
|
+
"""
|
|
459
|
+
|
|
460
|
+
def __init__(
|
|
461
|
+
self, dtype, ndim, layout, readonly=False, name=None, aligned=True
|
|
462
|
+
):
|
|
463
|
+
if readonly:
|
|
464
|
+
self.mutable = False
|
|
465
|
+
if not aligned or (isinstance(dtype, Record) and not dtype.aligned):
|
|
466
|
+
self.aligned = False
|
|
467
|
+
if isinstance(dtype, NestedArray):
|
|
468
|
+
ndim += dtype.ndim
|
|
469
|
+
dtype = dtype.dtype
|
|
470
|
+
if name is None:
|
|
471
|
+
type_name = "array"
|
|
472
|
+
if not self.mutable:
|
|
473
|
+
type_name = "readonly " + type_name
|
|
474
|
+
if not self.aligned:
|
|
475
|
+
type_name = "unaligned " + type_name
|
|
476
|
+
name = "%s(%s, %sd, %s)" % (type_name, dtype, ndim, layout)
|
|
477
|
+
super(Array, self).__init__(dtype, ndim, layout, name=name)
|
|
478
|
+
|
|
479
|
+
@property
|
|
480
|
+
def mangling_args(self):
|
|
481
|
+
args = [
|
|
482
|
+
self.dtype,
|
|
483
|
+
self.ndim,
|
|
484
|
+
self.layout,
|
|
485
|
+
"mutable" if self.mutable else "readonly",
|
|
486
|
+
"aligned" if self.aligned else "unaligned",
|
|
487
|
+
]
|
|
488
|
+
return self.__class__.__name__, args
|
|
489
|
+
|
|
490
|
+
def copy(self, dtype=None, ndim=None, layout=None, readonly=None):
|
|
491
|
+
if dtype is None:
|
|
492
|
+
dtype = self.dtype
|
|
493
|
+
if ndim is None:
|
|
494
|
+
ndim = self.ndim
|
|
495
|
+
if layout is None:
|
|
496
|
+
layout = self.layout
|
|
497
|
+
if readonly is None:
|
|
498
|
+
readonly = not self.mutable
|
|
499
|
+
return Array(
|
|
500
|
+
dtype=dtype,
|
|
501
|
+
ndim=ndim,
|
|
502
|
+
layout=layout,
|
|
503
|
+
readonly=readonly,
|
|
504
|
+
aligned=self.aligned,
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
@property
|
|
508
|
+
def key(self):
|
|
509
|
+
return self.dtype, self.ndim, self.layout, self.mutable, self.aligned
|
|
510
|
+
|
|
511
|
+
def unify(self, typingctx, other):
|
|
512
|
+
"""
|
|
513
|
+
Unify this with the *other* Array.
|
|
514
|
+
"""
|
|
515
|
+
# If other is array and the ndim matches
|
|
516
|
+
if isinstance(other, Array) and other.ndim == self.ndim:
|
|
517
|
+
# If dtype matches or other.dtype is undefined (inferred)
|
|
518
|
+
if other.dtype == self.dtype or not other.dtype.is_precise():
|
|
519
|
+
if self.layout == other.layout:
|
|
520
|
+
layout = self.layout
|
|
521
|
+
else:
|
|
522
|
+
layout = "A"
|
|
523
|
+
readonly = not (self.mutable and other.mutable)
|
|
524
|
+
aligned = self.aligned and other.aligned
|
|
525
|
+
return Array(
|
|
526
|
+
dtype=self.dtype,
|
|
527
|
+
ndim=self.ndim,
|
|
528
|
+
layout=layout,
|
|
529
|
+
readonly=readonly,
|
|
530
|
+
aligned=aligned,
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
def can_convert_to(self, typingctx, other):
|
|
534
|
+
"""
|
|
535
|
+
Convert this Array to the *other*.
|
|
536
|
+
"""
|
|
537
|
+
if (
|
|
538
|
+
isinstance(other, Array)
|
|
539
|
+
and other.ndim == self.ndim
|
|
540
|
+
and other.dtype == self.dtype
|
|
541
|
+
):
|
|
542
|
+
if (
|
|
543
|
+
other.layout in ("A", self.layout)
|
|
544
|
+
and (self.mutable or not other.mutable)
|
|
545
|
+
and (self.aligned or not other.aligned)
|
|
546
|
+
):
|
|
547
|
+
return Conversion.safe
|
|
548
|
+
|
|
549
|
+
def is_precise(self):
|
|
550
|
+
return self.dtype.is_precise()
|
|
551
|
+
|
|
552
|
+
@property
|
|
553
|
+
def box_type(self):
|
|
554
|
+
"""Returns the Python type to box to."""
|
|
555
|
+
return np.ndarray
|
|
556
|
+
|
|
557
|
+
def __repr__(self):
|
|
558
|
+
return (
|
|
559
|
+
f"Array({repr(self.dtype)}, {self.ndim}, '{self.layout}', "
|
|
560
|
+
f"{not self.mutable}, aligned={self.aligned})"
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
class ArrayCTypes(Type):
|
|
565
|
+
"""
|
|
566
|
+
This is the type for `np.ndarray.ctypes`.
|
|
567
|
+
"""
|
|
568
|
+
|
|
569
|
+
def __init__(self, arytype):
|
|
570
|
+
# This depends on the ndim for the shape and strides attributes,
|
|
571
|
+
# even though they are not implemented, yet.
|
|
572
|
+
self.dtype = arytype.dtype
|
|
573
|
+
self.ndim = arytype.ndim
|
|
574
|
+
name = "ArrayCTypes(dtype={0}, ndim={1})".format(self.dtype, self.ndim)
|
|
575
|
+
super(ArrayCTypes, self).__init__(name)
|
|
576
|
+
|
|
577
|
+
@property
|
|
578
|
+
def key(self):
|
|
579
|
+
return self.dtype, self.ndim
|
|
580
|
+
|
|
581
|
+
def can_convert_to(self, typingctx, other):
|
|
582
|
+
"""
|
|
583
|
+
Convert this type to the corresponding pointer type.
|
|
584
|
+
This allows passing a array.ctypes object to a C function taking
|
|
585
|
+
a raw pointer.
|
|
586
|
+
|
|
587
|
+
Note that in pure Python, the array.ctypes object can only be
|
|
588
|
+
passed to a ctypes function accepting a c_void_p, not a typed
|
|
589
|
+
pointer.
|
|
590
|
+
"""
|
|
591
|
+
from . import CPointer, voidptr
|
|
592
|
+
|
|
593
|
+
# XXX what about readonly
|
|
594
|
+
if isinstance(other, CPointer) and other.dtype == self.dtype:
|
|
595
|
+
return Conversion.safe
|
|
596
|
+
elif other == voidptr:
|
|
597
|
+
return Conversion.safe
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
class ArrayFlags(Type):
|
|
601
|
+
"""
|
|
602
|
+
This is the type for `np.ndarray.flags`.
|
|
603
|
+
"""
|
|
604
|
+
|
|
605
|
+
def __init__(self, arytype):
|
|
606
|
+
self.array_type = arytype
|
|
607
|
+
name = "ArrayFlags({0})".format(self.array_type)
|
|
608
|
+
super(ArrayFlags, self).__init__(name)
|
|
609
|
+
|
|
610
|
+
@property
|
|
611
|
+
def key(self):
|
|
612
|
+
return self.array_type
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
class NestedArray(Array):
|
|
616
|
+
"""
|
|
617
|
+
A NestedArray is an array nested within a structured type (which are "void"
|
|
618
|
+
type in NumPy parlance). Unlike an Array, the shape, and not just the number
|
|
619
|
+
of dimensions is part of the type of a NestedArray.
|
|
620
|
+
"""
|
|
621
|
+
|
|
622
|
+
def __init__(self, dtype, shape):
|
|
623
|
+
if isinstance(dtype, NestedArray):
|
|
624
|
+
tmp = Array(dtype.dtype, dtype.ndim, "C")
|
|
625
|
+
shape += dtype.shape
|
|
626
|
+
dtype = tmp.dtype
|
|
627
|
+
assert dtype.bitwidth % 8 == 0, (
|
|
628
|
+
"Dtype bitwidth must be a multiple of bytes"
|
|
629
|
+
)
|
|
630
|
+
self._shape = shape
|
|
631
|
+
name = "nestedarray(%s, %s)" % (dtype, shape)
|
|
632
|
+
ndim = len(shape)
|
|
633
|
+
super(NestedArray, self).__init__(dtype, ndim, "C", name=name)
|
|
634
|
+
|
|
635
|
+
@property
|
|
636
|
+
def shape(self):
|
|
637
|
+
return self._shape
|
|
638
|
+
|
|
639
|
+
@property
|
|
640
|
+
def nitems(self):
|
|
641
|
+
l = 1
|
|
642
|
+
for s in self.shape:
|
|
643
|
+
l = l * s
|
|
644
|
+
return l
|
|
645
|
+
|
|
646
|
+
@property
|
|
647
|
+
def size(self):
|
|
648
|
+
return self.dtype.bitwidth // 8
|
|
649
|
+
|
|
650
|
+
@property
|
|
651
|
+
def strides(self):
|
|
652
|
+
stride = self.size
|
|
653
|
+
strides = []
|
|
654
|
+
for i in reversed(self._shape):
|
|
655
|
+
strides.append(stride)
|
|
656
|
+
stride *= i
|
|
657
|
+
return tuple(reversed(strides))
|
|
658
|
+
|
|
659
|
+
@property
|
|
660
|
+
def key(self):
|
|
661
|
+
return self.dtype, self.shape
|
|
662
|
+
|
|
663
|
+
def __repr__(self):
|
|
664
|
+
return f"NestedArray({repr(self.dtype)}, {self.shape})"
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
class NumPyRandomBitGeneratorType(Type):
|
|
668
|
+
def __init__(self, *args, **kwargs):
|
|
669
|
+
super(NumPyRandomBitGeneratorType, self).__init__(*args, **kwargs)
|
|
670
|
+
self.name = "NumPyRandomBitGeneratorType"
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
class NumPyRandomGeneratorType(Type):
|
|
674
|
+
def __init__(self, *args, **kwargs):
|
|
675
|
+
super(NumPyRandomGeneratorType, self).__init__(*args, **kwargs)
|
|
676
|
+
self.name = "NumPyRandomGeneratorType"
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
class PolynomialType(Type):
|
|
680
|
+
def __init__(self, coef, domain=None, window=None, n_args=1):
|
|
681
|
+
super(PolynomialType, self).__init__(
|
|
682
|
+
name=f"PolynomialType({coef}, {domain}, {domain}, {n_args})"
|
|
683
|
+
)
|
|
684
|
+
self.coef = coef
|
|
685
|
+
self.domain = domain
|
|
686
|
+
self.window = window
|
|
687
|
+
# We use n_args to keep track of the number of arguments in the
|
|
688
|
+
# constructor, since the types of domain and window arguments depend on
|
|
689
|
+
# that and we need that information when boxing
|
|
690
|
+
self.n_args = n_args
|