numba-cuda 0.22.0__cp313-cp313-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.
- _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-313-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-313-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-313-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-313-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-313-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,533 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
from abc import ABCMeta, abstractmethod, abstractproperty
|
|
5
|
+
from typing import Dict as ptDict, Type as ptType
|
|
6
|
+
import itertools
|
|
7
|
+
import weakref
|
|
8
|
+
from functools import cached_property
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
from numba.cuda.utils import get_hashable_key
|
|
13
|
+
|
|
14
|
+
# Types are added to a global registry (_typecache) in order to assign
|
|
15
|
+
# them unique integer codes for fast matching in _dispatcher.c.
|
|
16
|
+
# However, we also want types to be disposable, therefore we ensure
|
|
17
|
+
# each type is interned as a weak reference, so that it lives only as
|
|
18
|
+
# long as necessary to keep a stable type code.
|
|
19
|
+
# NOTE: some types can still be made immortal elsewhere (for example
|
|
20
|
+
# in _dispatcher.c's internal caches).
|
|
21
|
+
_typecodes = itertools.count()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _autoincr():
|
|
25
|
+
n = next(_typecodes)
|
|
26
|
+
# 4 billion types should be enough, right?
|
|
27
|
+
assert n < 2**32, "Limited to 4 billion types"
|
|
28
|
+
return n
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
_typecache: ptDict[weakref.ref, weakref.ref] = {}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _on_type_disposal(wr, _pop=_typecache.pop):
|
|
35
|
+
_pop(wr, None)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class _TypeMetaclass(ABCMeta):
|
|
39
|
+
"""
|
|
40
|
+
A metaclass that will intern instances after they are created.
|
|
41
|
+
This is done by first creating a new instance (including calling
|
|
42
|
+
__init__, which sets up the required attributes for equality
|
|
43
|
+
and hashing), then looking it up in the _typecache registry.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(cls, name, bases, orig_vars):
|
|
47
|
+
# __init__ is hooked to mark whether a Type class being defined is a
|
|
48
|
+
# Numba internal type (one which is defined somewhere under the `numba`
|
|
49
|
+
# module) or an external type (one which is defined elsewhere, for
|
|
50
|
+
# example a user defined type).
|
|
51
|
+
super(_TypeMetaclass, cls).__init__(name, bases, orig_vars)
|
|
52
|
+
root = (cls.__module__.split("."))[0]
|
|
53
|
+
cls._is_internal = root == "numba"
|
|
54
|
+
|
|
55
|
+
def _intern(cls, inst):
|
|
56
|
+
# Try to intern the created instance
|
|
57
|
+
wr = weakref.ref(inst, _on_type_disposal)
|
|
58
|
+
orig = _typecache.get(wr)
|
|
59
|
+
orig = orig and orig()
|
|
60
|
+
if orig is not None:
|
|
61
|
+
return orig
|
|
62
|
+
else:
|
|
63
|
+
inst._code = _autoincr()
|
|
64
|
+
_typecache[wr] = wr
|
|
65
|
+
return inst
|
|
66
|
+
|
|
67
|
+
def __call__(cls, *args, **kwargs):
|
|
68
|
+
"""
|
|
69
|
+
Instantiate *cls* (a Type subclass, presumably) and intern it.
|
|
70
|
+
If an interned instance already exists, it is returned, otherwise
|
|
71
|
+
the new instance is returned.
|
|
72
|
+
"""
|
|
73
|
+
inst = type.__call__(cls, *args, **kwargs)
|
|
74
|
+
return cls._intern(inst)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _type_reconstructor(reconstructor, reconstructor_args, state):
|
|
78
|
+
"""
|
|
79
|
+
Rebuild function for unpickling types.
|
|
80
|
+
"""
|
|
81
|
+
obj = reconstructor(*reconstructor_args)
|
|
82
|
+
if state:
|
|
83
|
+
obj.__dict__.update(state)
|
|
84
|
+
return type(obj)._intern(obj)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Type(metaclass=_TypeMetaclass):
|
|
88
|
+
"""
|
|
89
|
+
The base class for all Numba types.
|
|
90
|
+
It is essential that proper equality comparison is implemented. The
|
|
91
|
+
default implementation uses the "key" property (overridable in subclasses)
|
|
92
|
+
for both comparison and hashing, to ensure sane behaviour.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
mutable = False
|
|
96
|
+
# Rather the type is reflected at the python<->nopython boundary
|
|
97
|
+
reflected = False
|
|
98
|
+
|
|
99
|
+
def __init__(self, name):
|
|
100
|
+
self.name = name
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def key(self):
|
|
104
|
+
"""
|
|
105
|
+
A property used for __eq__, __ne__ and __hash__. Can be overridden
|
|
106
|
+
in subclasses.
|
|
107
|
+
"""
|
|
108
|
+
return self.name
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def mangling_args(self):
|
|
112
|
+
"""
|
|
113
|
+
Returns `(basename, args)` where `basename` is the name of the type
|
|
114
|
+
and `args` is a sequence of parameters of the type.
|
|
115
|
+
|
|
116
|
+
Subclass should override to specialize the behavior.
|
|
117
|
+
By default, this returns `(self.name, ())`.
|
|
118
|
+
"""
|
|
119
|
+
return self.name, ()
|
|
120
|
+
|
|
121
|
+
def __repr__(self):
|
|
122
|
+
return self.name
|
|
123
|
+
|
|
124
|
+
def __str__(self):
|
|
125
|
+
return self.name
|
|
126
|
+
|
|
127
|
+
def __hash__(self):
|
|
128
|
+
return hash(self.key)
|
|
129
|
+
|
|
130
|
+
def __eq__(self, other):
|
|
131
|
+
return self.__class__ is other.__class__ and self.key == other.key
|
|
132
|
+
|
|
133
|
+
def __ne__(self, other):
|
|
134
|
+
return not (self == other)
|
|
135
|
+
|
|
136
|
+
def __reduce__(self):
|
|
137
|
+
reconstructor, args, state = super(Type, self).__reduce__()
|
|
138
|
+
return (_type_reconstructor, (reconstructor, args, state))
|
|
139
|
+
|
|
140
|
+
def unify(self, typingctx, other):
|
|
141
|
+
"""
|
|
142
|
+
Try to unify this type with the *other*. A third type must
|
|
143
|
+
be returned, or None if unification is not possible.
|
|
144
|
+
Only override this if the coercion logic cannot be expressed
|
|
145
|
+
as simple casting rules.
|
|
146
|
+
"""
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
def can_convert_to(self, typingctx, other):
|
|
150
|
+
"""
|
|
151
|
+
Check whether this type can be converted to the *other*.
|
|
152
|
+
If successful, must return a string describing the conversion, e.g.
|
|
153
|
+
"exact", "promote", "unsafe", "safe"; otherwise None is returned.
|
|
154
|
+
"""
|
|
155
|
+
return None
|
|
156
|
+
|
|
157
|
+
def can_convert_from(self, typingctx, other):
|
|
158
|
+
"""
|
|
159
|
+
Similar to *can_convert_to*, but in reverse. Only needed if
|
|
160
|
+
the type provides conversion from other types.
|
|
161
|
+
"""
|
|
162
|
+
return None
|
|
163
|
+
|
|
164
|
+
def is_precise(self):
|
|
165
|
+
"""
|
|
166
|
+
Whether this type is precise, i.e. can be part of a successful
|
|
167
|
+
type inference. Default implementation returns True.
|
|
168
|
+
"""
|
|
169
|
+
return True
|
|
170
|
+
|
|
171
|
+
def augment(self, other):
|
|
172
|
+
"""
|
|
173
|
+
Augment this type with the *other*. Return the augmented type,
|
|
174
|
+
or None if not supported.
|
|
175
|
+
"""
|
|
176
|
+
return None
|
|
177
|
+
|
|
178
|
+
# User-facing helpers. These are not part of the core Type API but
|
|
179
|
+
# are provided so that users can write e.g. `numba.boolean(1.5)`
|
|
180
|
+
# (returns True) or `types.int32(types.int32[:])` (returns something
|
|
181
|
+
# usable as a function signature).
|
|
182
|
+
|
|
183
|
+
def __call__(self, *args):
|
|
184
|
+
from numba.cuda.typing import signature
|
|
185
|
+
|
|
186
|
+
if len(args) == 1 and not isinstance(args[0], Type):
|
|
187
|
+
return self.cast_python_value(args[0])
|
|
188
|
+
return signature(
|
|
189
|
+
self, # return_type
|
|
190
|
+
*args,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def __getitem__(self, args):
|
|
194
|
+
"""
|
|
195
|
+
Return an array of this type.
|
|
196
|
+
"""
|
|
197
|
+
from numba.cuda.types import Array
|
|
198
|
+
|
|
199
|
+
ndim, layout = self._determine_array_spec(args)
|
|
200
|
+
return Array(dtype=self, ndim=ndim, layout=layout)
|
|
201
|
+
|
|
202
|
+
def _determine_array_spec(self, args):
|
|
203
|
+
# XXX non-contiguous by default, even for 1d arrays,
|
|
204
|
+
# doesn't sound very intuitive
|
|
205
|
+
def validate_slice(s):
|
|
206
|
+
return isinstance(s, slice) and s.start is None and s.stop is None
|
|
207
|
+
|
|
208
|
+
if isinstance(args, (tuple, list)) and all(map(validate_slice, args)):
|
|
209
|
+
ndim = len(args)
|
|
210
|
+
if args[0].step == 1:
|
|
211
|
+
layout = "F"
|
|
212
|
+
elif args[-1].step == 1:
|
|
213
|
+
layout = "C"
|
|
214
|
+
else:
|
|
215
|
+
layout = "A"
|
|
216
|
+
elif validate_slice(args):
|
|
217
|
+
ndim = 1
|
|
218
|
+
if args.step == 1:
|
|
219
|
+
layout = "C"
|
|
220
|
+
else:
|
|
221
|
+
layout = "A"
|
|
222
|
+
else:
|
|
223
|
+
# Raise a KeyError to not be handled by collection constructors (e.g. list).
|
|
224
|
+
raise KeyError(
|
|
225
|
+
f"Can only index numba types with slices with no start or stop, got {args}."
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return ndim, layout
|
|
229
|
+
|
|
230
|
+
def cast_python_value(self, args):
|
|
231
|
+
raise NotImplementedError
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def is_internal(self):
|
|
235
|
+
"""Returns True if this class is an internally defined Numba type by
|
|
236
|
+
virtue of the module in which it is instantiated, False else."""
|
|
237
|
+
return self._is_internal
|
|
238
|
+
|
|
239
|
+
def dump(self, tab=""):
|
|
240
|
+
print(
|
|
241
|
+
f"{tab}DUMP {type(self).__name__}[code={self._code}, name={self.name}]"
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
# XXX we should distinguish between Dummy (no meaningful
|
|
246
|
+
# representation, e.g. None or a builtin function) and Opaque (has a
|
|
247
|
+
# meaningful representation, e.g. ExternalFunctionPointer)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class Dummy(Type):
|
|
251
|
+
"""
|
|
252
|
+
Base class for types that do not really have a representation and are
|
|
253
|
+
compatible with a void*.
|
|
254
|
+
"""
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class Hashable(Type):
|
|
258
|
+
"""
|
|
259
|
+
Base class for hashable types.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class Number(Hashable):
|
|
264
|
+
"""
|
|
265
|
+
Base class for number types.
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
def unify(self, typingctx, other):
|
|
269
|
+
"""
|
|
270
|
+
Unify the two number types using Numpy's rules.
|
|
271
|
+
"""
|
|
272
|
+
from numba.cuda.np import numpy_support
|
|
273
|
+
|
|
274
|
+
if isinstance(other, Number):
|
|
275
|
+
# XXX: this can produce unsafe conversions,
|
|
276
|
+
# e.g. would unify {int64, uint64} to float64
|
|
277
|
+
a = numpy_support.as_dtype(self)
|
|
278
|
+
b = numpy_support.as_dtype(other)
|
|
279
|
+
sel = np.promote_types(a, b)
|
|
280
|
+
return numpy_support.from_dtype(sel)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
class Callable(Type):
|
|
284
|
+
"""
|
|
285
|
+
Base class for callables.
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
@abstractmethod
|
|
289
|
+
def get_call_type(self, context, args, kws):
|
|
290
|
+
"""
|
|
291
|
+
Using the typing *context*, resolve the callable's signature for
|
|
292
|
+
the given arguments. A signature object is returned, or None.
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
@abstractmethod
|
|
296
|
+
def get_call_signatures(self):
|
|
297
|
+
"""
|
|
298
|
+
Returns a tuple of (list of signatures, parameterized)
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
@abstractmethod
|
|
302
|
+
def get_impl_key(self, sig):
|
|
303
|
+
"""
|
|
304
|
+
Returns the impl key for the given signature
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
class DTypeSpec(Type):
|
|
309
|
+
"""
|
|
310
|
+
Base class for types usable as "dtype" arguments to various Numpy APIs
|
|
311
|
+
(e.g. np.empty()).
|
|
312
|
+
"""
|
|
313
|
+
|
|
314
|
+
@abstractproperty
|
|
315
|
+
def dtype(self):
|
|
316
|
+
"""
|
|
317
|
+
The actual dtype denoted by this dtype spec (a Type instance).
|
|
318
|
+
"""
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class IterableType(Type):
|
|
322
|
+
"""
|
|
323
|
+
Base class for iterable types.
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
@abstractproperty
|
|
327
|
+
def iterator_type(self):
|
|
328
|
+
"""
|
|
329
|
+
The iterator type obtained when calling iter() (explicitly or implicitly).
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class Sized(Type):
|
|
334
|
+
"""
|
|
335
|
+
Base class for objects that support len()
|
|
336
|
+
"""
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class ConstSized(Sized):
|
|
340
|
+
"""
|
|
341
|
+
For types that have a constant size
|
|
342
|
+
"""
|
|
343
|
+
|
|
344
|
+
@abstractmethod
|
|
345
|
+
def __len__(self):
|
|
346
|
+
pass
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class IteratorType(IterableType):
|
|
350
|
+
"""
|
|
351
|
+
Base class for all iterator types.
|
|
352
|
+
Derived classes should implement the *yield_type* attribute.
|
|
353
|
+
"""
|
|
354
|
+
|
|
355
|
+
def __init__(self, name, **kwargs):
|
|
356
|
+
super(IteratorType, self).__init__(name, **kwargs)
|
|
357
|
+
|
|
358
|
+
@abstractproperty
|
|
359
|
+
def yield_type(self):
|
|
360
|
+
"""
|
|
361
|
+
The type of values yielded by the iterator.
|
|
362
|
+
"""
|
|
363
|
+
|
|
364
|
+
# This is a property to avoid recursivity (for pickling)
|
|
365
|
+
|
|
366
|
+
@property
|
|
367
|
+
def iterator_type(self):
|
|
368
|
+
return self
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class Container(Sized, IterableType):
|
|
372
|
+
"""
|
|
373
|
+
Base class for container types.
|
|
374
|
+
"""
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
class Sequence(Container):
|
|
378
|
+
"""
|
|
379
|
+
Base class for 1d sequence types. Instances should have the *dtype*
|
|
380
|
+
attribute.
|
|
381
|
+
"""
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
class MutableSequence(Sequence):
|
|
385
|
+
"""
|
|
386
|
+
Base class for 1d mutable sequence types. Instances should have the
|
|
387
|
+
*dtype* attribute.
|
|
388
|
+
"""
|
|
389
|
+
|
|
390
|
+
mutable = True
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
class ArrayCompatible(Type):
|
|
394
|
+
"""
|
|
395
|
+
Type class for Numpy array-compatible objects (typically, objects
|
|
396
|
+
exposing an __array__ method).
|
|
397
|
+
Derived classes should implement the *as_array* attribute.
|
|
398
|
+
"""
|
|
399
|
+
|
|
400
|
+
# If overridden by a subclass, it should also implement typing
|
|
401
|
+
# for '__array_wrap__' with arguments (input, formal result).
|
|
402
|
+
array_priority = 0.0
|
|
403
|
+
|
|
404
|
+
@abstractproperty
|
|
405
|
+
def as_array(self):
|
|
406
|
+
"""
|
|
407
|
+
The equivalent array type, for operations supporting array-compatible
|
|
408
|
+
objects (such as ufuncs).
|
|
409
|
+
"""
|
|
410
|
+
|
|
411
|
+
# For compatibility with types.Array
|
|
412
|
+
|
|
413
|
+
@cached_property
|
|
414
|
+
def ndim(self):
|
|
415
|
+
return self.as_array.ndim
|
|
416
|
+
|
|
417
|
+
@cached_property
|
|
418
|
+
def layout(self):
|
|
419
|
+
return self.as_array.layout
|
|
420
|
+
|
|
421
|
+
@cached_property
|
|
422
|
+
def dtype(self):
|
|
423
|
+
return self.as_array.dtype
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class Literal(Type):
|
|
427
|
+
"""Base class for Literal types.
|
|
428
|
+
Literal types contain the original Python value in the type.
|
|
429
|
+
|
|
430
|
+
A literal type should always be constructed from the `literal(val)`
|
|
431
|
+
function.
|
|
432
|
+
"""
|
|
433
|
+
|
|
434
|
+
# *ctor_map* is a dictionary mapping Python types to Literal subclasses
|
|
435
|
+
# for constructing a numba type for a given Python type.
|
|
436
|
+
# It is used in `literal(val)` function.
|
|
437
|
+
# To add new Literal subclass, register a new mapping to this dict.
|
|
438
|
+
ctor_map: ptDict[type, ptType["Literal"]] = {}
|
|
439
|
+
|
|
440
|
+
# *_literal_type_cache* is used to cache the numba type of the given value.
|
|
441
|
+
_literal_type_cache = None
|
|
442
|
+
|
|
443
|
+
def __init__(self, value):
|
|
444
|
+
if type(self) is Literal:
|
|
445
|
+
raise TypeError(
|
|
446
|
+
"Cannot be constructed directly. "
|
|
447
|
+
"Use `numba.cuda.types.literal(value)` instead",
|
|
448
|
+
)
|
|
449
|
+
self._literal_init(value)
|
|
450
|
+
fmt = "Literal[{}]({})"
|
|
451
|
+
super(Literal, self).__init__(fmt.format(type(value).__name__, value))
|
|
452
|
+
|
|
453
|
+
def _literal_init(self, value):
|
|
454
|
+
self._literal_value = value
|
|
455
|
+
# We want to support constants of non-hashable values, therefore
|
|
456
|
+
# fall back on the value's id() if necessary.
|
|
457
|
+
self._key = get_hashable_key(value)
|
|
458
|
+
|
|
459
|
+
@property
|
|
460
|
+
def literal_value(self):
|
|
461
|
+
return self._literal_value
|
|
462
|
+
|
|
463
|
+
@property
|
|
464
|
+
def literal_type(self):
|
|
465
|
+
if self._literal_type_cache is None:
|
|
466
|
+
from numba.cuda import typing
|
|
467
|
+
|
|
468
|
+
ctx = typing.Context()
|
|
469
|
+
try:
|
|
470
|
+
res = ctx.resolve_value_type(self.literal_value)
|
|
471
|
+
except ValueError as e:
|
|
472
|
+
if "Int value is too large" in str(e):
|
|
473
|
+
# If a string literal cannot create an IntegerLiteral
|
|
474
|
+
# because of overflow we generate this message.
|
|
475
|
+
msg = f"Cannot create literal type. {str(e)}"
|
|
476
|
+
raise TypeError(msg)
|
|
477
|
+
# Not all literal types have a literal_value that can be
|
|
478
|
+
# resolved to a type, for example, LiteralStrKeyDict has a
|
|
479
|
+
# literal_value that is a python dict for which there's no
|
|
480
|
+
# `typeof` support.
|
|
481
|
+
msg = "{} has no attribute 'literal_type'".format(self)
|
|
482
|
+
raise AttributeError(msg)
|
|
483
|
+
self._literal_type_cache = res
|
|
484
|
+
|
|
485
|
+
return self._literal_type_cache
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class TypeRef(Dummy):
|
|
489
|
+
"""Reference to a type.
|
|
490
|
+
|
|
491
|
+
Used when a type is passed as a value.
|
|
492
|
+
"""
|
|
493
|
+
|
|
494
|
+
def __init__(self, instance_type):
|
|
495
|
+
self.instance_type = instance_type
|
|
496
|
+
super(TypeRef, self).__init__("typeref[{}]".format(self.instance_type))
|
|
497
|
+
|
|
498
|
+
@property
|
|
499
|
+
def key(self):
|
|
500
|
+
return self.instance_type
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
class InitialValue(object):
|
|
504
|
+
"""
|
|
505
|
+
Used as a mixin for a type will potentially have an initial value that will
|
|
506
|
+
be carried in the .initial_value attribute.
|
|
507
|
+
"""
|
|
508
|
+
|
|
509
|
+
def __init__(self, initial_value):
|
|
510
|
+
self._initial_value = initial_value
|
|
511
|
+
|
|
512
|
+
@property
|
|
513
|
+
def initial_value(self):
|
|
514
|
+
return self._initial_value
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
class Poison(Type):
|
|
518
|
+
"""
|
|
519
|
+
This is the "bottom" type in the type system. It won't unify and it's
|
|
520
|
+
unliteral version is Poison of itself. It's advisable for debugging purposes
|
|
521
|
+
to call the constructor with the type that's being poisoned (for whatever
|
|
522
|
+
reason) but this isn't strictly required.
|
|
523
|
+
"""
|
|
524
|
+
|
|
525
|
+
def __init__(self, ty):
|
|
526
|
+
self.ty = ty
|
|
527
|
+
super(Poison, self).__init__(name="Poison<%s>" % ty)
|
|
528
|
+
|
|
529
|
+
def __unliteral__(self):
|
|
530
|
+
return Poison(self)
|
|
531
|
+
|
|
532
|
+
def unify(self, typingctx, other):
|
|
533
|
+
return None
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Helper classes / mixins for defining types.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .abstract import ArrayCompatible, Dummy, IterableType, IteratorType
|
|
9
|
+
from numba.cuda.core.errors import NumbaTypeError, NumbaValueError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Opaque(Dummy):
|
|
13
|
+
"""
|
|
14
|
+
A type that is a opaque pointer.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SimpleIterableType(IterableType):
|
|
19
|
+
def __init__(self, name, iterator_type):
|
|
20
|
+
self._iterator_type = iterator_type
|
|
21
|
+
super(SimpleIterableType, self).__init__(name)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def iterator_type(self):
|
|
25
|
+
return self._iterator_type
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SimpleIteratorType(IteratorType):
|
|
29
|
+
def __init__(self, name, yield_type):
|
|
30
|
+
self._yield_type = yield_type
|
|
31
|
+
super(SimpleIteratorType, self).__init__(name)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def yield_type(self):
|
|
35
|
+
return self._yield_type
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Buffer(IterableType, ArrayCompatible):
|
|
39
|
+
"""
|
|
40
|
+
Type class for objects providing the buffer protocol.
|
|
41
|
+
Derived classes exist for more specific cases.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
mutable = True
|
|
45
|
+
slice_is_copy = False
|
|
46
|
+
aligned = True
|
|
47
|
+
|
|
48
|
+
# CS and FS are not reserved for inner contig but strided
|
|
49
|
+
LAYOUTS = frozenset(["C", "F", "CS", "FS", "A"])
|
|
50
|
+
|
|
51
|
+
def __init__(self, dtype, ndim, layout, readonly=False, name=None):
|
|
52
|
+
from .misc import unliteral
|
|
53
|
+
|
|
54
|
+
if isinstance(dtype, Buffer):
|
|
55
|
+
msg = (
|
|
56
|
+
"The dtype of a Buffer type cannot itself be a Buffer type, "
|
|
57
|
+
"this is unsupported behaviour."
|
|
58
|
+
"\nThe dtype requested for the unsupported Buffer was: {}."
|
|
59
|
+
)
|
|
60
|
+
raise NumbaTypeError(msg.format(dtype))
|
|
61
|
+
if layout not in self.LAYOUTS:
|
|
62
|
+
raise NumbaValueError("Invalid layout '%s'" % layout)
|
|
63
|
+
self.dtype = unliteral(dtype)
|
|
64
|
+
self.ndim = ndim
|
|
65
|
+
self.layout = layout
|
|
66
|
+
if readonly:
|
|
67
|
+
self.mutable = False
|
|
68
|
+
if name is None:
|
|
69
|
+
type_name = self.__class__.__name__.lower()
|
|
70
|
+
if readonly:
|
|
71
|
+
type_name = "readonly %s" % type_name
|
|
72
|
+
name = "%s(%s, %sd, %s)" % (type_name, dtype, ndim, layout)
|
|
73
|
+
super(Buffer, self).__init__(name)
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def iterator_type(self):
|
|
77
|
+
from .iterators import ArrayIterator
|
|
78
|
+
|
|
79
|
+
return ArrayIterator(self)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def as_array(self):
|
|
83
|
+
return self
|
|
84
|
+
|
|
85
|
+
def copy(self, dtype=None, ndim=None, layout=None):
|
|
86
|
+
if dtype is None:
|
|
87
|
+
dtype = self.dtype
|
|
88
|
+
if ndim is None:
|
|
89
|
+
ndim = self.ndim
|
|
90
|
+
if layout is None:
|
|
91
|
+
layout = self.layout
|
|
92
|
+
return self.__class__(
|
|
93
|
+
dtype=dtype, ndim=ndim, layout=layout, readonly=not self.mutable
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def key(self):
|
|
98
|
+
return self.dtype, self.ndim, self.layout, self.mutable
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
def is_c_contig(self):
|
|
102
|
+
return self.layout == "C" or (self.ndim <= 1 and self.layout in "CF")
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def is_f_contig(self):
|
|
106
|
+
return self.layout == "F" or (self.ndim <= 1 and self.layout in "CF")
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def is_contig(self):
|
|
110
|
+
return self.layout in "CF"
|