numba-cuda 0.21.1__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _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 +577 -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.cp313-win_amd64.pyd +0 -0
- numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
- numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cp313-win_amd64.pyd +0 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -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.cp313-win_amd64.pyd +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.cp313-win_amd64.pyd +0 -0
- numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -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.cp313-win_amd64.pyd +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 +556 -0
- numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
- numba_cuda/numba/cuda/cudadrv/devicearray.py +951 -0
- numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
- numba_cuda/numba/cuda/cudadrv/driver.py +3222 -0
- numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
- numba_cuda/numba/cuda/cudadrv/dummyarray.py +558 -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 +995 -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 +903 -0
- numba_cuda/numba/cuda/decorators.py +294 -0
- numba_cuda/numba/cuda/descriptor.py +35 -0
- numba_cuda/numba/cuda/device_init.py +158 -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/intrinsic_wrapper.py +41 -0
- numba_cuda/numba/cuda/intrinsics.py +382 -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 +1951 -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 +635 -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 +187 -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 +198 -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 +889 -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 +331 -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 +391 -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.21.1.dist-info/METADATA +109 -0
- numba_cuda-0.21.1.dist-info/RECORD +488 -0
- numba_cuda-0.21.1.dist-info/WHEEL +5 -0
- numba_cuda-0.21.1.dist-info/licenses/LICENSE +26 -0
- numba_cuda-0.21.1.dist-info/licenses/LICENSE.numba +24 -0
- numba_cuda-0.21.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Added for symmetry with the core API
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import uuid
|
|
9
|
+
import weakref
|
|
10
|
+
import collections
|
|
11
|
+
import functools
|
|
12
|
+
|
|
13
|
+
from numba.cuda.core import errors
|
|
14
|
+
from numba.cuda import types, utils, config
|
|
15
|
+
|
|
16
|
+
# # Exported symbols
|
|
17
|
+
from numba.cuda.typing.typeof import typeof_impl # noqa: F401
|
|
18
|
+
from numba.cuda.typing.asnumbatype import as_numba_type # noqa: F401
|
|
19
|
+
from numba.cuda.typing.templates import infer, infer_getattr # noqa: F401
|
|
20
|
+
|
|
21
|
+
from numba.cuda.core.imputils import ( # noqa: F401
|
|
22
|
+
lower_builtin,
|
|
23
|
+
lower_getattr,
|
|
24
|
+
lower_getattr_generic, # noqa: F401
|
|
25
|
+
lower_setattr,
|
|
26
|
+
lower_setattr_generic,
|
|
27
|
+
lower_cast,
|
|
28
|
+
) # noqa: F401
|
|
29
|
+
from numba.cuda.core.pythonapi import box, unbox, reflect, NativeValue # noqa: F401
|
|
30
|
+
from numba.cuda.serialize import ReduceMixin
|
|
31
|
+
from numba.cuda.datamodel import models as core_models # noqa: F401
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
from numba.cuda.models import register_model # noqa: F401
|
|
35
|
+
from numba.cuda import models # noqa: F401
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def make_attribute_wrapper(typeclass, struct_attr, python_attr):
|
|
39
|
+
"""
|
|
40
|
+
Make an automatic attribute wrapper exposing member named *struct_attr*
|
|
41
|
+
as a read-only attribute named *python_attr*.
|
|
42
|
+
The given *typeclass*'s model must be a StructModel subclass.
|
|
43
|
+
|
|
44
|
+
Vendored from numba.cuda.extending with a change to consider the CUDA data
|
|
45
|
+
model manager.
|
|
46
|
+
"""
|
|
47
|
+
from numba.cuda.typing.templates import AttributeTemplate
|
|
48
|
+
from numba.cuda.datamodel import default_manager
|
|
49
|
+
from numba.cuda.datamodel.models import StructModel
|
|
50
|
+
from numba.cuda.core.imputils import impl_ret_borrowed
|
|
51
|
+
from numba.cuda import cgutils
|
|
52
|
+
|
|
53
|
+
from numba.cuda.models import cuda_data_manager
|
|
54
|
+
from numba.cuda.cudadecl import registry as cuda_registry
|
|
55
|
+
from numba.cuda.cudaimpl import registry as cuda_impl_registry
|
|
56
|
+
|
|
57
|
+
data_model_manager = cuda_data_manager.chain(default_manager)
|
|
58
|
+
|
|
59
|
+
if not isinstance(typeclass, type) or not issubclass(typeclass, types.Type):
|
|
60
|
+
raise TypeError(
|
|
61
|
+
"typeclass should be a Type subclass, got %s" % (typeclass,)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def get_attr_fe_type(typ):
|
|
65
|
+
"""
|
|
66
|
+
Get the Numba type of member *struct_attr* in *typ*.
|
|
67
|
+
"""
|
|
68
|
+
model = data_model_manager.lookup(typ)
|
|
69
|
+
if not isinstance(model, StructModel):
|
|
70
|
+
raise TypeError(
|
|
71
|
+
"make_struct_attribute_wrapper() needs a type "
|
|
72
|
+
"with a StructModel, but got %s" % (model,)
|
|
73
|
+
)
|
|
74
|
+
return model.get_member_fe_type(struct_attr)
|
|
75
|
+
|
|
76
|
+
@cuda_registry.register_attr
|
|
77
|
+
class StructAttribute(AttributeTemplate):
|
|
78
|
+
key = typeclass
|
|
79
|
+
|
|
80
|
+
def generic_resolve(self, typ, attr):
|
|
81
|
+
if attr == python_attr:
|
|
82
|
+
return get_attr_fe_type(typ)
|
|
83
|
+
|
|
84
|
+
@cuda_impl_registry.lower_getattr(typeclass, python_attr)
|
|
85
|
+
def struct_getattr_impl(context, builder, typ, val):
|
|
86
|
+
val = cgutils.create_struct_proxy(typ)(context, builder, value=val)
|
|
87
|
+
attrty = get_attr_fe_type(typ)
|
|
88
|
+
attrval = getattr(val, struct_attr)
|
|
89
|
+
return impl_ret_borrowed(context, builder, attrty, attrval)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def type_callable(func):
|
|
93
|
+
"""
|
|
94
|
+
Decorate a function as implementing typing for the callable *func*.
|
|
95
|
+
*func* can be a callable object (probably a global) or a string
|
|
96
|
+
denoting a built-in operation (such 'getitem' or '__array_wrap__')
|
|
97
|
+
"""
|
|
98
|
+
from numba.cuda.typing.templates import (
|
|
99
|
+
CallableTemplate,
|
|
100
|
+
infer,
|
|
101
|
+
infer_global,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if not callable(func) and not isinstance(func, str):
|
|
105
|
+
raise TypeError("`func` should be a function or string")
|
|
106
|
+
try:
|
|
107
|
+
func_name = func.__name__
|
|
108
|
+
except AttributeError:
|
|
109
|
+
func_name = str(func)
|
|
110
|
+
|
|
111
|
+
def decorate(typing_func):
|
|
112
|
+
def generic(self):
|
|
113
|
+
return typing_func(self.context)
|
|
114
|
+
|
|
115
|
+
name = "%s_CallableTemplate" % (func_name,)
|
|
116
|
+
bases = (CallableTemplate,)
|
|
117
|
+
class_dict = dict(key=func, generic=generic)
|
|
118
|
+
template = type(name, bases, class_dict)
|
|
119
|
+
infer(template)
|
|
120
|
+
if callable(func):
|
|
121
|
+
infer_global(func, types.Function(template))
|
|
122
|
+
return typing_func
|
|
123
|
+
|
|
124
|
+
return decorate
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# By default, an *overload* does not have a cpython wrapper because it is not
|
|
128
|
+
# callable from python. It also has `nopython=True`, this has been default since
|
|
129
|
+
# its inception!
|
|
130
|
+
_overload_default_jit_options = {"no_cpython_wrapper": True, "nopython": True}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def overload(
|
|
134
|
+
func,
|
|
135
|
+
jit_options={},
|
|
136
|
+
strict=True,
|
|
137
|
+
inline="never",
|
|
138
|
+
prefer_literal=False,
|
|
139
|
+
target="cuda",
|
|
140
|
+
**kwargs,
|
|
141
|
+
):
|
|
142
|
+
"""
|
|
143
|
+
A decorator marking the decorated function as typing and implementing
|
|
144
|
+
*func* in nopython mode.
|
|
145
|
+
|
|
146
|
+
The decorated function will have the same formal parameters as *func*
|
|
147
|
+
and be passed the Numba types of those parameters. It should return
|
|
148
|
+
a function implementing *func* for the given types.
|
|
149
|
+
|
|
150
|
+
Here is an example implementing len() for tuple types::
|
|
151
|
+
|
|
152
|
+
@overload(len)
|
|
153
|
+
def tuple_len(seq):
|
|
154
|
+
if isinstance(seq, types.BaseTuple):
|
|
155
|
+
n = len(seq)
|
|
156
|
+
|
|
157
|
+
def len_impl(seq):
|
|
158
|
+
return n
|
|
159
|
+
|
|
160
|
+
return len_impl
|
|
161
|
+
|
|
162
|
+
Compiler options can be passed as an dictionary using the **jit_options**
|
|
163
|
+
argument.
|
|
164
|
+
|
|
165
|
+
Overloading strictness (that the typing and implementing signatures match)
|
|
166
|
+
is enforced by the **strict** keyword argument, it is recommended that this
|
|
167
|
+
is set to True (default).
|
|
168
|
+
|
|
169
|
+
To handle a function that accepts imprecise types, an overload
|
|
170
|
+
definition can return 2-tuple of ``(signature, impl_function)``, where
|
|
171
|
+
the ``signature`` is a ``typing.Signature`` specifying the precise
|
|
172
|
+
signature to be used; and ``impl_function`` is the same implementation
|
|
173
|
+
function as in the simple case.
|
|
174
|
+
|
|
175
|
+
If the kwarg inline determines whether the overload is inlined in the
|
|
176
|
+
calling function and can be one of three values:
|
|
177
|
+
* 'never' (default) - the overload is never inlined.
|
|
178
|
+
* 'always' - the overload is always inlined.
|
|
179
|
+
* a function that takes two arguments, both of which are instances of a
|
|
180
|
+
namedtuple with fields:
|
|
181
|
+
* func_ir
|
|
182
|
+
* typemap
|
|
183
|
+
* calltypes
|
|
184
|
+
* signature
|
|
185
|
+
The first argument holds the information from the caller, the second
|
|
186
|
+
holds the information from the callee. The function should return Truthy
|
|
187
|
+
to determine whether to inline, this essentially permitting custom
|
|
188
|
+
inlining rules (typical use might be cost models).
|
|
189
|
+
|
|
190
|
+
The *prefer_literal* option allows users to control if literal types should
|
|
191
|
+
be tried first or last. The default (`False`) is to use non-literal types.
|
|
192
|
+
Implementations that can specialize based on literal values should set the
|
|
193
|
+
option to `True`. Note, this option maybe expanded in the near future to
|
|
194
|
+
allow for more control (e.g. disabling non-literal types).
|
|
195
|
+
|
|
196
|
+
**kwargs prescribes additional arguments passed through to the overload
|
|
197
|
+
template. The only accepted key at present is 'target' which is a string
|
|
198
|
+
corresponding to the target that this overload should be bound against.
|
|
199
|
+
"""
|
|
200
|
+
from numba.cuda.typing.templates import make_overload_template, infer_global
|
|
201
|
+
|
|
202
|
+
# set default options
|
|
203
|
+
opts = _overload_default_jit_options.copy()
|
|
204
|
+
opts.update(jit_options) # let user options override
|
|
205
|
+
|
|
206
|
+
# TODO: abort now if the kwarg 'target' relates to an unregistered target,
|
|
207
|
+
# this requires sorting out the circular imports first.
|
|
208
|
+
|
|
209
|
+
kwargs["target"] = target
|
|
210
|
+
|
|
211
|
+
def decorate(overload_func):
|
|
212
|
+
template = make_overload_template(
|
|
213
|
+
func, overload_func, opts, strict, inline, prefer_literal, **kwargs
|
|
214
|
+
)
|
|
215
|
+
infer(template)
|
|
216
|
+
if callable(func):
|
|
217
|
+
infer_global(func, types.Function(template))
|
|
218
|
+
|
|
219
|
+
# For generic/CPU targets, also register in numba.core registry
|
|
220
|
+
if target in ("generic", "cpu"):
|
|
221
|
+
try:
|
|
222
|
+
from numba.core.typing.templates import (
|
|
223
|
+
make_overload_template as core_make_overload_template,
|
|
224
|
+
infer as core_infer,
|
|
225
|
+
infer_global as core_infer_global,
|
|
226
|
+
)
|
|
227
|
+
from numba.core import types as core_types
|
|
228
|
+
|
|
229
|
+
core_template = core_make_overload_template(
|
|
230
|
+
func,
|
|
231
|
+
overload_func,
|
|
232
|
+
opts,
|
|
233
|
+
strict,
|
|
234
|
+
inline,
|
|
235
|
+
prefer_literal,
|
|
236
|
+
**kwargs,
|
|
237
|
+
)
|
|
238
|
+
core_infer(core_template)
|
|
239
|
+
if callable(func):
|
|
240
|
+
core_infer_global(func, core_types.Function(core_template))
|
|
241
|
+
except ImportError:
|
|
242
|
+
pass
|
|
243
|
+
|
|
244
|
+
return overload_func
|
|
245
|
+
|
|
246
|
+
return decorate
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def register_jitable(*args, **kwargs):
|
|
250
|
+
"""
|
|
251
|
+
Register a regular python function that can be executed by the python
|
|
252
|
+
interpreter and can be compiled into a nopython function when referenced
|
|
253
|
+
by other jit'ed functions. Can be used as::
|
|
254
|
+
|
|
255
|
+
@register_jitable
|
|
256
|
+
def foo(x, y):
|
|
257
|
+
return x + y
|
|
258
|
+
|
|
259
|
+
Or, with compiler options::
|
|
260
|
+
|
|
261
|
+
@register_jitable(_nrt=False) # disable runtime allocation
|
|
262
|
+
def foo(x, y):
|
|
263
|
+
return x + y
|
|
264
|
+
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
def wrap(fn):
|
|
268
|
+
# It is just a wrapper for @overload
|
|
269
|
+
inline = kwargs.pop("inline", "never")
|
|
270
|
+
|
|
271
|
+
@overload(fn, jit_options=kwargs, inline=inline, strict=False)
|
|
272
|
+
def ov_wrap(*args, **kwargs):
|
|
273
|
+
return fn
|
|
274
|
+
|
|
275
|
+
return fn
|
|
276
|
+
|
|
277
|
+
if kwargs:
|
|
278
|
+
return wrap
|
|
279
|
+
else:
|
|
280
|
+
return wrap(*args)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def overload_attribute(typ, attr, target="cuda", **kwargs):
|
|
284
|
+
"""
|
|
285
|
+
A decorator marking the decorated function as typing and implementing
|
|
286
|
+
attribute *attr* for the given Numba type in nopython mode.
|
|
287
|
+
|
|
288
|
+
*kwargs* are passed to the underlying `@overload` call.
|
|
289
|
+
|
|
290
|
+
Here is an example implementing .nbytes for array types::
|
|
291
|
+
|
|
292
|
+
@overload_attribute(types.Array, "nbytes")
|
|
293
|
+
def array_nbytes(arr):
|
|
294
|
+
def get(arr):
|
|
295
|
+
return arr.size * arr.itemsize
|
|
296
|
+
|
|
297
|
+
return get
|
|
298
|
+
"""
|
|
299
|
+
# TODO implement setters
|
|
300
|
+
from numba.cuda.typing.templates import make_overload_attribute_template
|
|
301
|
+
|
|
302
|
+
kwargs["target"] = target
|
|
303
|
+
|
|
304
|
+
def decorate(overload_func):
|
|
305
|
+
template = make_overload_attribute_template(
|
|
306
|
+
typ, attr, overload_func, **kwargs
|
|
307
|
+
)
|
|
308
|
+
infer_getattr(template)
|
|
309
|
+
|
|
310
|
+
# For generic/CPU targets, also register in numba.core registry
|
|
311
|
+
if target in ("generic", "cpu"):
|
|
312
|
+
try:
|
|
313
|
+
from numba.core.typing.templates import (
|
|
314
|
+
make_overload_attribute_template as core_make_overload_attribute_template,
|
|
315
|
+
infer_getattr as core_infer_getattr,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
core_template = core_make_overload_attribute_template(
|
|
319
|
+
typ, attr, overload_func, **kwargs
|
|
320
|
+
)
|
|
321
|
+
core_infer_getattr(core_template)
|
|
322
|
+
except ImportError:
|
|
323
|
+
pass
|
|
324
|
+
|
|
325
|
+
overload(overload_func, **kwargs)(overload_func)
|
|
326
|
+
return overload_func
|
|
327
|
+
|
|
328
|
+
return decorate
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _overload_method_common(typ, attr, **kwargs):
|
|
332
|
+
"""Common code for overload_method and overload_classmethod"""
|
|
333
|
+
from numba.cuda.typing.templates import make_overload_method_template
|
|
334
|
+
|
|
335
|
+
def decorate(overload_func):
|
|
336
|
+
copied_kwargs = kwargs.copy() # avoid mutating parent dict
|
|
337
|
+
template = make_overload_method_template(
|
|
338
|
+
typ,
|
|
339
|
+
attr,
|
|
340
|
+
overload_func,
|
|
341
|
+
inline=copied_kwargs.pop("inline", "never"),
|
|
342
|
+
prefer_literal=copied_kwargs.pop("prefer_literal", False),
|
|
343
|
+
**copied_kwargs,
|
|
344
|
+
)
|
|
345
|
+
infer_getattr(template)
|
|
346
|
+
|
|
347
|
+
# For generic/CPU targets, also register in numba.core registry
|
|
348
|
+
target = kwargs.get("target", "cuda")
|
|
349
|
+
if target in ("generic", "cpu"):
|
|
350
|
+
try:
|
|
351
|
+
from numba.core.typing.templates import (
|
|
352
|
+
make_overload_method_template as core_make_overload_method_template,
|
|
353
|
+
infer_getattr as core_infer_getattr,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
copied_kwargs2 = kwargs.copy()
|
|
357
|
+
core_template = core_make_overload_method_template(
|
|
358
|
+
typ,
|
|
359
|
+
attr,
|
|
360
|
+
overload_func,
|
|
361
|
+
inline=copied_kwargs2.pop("inline", "never"),
|
|
362
|
+
prefer_literal=copied_kwargs2.pop("prefer_literal", False),
|
|
363
|
+
**copied_kwargs2,
|
|
364
|
+
)
|
|
365
|
+
core_infer_getattr(core_template)
|
|
366
|
+
except ImportError:
|
|
367
|
+
pass
|
|
368
|
+
|
|
369
|
+
overload(overload_func, **kwargs)(overload_func)
|
|
370
|
+
return overload_func
|
|
371
|
+
|
|
372
|
+
return decorate
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def overload_method(typ, attr, target="cuda", **kwargs):
|
|
376
|
+
"""
|
|
377
|
+
A decorator marking the decorated function as typing and implementing
|
|
378
|
+
method *attr* for the given Numba type in nopython mode.
|
|
379
|
+
|
|
380
|
+
*kwargs* are passed to the underlying `@overload` call.
|
|
381
|
+
|
|
382
|
+
Here is an example implementing .take() for array types::
|
|
383
|
+
|
|
384
|
+
@overload_method(types.Array, "take")
|
|
385
|
+
def array_take(arr, indices):
|
|
386
|
+
if isinstance(indices, types.Array):
|
|
387
|
+
|
|
388
|
+
def take_impl(arr, indices):
|
|
389
|
+
n = indices.shape[0]
|
|
390
|
+
res = np.empty(n, arr.dtype)
|
|
391
|
+
for i in range(n):
|
|
392
|
+
res[i] = arr[indices[i]]
|
|
393
|
+
return res
|
|
394
|
+
|
|
395
|
+
return take_impl
|
|
396
|
+
"""
|
|
397
|
+
|
|
398
|
+
kwargs["target"] = target
|
|
399
|
+
|
|
400
|
+
return _overload_method_common(typ, attr, **kwargs)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def overload_classmethod(typ, attr, target="cuda", **kwargs):
|
|
404
|
+
"""
|
|
405
|
+
A decorator marking the decorated function as typing and implementing
|
|
406
|
+
classmethod *attr* for the given Numba type in nopython mode.
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
Similar to ``overload_method``.
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
Here is an example implementing a classmethod on the Array type to call
|
|
413
|
+
``np.arange()``::
|
|
414
|
+
|
|
415
|
+
@overload_classmethod(types.Array, "make")
|
|
416
|
+
def ov_make(cls, nitems):
|
|
417
|
+
def impl(cls, nitems):
|
|
418
|
+
return np.arange(nitems)
|
|
419
|
+
|
|
420
|
+
return impl
|
|
421
|
+
|
|
422
|
+
The above code will allow the following to work in jit-compiled code::
|
|
423
|
+
|
|
424
|
+
@njit
|
|
425
|
+
def foo(n):
|
|
426
|
+
return types.Array.make(n)
|
|
427
|
+
"""
|
|
428
|
+
|
|
429
|
+
kwargs["target"] = target
|
|
430
|
+
|
|
431
|
+
return _overload_method_common(types.TypeRef(typ), attr, **kwargs)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class _Intrinsic(ReduceMixin):
|
|
435
|
+
"""
|
|
436
|
+
Dummy callable for intrinsic
|
|
437
|
+
"""
|
|
438
|
+
|
|
439
|
+
_memo = weakref.WeakValueDictionary()
|
|
440
|
+
# hold refs to last N functions deserialized, retaining them in _memo
|
|
441
|
+
# regardless of whether there is another reference
|
|
442
|
+
_recent = collections.deque(maxlen=config.FUNCTION_CACHE_SIZE)
|
|
443
|
+
|
|
444
|
+
__uuid = None
|
|
445
|
+
|
|
446
|
+
def __init__(self, name, defn, prefer_literal=False, **kwargs):
|
|
447
|
+
self._ctor_kwargs = kwargs
|
|
448
|
+
self._name = name
|
|
449
|
+
self._defn = defn
|
|
450
|
+
self._prefer_literal = prefer_literal
|
|
451
|
+
functools.update_wrapper(self, defn)
|
|
452
|
+
|
|
453
|
+
@property
|
|
454
|
+
def _uuid(self):
|
|
455
|
+
"""
|
|
456
|
+
An instance-specific UUID, to avoid multiple deserializations of
|
|
457
|
+
a given instance.
|
|
458
|
+
|
|
459
|
+
Note this is lazily-generated, for performance reasons.
|
|
460
|
+
"""
|
|
461
|
+
u = self.__uuid
|
|
462
|
+
if u is None:
|
|
463
|
+
u = str(uuid.uuid1())
|
|
464
|
+
self._set_uuid(u)
|
|
465
|
+
return u
|
|
466
|
+
|
|
467
|
+
def _set_uuid(self, u):
|
|
468
|
+
assert self.__uuid is None
|
|
469
|
+
self.__uuid = u
|
|
470
|
+
self._memo[u] = self
|
|
471
|
+
self._recent.append(self)
|
|
472
|
+
|
|
473
|
+
def _register(self):
|
|
474
|
+
# _ctor_kwargs
|
|
475
|
+
from numba.cuda.typing.templates import (
|
|
476
|
+
make_intrinsic_template,
|
|
477
|
+
infer_global,
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
template = make_intrinsic_template(
|
|
481
|
+
self,
|
|
482
|
+
self._defn,
|
|
483
|
+
self._name,
|
|
484
|
+
prefer_literal=self._prefer_literal,
|
|
485
|
+
kwargs=self._ctor_kwargs,
|
|
486
|
+
)
|
|
487
|
+
infer(template)
|
|
488
|
+
infer_global(self, types.Function(template))
|
|
489
|
+
|
|
490
|
+
def __call__(self, *args, **kwargs):
|
|
491
|
+
"""
|
|
492
|
+
This is only defined to pretend to be a callable from CPython.
|
|
493
|
+
"""
|
|
494
|
+
msg = "{0} is not usable in pure-python".format(self)
|
|
495
|
+
raise NotImplementedError(msg)
|
|
496
|
+
|
|
497
|
+
def __repr__(self):
|
|
498
|
+
return "<intrinsic {0}>".format(self._name)
|
|
499
|
+
|
|
500
|
+
def __deepcopy__(self, memo):
|
|
501
|
+
# NOTE: Intrinsic are immutable and we don't need to copy.
|
|
502
|
+
# This is triggered from deepcopy of statements.
|
|
503
|
+
return self
|
|
504
|
+
|
|
505
|
+
def _reduce_states(self):
|
|
506
|
+
"""
|
|
507
|
+
NOTE: part of ReduceMixin protocol
|
|
508
|
+
"""
|
|
509
|
+
return dict(uuid=self._uuid, name=self._name, defn=self._defn)
|
|
510
|
+
|
|
511
|
+
@classmethod
|
|
512
|
+
def _rebuild(cls, uuid, name, defn):
|
|
513
|
+
"""
|
|
514
|
+
NOTE: part of ReduceMixin protocol
|
|
515
|
+
"""
|
|
516
|
+
try:
|
|
517
|
+
return cls._memo[uuid]
|
|
518
|
+
except KeyError:
|
|
519
|
+
llc = cls(name=name, defn=defn)
|
|
520
|
+
llc._register()
|
|
521
|
+
llc._set_uuid(uuid)
|
|
522
|
+
return llc
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
def _intrinsic(*args, **kwargs):
|
|
526
|
+
"""
|
|
527
|
+
A decorator marking the decorated function as typing and implementing
|
|
528
|
+
*func* in nopython mode using the llvmlite IRBuilder API. This is an escape
|
|
529
|
+
hatch for expert users to build custom LLVM IR that will be inlined to
|
|
530
|
+
the caller.
|
|
531
|
+
|
|
532
|
+
The first argument to *func* is the typing context. The rest of the
|
|
533
|
+
arguments corresponds to the type of arguments of the decorated function.
|
|
534
|
+
These arguments are also used as the formal argument of the decorated
|
|
535
|
+
function. If *func* has the signature ``foo(typing_context, arg0, arg1)``,
|
|
536
|
+
the decorated function will have the signature ``foo(arg0, arg1)``.
|
|
537
|
+
|
|
538
|
+
The return values of *func* should be a 2-tuple of expected type signature,
|
|
539
|
+
and a code-generation function that will passed to ``lower_builtin``.
|
|
540
|
+
For unsupported operation, return None.
|
|
541
|
+
|
|
542
|
+
Here is an example implementing a ``cast_int_to_byte_ptr`` that cast
|
|
543
|
+
any integer to a byte pointer::
|
|
544
|
+
|
|
545
|
+
@intrinsic
|
|
546
|
+
def cast_int_to_byte_ptr(typingctx, src):
|
|
547
|
+
# check for accepted types
|
|
548
|
+
if isinstance(src, types.Integer):
|
|
549
|
+
# create the expected type signature
|
|
550
|
+
result_type = types.CPointer(types.uint8)
|
|
551
|
+
sig = result_type(types.uintp)
|
|
552
|
+
|
|
553
|
+
# defines the custom code generation
|
|
554
|
+
def codegen(context, builder, signature, args):
|
|
555
|
+
# llvm IRBuilder code here
|
|
556
|
+
[src] = args
|
|
557
|
+
rtype = signature.return_type
|
|
558
|
+
llrtype = context.get_value_type(rtype)
|
|
559
|
+
return builder.inttoptr(src, llrtype)
|
|
560
|
+
|
|
561
|
+
return sig, codegen
|
|
562
|
+
"""
|
|
563
|
+
|
|
564
|
+
# Make inner function for the actual work
|
|
565
|
+
def _intrinsic(func):
|
|
566
|
+
name = getattr(func, "__name__", str(func))
|
|
567
|
+
llc = _Intrinsic(name, func, **kwargs)
|
|
568
|
+
llc._register()
|
|
569
|
+
return llc
|
|
570
|
+
|
|
571
|
+
if not kwargs:
|
|
572
|
+
# No option is given
|
|
573
|
+
return _intrinsic(*args)
|
|
574
|
+
else:
|
|
575
|
+
# options are given, create a new callable to recv the
|
|
576
|
+
# definition function
|
|
577
|
+
def wrapper(func):
|
|
578
|
+
return _intrinsic(func)
|
|
579
|
+
|
|
580
|
+
return wrapper
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
intrinsic = _intrinsic(target="cuda")
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
def sentry_literal_args(pysig, literal_args, args, kwargs):
|
|
587
|
+
"""Ensures that the given argument types (in *args* and *kwargs*) are
|
|
588
|
+
literally typed for a function with the python signature *pysig* and the
|
|
589
|
+
list of literal argument names in *literal_args*.
|
|
590
|
+
|
|
591
|
+
Alternatively, this is the same as::
|
|
592
|
+
|
|
593
|
+
SentryLiteralArgs(literal_args).for_pysig(pysig).bind(*args, **kwargs)
|
|
594
|
+
"""
|
|
595
|
+
boundargs = pysig.bind(*args, **kwargs)
|
|
596
|
+
|
|
597
|
+
# Find literal argument positions and whether it is satisfied.
|
|
598
|
+
request_pos = set()
|
|
599
|
+
missing = False
|
|
600
|
+
for i, (k, v) in enumerate(boundargs.arguments.items()):
|
|
601
|
+
if k in literal_args:
|
|
602
|
+
request_pos.add(i)
|
|
603
|
+
if not isinstance(v, types.Literal):
|
|
604
|
+
missing = True
|
|
605
|
+
if missing:
|
|
606
|
+
# Yes, there are missing required literal arguments
|
|
607
|
+
e = errors.ForceLiteralArg(request_pos)
|
|
608
|
+
|
|
609
|
+
# A helper function to fold arguments
|
|
610
|
+
def folded(args, kwargs):
|
|
611
|
+
out = pysig.bind(*args, **kwargs).arguments.values()
|
|
612
|
+
return tuple(out)
|
|
613
|
+
|
|
614
|
+
raise e.bind_fold_arguments(folded)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
class SentryLiteralArgs(
|
|
618
|
+
collections.namedtuple("_SentryLiteralArgs", ["literal_args"])
|
|
619
|
+
):
|
|
620
|
+
"""
|
|
621
|
+
Parameters
|
|
622
|
+
----------
|
|
623
|
+
literal_args : Sequence[str]
|
|
624
|
+
A sequence of names for literal arguments
|
|
625
|
+
|
|
626
|
+
Examples
|
|
627
|
+
--------
|
|
628
|
+
|
|
629
|
+
The following line:
|
|
630
|
+
|
|
631
|
+
>>> SentryLiteralArgs(literal_args).for_pysig(pysig).bind(*args, **kwargs)
|
|
632
|
+
|
|
633
|
+
is equivalent to:
|
|
634
|
+
|
|
635
|
+
>>> sentry_literal_args(pysig, literal_args, args, kwargs)
|
|
636
|
+
"""
|
|
637
|
+
|
|
638
|
+
def for_function(self, func):
|
|
639
|
+
"""Bind the sentry to the signature of *func*.
|
|
640
|
+
|
|
641
|
+
Parameters
|
|
642
|
+
----------
|
|
643
|
+
func : Function
|
|
644
|
+
A python function.
|
|
645
|
+
|
|
646
|
+
Returns
|
|
647
|
+
-------
|
|
648
|
+
obj : BoundLiteralArgs
|
|
649
|
+
"""
|
|
650
|
+
return self.for_pysig(utils.pysignature(func))
|
|
651
|
+
|
|
652
|
+
def for_pysig(self, pysig):
|
|
653
|
+
"""Bind the sentry to the given signature *pysig*.
|
|
654
|
+
|
|
655
|
+
Parameters
|
|
656
|
+
----------
|
|
657
|
+
pysig : inspect.Signature
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
Returns
|
|
661
|
+
-------
|
|
662
|
+
obj : BoundLiteralArgs
|
|
663
|
+
"""
|
|
664
|
+
return BoundLiteralArgs(
|
|
665
|
+
pysig=pysig,
|
|
666
|
+
literal_args=self.literal_args,
|
|
667
|
+
)
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
class BoundLiteralArgs(
|
|
671
|
+
collections.namedtuple("BoundLiteralArgs", ["pysig", "literal_args"])
|
|
672
|
+
):
|
|
673
|
+
"""
|
|
674
|
+
This class is usually created by SentryLiteralArgs.
|
|
675
|
+
"""
|
|
676
|
+
|
|
677
|
+
def bind(self, *args, **kwargs):
|
|
678
|
+
"""Bind to argument types."""
|
|
679
|
+
return sentry_literal_args(
|
|
680
|
+
self.pysig,
|
|
681
|
+
self.literal_args,
|
|
682
|
+
args,
|
|
683
|
+
kwargs,
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
def is_jitted(function):
|
|
688
|
+
"""Returns True if a function is wrapped by cuda.jit
|
|
689
|
+
|
|
690
|
+
The purpose of this function is to provide a means to check if a function is
|
|
691
|
+
already JIT decorated.
|
|
692
|
+
"""
|
|
693
|
+
|
|
694
|
+
# don't want to export this so import locally
|
|
695
|
+
from numba.cuda.dispatcher import CUDADispatcher
|
|
696
|
+
|
|
697
|
+
return isinstance(function, CUDADispatcher)
|