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,1209 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
import itertools
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import operator
|
|
8
|
+
|
|
9
|
+
from numba.cuda import types
|
|
10
|
+
from numba.cuda.core import errors
|
|
11
|
+
|
|
12
|
+
from numba.cuda.typing.templates import (
|
|
13
|
+
AttributeTemplate,
|
|
14
|
+
ConcreteTemplate,
|
|
15
|
+
AbstractTemplate,
|
|
16
|
+
Registry,
|
|
17
|
+
signature,
|
|
18
|
+
bound_function,
|
|
19
|
+
make_callable_template,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
from numba.cuda.extending import (
|
|
23
|
+
typeof_impl,
|
|
24
|
+
type_callable,
|
|
25
|
+
core_models,
|
|
26
|
+
register_model,
|
|
27
|
+
make_attribute_wrapper,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
registry = Registry()
|
|
31
|
+
infer = registry.register
|
|
32
|
+
infer_global = registry.register_global
|
|
33
|
+
infer_getattr = registry.register_attr
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@infer_global(print)
|
|
37
|
+
class Print(AbstractTemplate):
|
|
38
|
+
def generic(self, args, kws):
|
|
39
|
+
for a in args:
|
|
40
|
+
sig = self.context.resolve_function_type("print_item", (a,), {})
|
|
41
|
+
if sig is None:
|
|
42
|
+
raise errors.TypingError("Type %s is not printable." % a)
|
|
43
|
+
assert sig.return_type is types.none
|
|
44
|
+
return signature(types.none, *args)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@infer
|
|
48
|
+
class PrintItem(AbstractTemplate):
|
|
49
|
+
key = "print_item"
|
|
50
|
+
|
|
51
|
+
def generic(self, args, kws):
|
|
52
|
+
(arg,) = args
|
|
53
|
+
return signature(types.none, *args)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@infer_global(abs)
|
|
57
|
+
class Abs(ConcreteTemplate):
|
|
58
|
+
int_cases = [signature(ty, ty) for ty in sorted(types.signed_domain)]
|
|
59
|
+
uint_cases = [signature(ty, ty) for ty in sorted(types.unsigned_domain)]
|
|
60
|
+
real_cases = [signature(ty, ty) for ty in sorted(types.real_domain)]
|
|
61
|
+
complex_cases = [
|
|
62
|
+
signature(ty.underlying_float, ty)
|
|
63
|
+
for ty in sorted(types.complex_domain)
|
|
64
|
+
]
|
|
65
|
+
cases = int_cases + uint_cases + real_cases + complex_cases
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@infer_global(slice)
|
|
69
|
+
class Slice(ConcreteTemplate):
|
|
70
|
+
cases = [
|
|
71
|
+
signature(types.slice2_type, types.intp),
|
|
72
|
+
signature(types.slice2_type, types.none),
|
|
73
|
+
signature(types.slice2_type, types.none, types.none),
|
|
74
|
+
signature(types.slice2_type, types.none, types.intp),
|
|
75
|
+
signature(types.slice2_type, types.intp, types.none),
|
|
76
|
+
signature(types.slice2_type, types.intp, types.intp),
|
|
77
|
+
signature(types.slice3_type, types.intp, types.intp, types.intp),
|
|
78
|
+
signature(types.slice3_type, types.none, types.intp, types.intp),
|
|
79
|
+
signature(types.slice3_type, types.intp, types.none, types.intp),
|
|
80
|
+
signature(types.slice3_type, types.intp, types.intp, types.none),
|
|
81
|
+
signature(types.slice3_type, types.intp, types.none, types.none),
|
|
82
|
+
signature(types.slice3_type, types.none, types.intp, types.none),
|
|
83
|
+
signature(types.slice3_type, types.none, types.none, types.intp),
|
|
84
|
+
signature(types.slice3_type, types.none, types.none, types.none),
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@infer_global(range, typing_key=range)
|
|
89
|
+
class Range(ConcreteTemplate):
|
|
90
|
+
cases = [
|
|
91
|
+
signature(types.range_state32_type, types.int32),
|
|
92
|
+
signature(types.range_state32_type, types.int32, types.int32),
|
|
93
|
+
signature(
|
|
94
|
+
types.range_state32_type, types.int32, types.int32, types.int32
|
|
95
|
+
),
|
|
96
|
+
signature(types.range_state64_type, types.int64),
|
|
97
|
+
signature(types.range_state64_type, types.int64, types.int64),
|
|
98
|
+
signature(
|
|
99
|
+
types.range_state64_type, types.int64, types.int64, types.int64
|
|
100
|
+
),
|
|
101
|
+
signature(types.unsigned_range_state64_type, types.uint64),
|
|
102
|
+
signature(
|
|
103
|
+
types.unsigned_range_state64_type, types.uint64, types.uint64
|
|
104
|
+
),
|
|
105
|
+
signature(
|
|
106
|
+
types.unsigned_range_state64_type,
|
|
107
|
+
types.uint64,
|
|
108
|
+
types.uint64,
|
|
109
|
+
types.uint64,
|
|
110
|
+
),
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@infer
|
|
115
|
+
class GetIter(AbstractTemplate):
|
|
116
|
+
key = "getiter"
|
|
117
|
+
|
|
118
|
+
def generic(self, args, kws):
|
|
119
|
+
assert not kws
|
|
120
|
+
[obj] = args
|
|
121
|
+
if isinstance(obj, types.IterableType):
|
|
122
|
+
return signature(obj.iterator_type, obj)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@infer
|
|
126
|
+
class IterNext(AbstractTemplate):
|
|
127
|
+
key = "iternext"
|
|
128
|
+
|
|
129
|
+
def generic(self, args, kws):
|
|
130
|
+
assert not kws
|
|
131
|
+
[it] = args
|
|
132
|
+
if isinstance(it, types.IteratorType):
|
|
133
|
+
return signature(types.Pair(it.yield_type, types.boolean), it)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@infer
|
|
137
|
+
class PairFirst(AbstractTemplate):
|
|
138
|
+
"""
|
|
139
|
+
Given a heterogeneous pair, return the first element.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
key = "pair_first"
|
|
143
|
+
|
|
144
|
+
def generic(self, args, kws):
|
|
145
|
+
assert not kws
|
|
146
|
+
[pair] = args
|
|
147
|
+
if isinstance(pair, types.Pair):
|
|
148
|
+
return signature(pair.first_type, pair)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@infer
|
|
152
|
+
class PairSecond(AbstractTemplate):
|
|
153
|
+
"""
|
|
154
|
+
Given a heterogeneous pair, return the second element.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
key = "pair_second"
|
|
158
|
+
|
|
159
|
+
def generic(self, args, kws):
|
|
160
|
+
assert not kws
|
|
161
|
+
[pair] = args
|
|
162
|
+
if isinstance(pair, types.Pair):
|
|
163
|
+
return signature(pair.second_type, pair)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def choose_result_bitwidth(*inputs):
|
|
167
|
+
return max(types.intp.bitwidth, *(tp.bitwidth for tp in inputs))
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def choose_result_int(*inputs):
|
|
171
|
+
"""
|
|
172
|
+
Choose the integer result type for an operation on integer inputs,
|
|
173
|
+
according to the integer typing NBEP.
|
|
174
|
+
"""
|
|
175
|
+
bitwidth = choose_result_bitwidth(*inputs)
|
|
176
|
+
signed = any(tp.signed for tp in inputs)
|
|
177
|
+
return types.Integer.from_bitwidth(bitwidth, signed)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# The "machine" integer types to take into consideration for operator typing
|
|
181
|
+
# (according to the integer typing NBEP)
|
|
182
|
+
machine_ints = sorted(set((types.intp, types.int64))) + sorted(
|
|
183
|
+
set((types.uintp, types.uint64))
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Explicit integer rules for binary operators; smaller ints will be
|
|
187
|
+
# automatically upcast.
|
|
188
|
+
integer_binop_cases = tuple(
|
|
189
|
+
signature(choose_result_int(op1, op2), op1, op2)
|
|
190
|
+
for op1, op2 in itertools.product(machine_ints, machine_ints)
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class BinOp(ConcreteTemplate):
|
|
195
|
+
cases = list(integer_binop_cases)
|
|
196
|
+
cases += [signature(op, op, op) for op in sorted(types.real_domain)]
|
|
197
|
+
cases += [signature(op, op, op) for op in sorted(types.complex_domain)]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@infer_global(operator.add)
|
|
201
|
+
@infer_global(operator.iadd)
|
|
202
|
+
class BinOpAdd(BinOp):
|
|
203
|
+
pass
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@infer_global(operator.sub)
|
|
207
|
+
@infer_global(operator.isub)
|
|
208
|
+
class BinOpSub(BinOp):
|
|
209
|
+
pass
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@infer_global(operator.mul)
|
|
213
|
+
@infer_global(operator.imul)
|
|
214
|
+
class BinOpMul(BinOp):
|
|
215
|
+
pass
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@infer_global(operator.mod)
|
|
219
|
+
@infer_global(operator.imod)
|
|
220
|
+
class BinOpMod(ConcreteTemplate):
|
|
221
|
+
cases = list(integer_binop_cases)
|
|
222
|
+
cases += [signature(op, op, op) for op in sorted(types.real_domain)]
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@infer_global(operator.truediv)
|
|
226
|
+
@infer_global(operator.itruediv)
|
|
227
|
+
class BinOpTrueDiv(ConcreteTemplate):
|
|
228
|
+
cases = [
|
|
229
|
+
signature(types.float64, op1, op2)
|
|
230
|
+
for op1, op2 in itertools.product(machine_ints, machine_ints)
|
|
231
|
+
]
|
|
232
|
+
cases += [signature(op, op, op) for op in sorted(types.real_domain)]
|
|
233
|
+
cases += [signature(op, op, op) for op in sorted(types.complex_domain)]
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@infer_global(operator.floordiv)
|
|
237
|
+
@infer_global(operator.ifloordiv)
|
|
238
|
+
class BinOpFloorDiv(ConcreteTemplate):
|
|
239
|
+
cases = list(integer_binop_cases)
|
|
240
|
+
cases += [signature(op, op, op) for op in sorted(types.real_domain)]
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@infer_global(divmod)
|
|
244
|
+
class DivMod(ConcreteTemplate):
|
|
245
|
+
_tys = machine_ints + sorted(types.real_domain)
|
|
246
|
+
cases = [signature(types.UniTuple(ty, 2), ty, ty) for ty in _tys]
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@infer_global(operator.pow)
|
|
250
|
+
@infer_global(operator.ipow)
|
|
251
|
+
class BinOpPower(ConcreteTemplate):
|
|
252
|
+
cases = list(integer_binop_cases)
|
|
253
|
+
# Ensure that float32 ** int doesn't go through DP computations
|
|
254
|
+
cases += [
|
|
255
|
+
signature(types.float32, types.float32, op)
|
|
256
|
+
for op in (types.int32, types.int64, types.uint64)
|
|
257
|
+
]
|
|
258
|
+
cases += [
|
|
259
|
+
signature(types.float64, types.float64, op)
|
|
260
|
+
for op in (types.int32, types.int64, types.uint64)
|
|
261
|
+
]
|
|
262
|
+
cases += [signature(op, op, op) for op in sorted(types.real_domain)]
|
|
263
|
+
cases += [signature(op, op, op) for op in sorted(types.complex_domain)]
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@infer_global(pow)
|
|
267
|
+
class PowerBuiltin(BinOpPower):
|
|
268
|
+
# TODO add 3 operand version
|
|
269
|
+
pass
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class BitwiseShiftOperation(ConcreteTemplate):
|
|
273
|
+
# For bitshifts, only the first operand's signedness matters
|
|
274
|
+
# to choose the operation's signedness (the second operand
|
|
275
|
+
# should always be positive but will generally be considered
|
|
276
|
+
# signed anyway, since it's often a constant integer).
|
|
277
|
+
# (also, see issue #1995 for right-shifts)
|
|
278
|
+
|
|
279
|
+
# The RHS type is fixed to 64-bit signed/unsigned ints.
|
|
280
|
+
# The implementation will always cast the operands to the width of the
|
|
281
|
+
# result type, which is the widest between the LHS type and (u)intp.
|
|
282
|
+
cases = [
|
|
283
|
+
signature(max(op, types.intp), op, op2)
|
|
284
|
+
for op in sorted(types.signed_domain)
|
|
285
|
+
for op2 in [types.uint64, types.int64]
|
|
286
|
+
]
|
|
287
|
+
cases += [
|
|
288
|
+
signature(max(op, types.uintp), op, op2)
|
|
289
|
+
for op in sorted(types.unsigned_domain)
|
|
290
|
+
for op2 in [types.uint64, types.int64]
|
|
291
|
+
]
|
|
292
|
+
unsafe_casting = False
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
@infer_global(operator.lshift)
|
|
296
|
+
@infer_global(operator.ilshift)
|
|
297
|
+
class BitwiseLeftShift(BitwiseShiftOperation):
|
|
298
|
+
pass
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
@infer_global(operator.rshift)
|
|
302
|
+
@infer_global(operator.irshift)
|
|
303
|
+
class BitwiseRightShift(BitwiseShiftOperation):
|
|
304
|
+
pass
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class BitwiseLogicOperation(BinOp):
|
|
308
|
+
cases = [signature(types.boolean, types.boolean, types.boolean)]
|
|
309
|
+
cases += list(integer_binop_cases)
|
|
310
|
+
unsafe_casting = False
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
@infer_global(operator.and_)
|
|
314
|
+
@infer_global(operator.iand)
|
|
315
|
+
class BitwiseAnd(BitwiseLogicOperation):
|
|
316
|
+
pass
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
@infer_global(operator.or_)
|
|
320
|
+
@infer_global(operator.ior)
|
|
321
|
+
class BitwiseOr(BitwiseLogicOperation):
|
|
322
|
+
pass
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@infer_global(operator.xor)
|
|
326
|
+
@infer_global(operator.ixor)
|
|
327
|
+
class BitwiseXor(BitwiseLogicOperation):
|
|
328
|
+
pass
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
# Bitwise invert and negate are special: we must not upcast the operand
|
|
332
|
+
# for unsigned numbers, as that would change the result.
|
|
333
|
+
# (i.e. ~np.int8(0) == 255 but ~np.int32(0) == 4294967295).
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
@infer_global(operator.invert)
|
|
337
|
+
class BitwiseInvert(ConcreteTemplate):
|
|
338
|
+
# Note Numba follows the Numpy semantics of returning a bool,
|
|
339
|
+
# while Python returns an int. This makes it consistent with
|
|
340
|
+
# np.invert() and makes array expressions correct.
|
|
341
|
+
cases = [signature(types.boolean, types.boolean)]
|
|
342
|
+
cases += [
|
|
343
|
+
signature(choose_result_int(op), op)
|
|
344
|
+
for op in sorted(types.unsigned_domain)
|
|
345
|
+
]
|
|
346
|
+
cases += [
|
|
347
|
+
signature(choose_result_int(op), op)
|
|
348
|
+
for op in sorted(types.signed_domain)
|
|
349
|
+
]
|
|
350
|
+
|
|
351
|
+
unsafe_casting = False
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class UnaryOp(ConcreteTemplate):
|
|
355
|
+
cases = [
|
|
356
|
+
signature(choose_result_int(op), op)
|
|
357
|
+
for op in sorted(types.unsigned_domain)
|
|
358
|
+
]
|
|
359
|
+
cases += [
|
|
360
|
+
signature(choose_result_int(op), op)
|
|
361
|
+
for op in sorted(types.signed_domain)
|
|
362
|
+
]
|
|
363
|
+
cases += [signature(op, op) for op in sorted(types.real_domain)]
|
|
364
|
+
cases += [signature(op, op) for op in sorted(types.complex_domain)]
|
|
365
|
+
cases += [signature(types.intp, types.boolean)]
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
@infer_global(operator.neg)
|
|
369
|
+
class UnaryNegate(UnaryOp):
|
|
370
|
+
pass
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
@infer_global(operator.pos)
|
|
374
|
+
class UnaryPositive(UnaryOp):
|
|
375
|
+
pass
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
@infer_global(operator.not_)
|
|
379
|
+
class UnaryNot(ConcreteTemplate):
|
|
380
|
+
cases = [signature(types.boolean, types.boolean)]
|
|
381
|
+
cases += [
|
|
382
|
+
signature(types.boolean, op) for op in sorted(types.signed_domain)
|
|
383
|
+
]
|
|
384
|
+
cases += [
|
|
385
|
+
signature(types.boolean, op) for op in sorted(types.unsigned_domain)
|
|
386
|
+
]
|
|
387
|
+
cases += [signature(types.boolean, op) for op in sorted(types.real_domain)]
|
|
388
|
+
cases += [
|
|
389
|
+
signature(types.boolean, op) for op in sorted(types.complex_domain)
|
|
390
|
+
]
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
class OrderedCmpOp(ConcreteTemplate):
|
|
394
|
+
cases = [signature(types.boolean, types.boolean, types.boolean)]
|
|
395
|
+
cases += [
|
|
396
|
+
signature(types.boolean, op, op) for op in sorted(types.signed_domain)
|
|
397
|
+
]
|
|
398
|
+
cases += [
|
|
399
|
+
signature(types.boolean, op, op) for op in sorted(types.unsigned_domain)
|
|
400
|
+
]
|
|
401
|
+
cases += [
|
|
402
|
+
signature(types.boolean, op, op) for op in sorted(types.real_domain)
|
|
403
|
+
]
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
class UnorderedCmpOp(ConcreteTemplate):
|
|
407
|
+
cases = OrderedCmpOp.cases + [
|
|
408
|
+
signature(types.boolean, op, op) for op in sorted(types.complex_domain)
|
|
409
|
+
]
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
@infer_global(operator.lt)
|
|
413
|
+
class CmpOpLt(OrderedCmpOp):
|
|
414
|
+
pass
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
@infer_global(operator.le)
|
|
418
|
+
class CmpOpLe(OrderedCmpOp):
|
|
419
|
+
pass
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
@infer_global(operator.gt)
|
|
423
|
+
class CmpOpGt(OrderedCmpOp):
|
|
424
|
+
pass
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
@infer_global(operator.ge)
|
|
428
|
+
class CmpOpGe(OrderedCmpOp):
|
|
429
|
+
pass
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
# more specific overloads should be registered first
|
|
433
|
+
@infer_global(operator.eq)
|
|
434
|
+
class ConstOpEq(AbstractTemplate):
|
|
435
|
+
def generic(self, args, kws):
|
|
436
|
+
assert not kws
|
|
437
|
+
(arg1, arg2) = args
|
|
438
|
+
if isinstance(arg1, types.Literal) and isinstance(arg2, types.Literal):
|
|
439
|
+
return signature(types.boolean, arg1, arg2)
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
@infer_global(operator.ne)
|
|
443
|
+
class ConstOpNotEq(ConstOpEq):
|
|
444
|
+
pass
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
@infer_global(operator.eq)
|
|
448
|
+
class CmpOpEq(UnorderedCmpOp):
|
|
449
|
+
pass
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
@infer_global(operator.ne)
|
|
453
|
+
class CmpOpNe(UnorderedCmpOp):
|
|
454
|
+
pass
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
class TupleCompare(AbstractTemplate):
|
|
458
|
+
def generic(self, args, kws):
|
|
459
|
+
[lhs, rhs] = args
|
|
460
|
+
if isinstance(lhs, types.BaseTuple) and isinstance(
|
|
461
|
+
rhs, types.BaseTuple
|
|
462
|
+
):
|
|
463
|
+
for u, v in zip(lhs, rhs):
|
|
464
|
+
# Check element-wise comparability
|
|
465
|
+
res = self.context.resolve_function_type(self.key, (u, v), {})
|
|
466
|
+
if res is None:
|
|
467
|
+
break
|
|
468
|
+
else:
|
|
469
|
+
return signature(types.boolean, lhs, rhs)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
@infer_global(operator.eq)
|
|
473
|
+
class TupleEq(TupleCompare):
|
|
474
|
+
pass
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
@infer_global(operator.ne)
|
|
478
|
+
class TupleNe(TupleCompare):
|
|
479
|
+
pass
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
@infer_global(operator.ge)
|
|
483
|
+
class TupleGe(TupleCompare):
|
|
484
|
+
pass
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
@infer_global(operator.gt)
|
|
488
|
+
class TupleGt(TupleCompare):
|
|
489
|
+
pass
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
@infer_global(operator.le)
|
|
493
|
+
class TupleLe(TupleCompare):
|
|
494
|
+
pass
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
@infer_global(operator.lt)
|
|
498
|
+
class TupleLt(TupleCompare):
|
|
499
|
+
pass
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
@infer_global(operator.add)
|
|
503
|
+
class TupleAdd(AbstractTemplate):
|
|
504
|
+
def generic(self, args, kws):
|
|
505
|
+
if len(args) == 2:
|
|
506
|
+
a, b = args
|
|
507
|
+
if (
|
|
508
|
+
isinstance(a, types.BaseTuple)
|
|
509
|
+
and isinstance(b, types.BaseTuple)
|
|
510
|
+
and not isinstance(a, types.BaseNamedTuple)
|
|
511
|
+
and not isinstance(b, types.BaseNamedTuple)
|
|
512
|
+
):
|
|
513
|
+
res = types.BaseTuple.from_types(tuple(a) + tuple(b))
|
|
514
|
+
return signature(res, a, b)
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
class CmpOpIdentity(AbstractTemplate):
|
|
518
|
+
def generic(self, args, kws):
|
|
519
|
+
[lhs, rhs] = args
|
|
520
|
+
return signature(types.boolean, lhs, rhs)
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
@infer_global(operator.is_)
|
|
524
|
+
class CmpOpIs(CmpOpIdentity):
|
|
525
|
+
pass
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
@infer_global(operator.is_not)
|
|
529
|
+
class CmpOpIsNot(CmpOpIdentity):
|
|
530
|
+
pass
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def normalize_1d_index(index):
|
|
534
|
+
"""
|
|
535
|
+
Normalize the *index* type (an integer or slice) for indexing a 1D
|
|
536
|
+
sequence.
|
|
537
|
+
"""
|
|
538
|
+
if isinstance(index, types.SliceType):
|
|
539
|
+
return index
|
|
540
|
+
|
|
541
|
+
elif isinstance(index, types.Integer):
|
|
542
|
+
return types.intp if index.signed else types.uintp
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
@infer_global(operator.getitem)
|
|
546
|
+
class GetItemCPointer(AbstractTemplate):
|
|
547
|
+
def generic(self, args, kws):
|
|
548
|
+
assert not kws
|
|
549
|
+
ptr, idx = args
|
|
550
|
+
if isinstance(ptr, types.CPointer) and isinstance(idx, types.Integer):
|
|
551
|
+
return signature(ptr.dtype, ptr, normalize_1d_index(idx))
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
@infer_global(operator.setitem)
|
|
555
|
+
class SetItemCPointer(AbstractTemplate):
|
|
556
|
+
def generic(self, args, kws):
|
|
557
|
+
assert not kws
|
|
558
|
+
ptr, idx, val = args
|
|
559
|
+
if isinstance(ptr, types.CPointer) and isinstance(idx, types.Integer):
|
|
560
|
+
return signature(
|
|
561
|
+
types.none, ptr, normalize_1d_index(idx), ptr.dtype
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
@infer_global(len)
|
|
566
|
+
class Len(AbstractTemplate):
|
|
567
|
+
def generic(self, args, kws):
|
|
568
|
+
assert not kws
|
|
569
|
+
(val,) = args
|
|
570
|
+
if isinstance(val, (types.Buffer, types.BaseTuple)):
|
|
571
|
+
return signature(types.intp, val)
|
|
572
|
+
elif isinstance(val, (types.RangeType)):
|
|
573
|
+
return signature(val.dtype, val)
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
@infer_global(tuple)
|
|
577
|
+
class TupleConstructor(AbstractTemplate):
|
|
578
|
+
def generic(self, args, kws):
|
|
579
|
+
assert not kws
|
|
580
|
+
# empty tuple case
|
|
581
|
+
if len(args) == 0:
|
|
582
|
+
return signature(types.Tuple(()))
|
|
583
|
+
(val,) = args
|
|
584
|
+
# tuple as input
|
|
585
|
+
if isinstance(val, types.BaseTuple):
|
|
586
|
+
return signature(val, val)
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
@infer_global(operator.contains)
|
|
590
|
+
class Contains(AbstractTemplate):
|
|
591
|
+
def generic(self, args, kws):
|
|
592
|
+
assert not kws
|
|
593
|
+
(seq, val) = args
|
|
594
|
+
|
|
595
|
+
if isinstance(seq, (types.Sequence)):
|
|
596
|
+
return signature(types.boolean, seq, val)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
@infer_global(operator.truth)
|
|
600
|
+
class TupleBool(AbstractTemplate):
|
|
601
|
+
def generic(self, args, kws):
|
|
602
|
+
assert not kws
|
|
603
|
+
(val,) = args
|
|
604
|
+
if isinstance(val, (types.BaseTuple)):
|
|
605
|
+
return signature(types.boolean, val)
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
@infer
|
|
609
|
+
class StaticGetItemTuple(AbstractTemplate):
|
|
610
|
+
key = "static_getitem"
|
|
611
|
+
|
|
612
|
+
def generic(self, args, kws):
|
|
613
|
+
tup, idx = args
|
|
614
|
+
ret = None
|
|
615
|
+
if not isinstance(tup, types.BaseTuple):
|
|
616
|
+
return
|
|
617
|
+
if isinstance(idx, int):
|
|
618
|
+
try:
|
|
619
|
+
ret = tup.types[idx]
|
|
620
|
+
except IndexError:
|
|
621
|
+
raise errors.NumbaIndexError("tuple index out of range")
|
|
622
|
+
elif isinstance(idx, slice):
|
|
623
|
+
ret = types.BaseTuple.from_types(tup.types[idx])
|
|
624
|
+
if ret is not None:
|
|
625
|
+
sig = signature(ret, *args)
|
|
626
|
+
return sig
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
@infer
|
|
630
|
+
class StaticGetItemLiteralList(AbstractTemplate):
|
|
631
|
+
key = "static_getitem"
|
|
632
|
+
|
|
633
|
+
def generic(self, args, kws):
|
|
634
|
+
tup, idx = args
|
|
635
|
+
ret = None
|
|
636
|
+
if not isinstance(tup, types.LiteralList):
|
|
637
|
+
return
|
|
638
|
+
if isinstance(idx, int):
|
|
639
|
+
ret = tup.types[idx]
|
|
640
|
+
if ret is not None:
|
|
641
|
+
sig = signature(ret, *args)
|
|
642
|
+
return sig
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
@infer
|
|
646
|
+
class StaticGetItemLiteralStrKeyDict(AbstractTemplate):
|
|
647
|
+
key = "static_getitem"
|
|
648
|
+
|
|
649
|
+
def generic(self, args, kws):
|
|
650
|
+
tup, idx = args
|
|
651
|
+
ret = None
|
|
652
|
+
if not isinstance(tup, types.LiteralStrKeyDict):
|
|
653
|
+
return
|
|
654
|
+
if isinstance(idx, str):
|
|
655
|
+
if idx in tup.fields:
|
|
656
|
+
lookup = tup.fields.index(idx)
|
|
657
|
+
else:
|
|
658
|
+
raise errors.NumbaKeyError(f"Key '{idx}' is not in dict.")
|
|
659
|
+
ret = tup.types[lookup]
|
|
660
|
+
if ret is not None:
|
|
661
|
+
sig = signature(ret, *args)
|
|
662
|
+
return sig
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
@infer
|
|
666
|
+
class StaticGetItemClass(AbstractTemplate):
|
|
667
|
+
"""This handles the "static_getitem" when a Numba type is subscripted e.g:
|
|
668
|
+
var = typed.List.empty_list(float64[::1, :])
|
|
669
|
+
It only allows this on simple numerical types. Compound types, like
|
|
670
|
+
records, are not supported.
|
|
671
|
+
"""
|
|
672
|
+
|
|
673
|
+
key = "static_getitem"
|
|
674
|
+
|
|
675
|
+
def generic(self, args, kws):
|
|
676
|
+
clazz, idx = args
|
|
677
|
+
if not isinstance(clazz, types.NumberClass):
|
|
678
|
+
return
|
|
679
|
+
ret = clazz.dtype[idx]
|
|
680
|
+
sig = signature(ret, *args)
|
|
681
|
+
return sig
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
# Generic implementation for "not in"
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
@infer
|
|
688
|
+
class GenericNotIn(AbstractTemplate):
|
|
689
|
+
key = "not in"
|
|
690
|
+
|
|
691
|
+
def generic(self, args, kws):
|
|
692
|
+
args = args[::-1]
|
|
693
|
+
sig = self.context.resolve_function_type(operator.contains, args, kws)
|
|
694
|
+
return signature(sig.return_type, *sig.args[::-1])
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
# -------------------------------------------------------------------------------
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
@infer_getattr
|
|
701
|
+
class MemoryViewAttribute(AttributeTemplate):
|
|
702
|
+
key = types.MemoryView
|
|
703
|
+
|
|
704
|
+
def resolve_contiguous(self, buf):
|
|
705
|
+
return types.boolean
|
|
706
|
+
|
|
707
|
+
def resolve_c_contiguous(self, buf):
|
|
708
|
+
return types.boolean
|
|
709
|
+
|
|
710
|
+
def resolve_f_contiguous(self, buf):
|
|
711
|
+
return types.boolean
|
|
712
|
+
|
|
713
|
+
def resolve_itemsize(self, buf):
|
|
714
|
+
return types.intp
|
|
715
|
+
|
|
716
|
+
def resolve_nbytes(self, buf):
|
|
717
|
+
return types.intp
|
|
718
|
+
|
|
719
|
+
def resolve_readonly(self, buf):
|
|
720
|
+
return types.boolean
|
|
721
|
+
|
|
722
|
+
def resolve_shape(self, buf):
|
|
723
|
+
return types.UniTuple(types.intp, buf.ndim)
|
|
724
|
+
|
|
725
|
+
def resolve_strides(self, buf):
|
|
726
|
+
return types.UniTuple(types.intp, buf.ndim)
|
|
727
|
+
|
|
728
|
+
def resolve_ndim(self, buf):
|
|
729
|
+
return types.intp
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
# -------------------------------------------------------------------------------
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
@infer_getattr
|
|
736
|
+
class BooleanAttribute(AttributeTemplate):
|
|
737
|
+
key = types.Boolean
|
|
738
|
+
|
|
739
|
+
def resolve___class__(self, ty):
|
|
740
|
+
return types.NumberClass(ty)
|
|
741
|
+
|
|
742
|
+
@bound_function("number.item")
|
|
743
|
+
def resolve_item(self, ty, args, kws):
|
|
744
|
+
assert not kws
|
|
745
|
+
if not args:
|
|
746
|
+
return signature(ty)
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
@infer_getattr
|
|
750
|
+
class NumberAttribute(AttributeTemplate):
|
|
751
|
+
key = types.Number
|
|
752
|
+
|
|
753
|
+
def resolve___class__(self, ty):
|
|
754
|
+
return types.NumberClass(ty)
|
|
755
|
+
|
|
756
|
+
def resolve_real(self, ty):
|
|
757
|
+
return getattr(ty, "underlying_float", ty)
|
|
758
|
+
|
|
759
|
+
def resolve_imag(self, ty):
|
|
760
|
+
return getattr(ty, "underlying_float", ty)
|
|
761
|
+
|
|
762
|
+
@bound_function("complex.conjugate")
|
|
763
|
+
def resolve_conjugate(self, ty, args, kws):
|
|
764
|
+
assert not args
|
|
765
|
+
assert not kws
|
|
766
|
+
return signature(ty)
|
|
767
|
+
|
|
768
|
+
@bound_function("number.item")
|
|
769
|
+
def resolve_item(self, ty, args, kws):
|
|
770
|
+
assert not kws
|
|
771
|
+
if not args:
|
|
772
|
+
return signature(ty)
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
@infer_getattr
|
|
776
|
+
class NPTimedeltaAttribute(AttributeTemplate):
|
|
777
|
+
key = types.NPTimedelta
|
|
778
|
+
|
|
779
|
+
def resolve___class__(self, ty):
|
|
780
|
+
return types.NumberClass(ty)
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
@infer_getattr
|
|
784
|
+
class NPDatetimeAttribute(AttributeTemplate):
|
|
785
|
+
key = types.NPDatetime
|
|
786
|
+
|
|
787
|
+
def resolve___class__(self, ty):
|
|
788
|
+
return types.NumberClass(ty)
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
@infer_getattr
|
|
792
|
+
class SliceAttribute(AttributeTemplate):
|
|
793
|
+
key = types.SliceType
|
|
794
|
+
|
|
795
|
+
def resolve_start(self, ty):
|
|
796
|
+
return types.intp
|
|
797
|
+
|
|
798
|
+
def resolve_stop(self, ty):
|
|
799
|
+
return types.intp
|
|
800
|
+
|
|
801
|
+
def resolve_step(self, ty):
|
|
802
|
+
return types.intp
|
|
803
|
+
|
|
804
|
+
@bound_function("slice.indices")
|
|
805
|
+
def resolve_indices(self, ty, args, kws):
|
|
806
|
+
assert not kws
|
|
807
|
+
if len(args) != 1:
|
|
808
|
+
raise errors.NumbaTypeError(
|
|
809
|
+
"indices() takes exactly one argument (%d given)" % len(args)
|
|
810
|
+
)
|
|
811
|
+
(typ,) = args
|
|
812
|
+
if not isinstance(typ, types.Integer):
|
|
813
|
+
raise errors.NumbaTypeError(
|
|
814
|
+
"'%s' object cannot be interpreted as an integer" % typ
|
|
815
|
+
)
|
|
816
|
+
return signature(types.UniTuple(types.intp, 3), types.intp)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
# -------------------------------------------------------------------------------
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
@infer_getattr
|
|
823
|
+
class NumberClassAttribute(AttributeTemplate):
|
|
824
|
+
key = types.NumberClass
|
|
825
|
+
|
|
826
|
+
def resolve___call__(self, classty):
|
|
827
|
+
"""
|
|
828
|
+
Resolve a NumPy number class's constructor (e.g. calling numpy.int32(...))
|
|
829
|
+
"""
|
|
830
|
+
ty = classty.instance_type
|
|
831
|
+
|
|
832
|
+
def typer(val):
|
|
833
|
+
if isinstance(val, (types.BaseTuple, types.Sequence)):
|
|
834
|
+
# Array constructor, e.g. np.int32([1, 2])
|
|
835
|
+
fnty = self.context.resolve_value_type(np.array)
|
|
836
|
+
sig = fnty.get_call_type(
|
|
837
|
+
self.context, (val, types.DType(ty)), {}
|
|
838
|
+
)
|
|
839
|
+
return sig.return_type
|
|
840
|
+
elif isinstance(
|
|
841
|
+
val, (types.Number, types.Boolean, types.IntEnumMember)
|
|
842
|
+
):
|
|
843
|
+
# Scalar constructor, e.g. np.int32(42)
|
|
844
|
+
return ty
|
|
845
|
+
elif isinstance(val, (types.NPDatetime, types.NPTimedelta)):
|
|
846
|
+
# Constructor cast from datetime-like, e.g.
|
|
847
|
+
# > np.int64(np.datetime64("2000-01-01"))
|
|
848
|
+
if ty.bitwidth == 64:
|
|
849
|
+
return ty
|
|
850
|
+
else:
|
|
851
|
+
msg = (
|
|
852
|
+
f"Cannot cast {val} to {ty} as {ty} is not 64 bits "
|
|
853
|
+
"wide."
|
|
854
|
+
)
|
|
855
|
+
raise errors.TypingError(msg)
|
|
856
|
+
else:
|
|
857
|
+
if (
|
|
858
|
+
isinstance(val, types.Array)
|
|
859
|
+
and val.ndim == 0
|
|
860
|
+
and val.dtype == ty
|
|
861
|
+
):
|
|
862
|
+
# This is 0d array -> scalar degrading
|
|
863
|
+
return ty
|
|
864
|
+
else:
|
|
865
|
+
# unsupported
|
|
866
|
+
msg = f"Casting {val} to {ty} directly is unsupported."
|
|
867
|
+
if isinstance(val, types.Array):
|
|
868
|
+
# array casts are supported a different way.
|
|
869
|
+
msg += f" Try doing '<array>.astype(np.{ty})' instead"
|
|
870
|
+
raise errors.TypingError(msg)
|
|
871
|
+
|
|
872
|
+
return types.Function(make_callable_template(key=ty, typer=typer))
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
@infer_getattr
|
|
876
|
+
class TypeRefAttribute(AttributeTemplate):
|
|
877
|
+
key = types.TypeRef
|
|
878
|
+
|
|
879
|
+
def resolve___call__(self, classty):
|
|
880
|
+
"""
|
|
881
|
+
Resolve a core number's constructor (e.g. calling int(...))
|
|
882
|
+
|
|
883
|
+
Note:
|
|
884
|
+
|
|
885
|
+
This is needed because of the limitation of the current type-system
|
|
886
|
+
implementation. Specifically, the lack of a higher-order type
|
|
887
|
+
(i.e. passing the ``DictType`` vs ``DictType(key_type, value_type)``)
|
|
888
|
+
"""
|
|
889
|
+
ty = classty.instance_type
|
|
890
|
+
|
|
891
|
+
if isinstance(ty, type) and issubclass(ty, types.Type):
|
|
892
|
+
# Redirect the typing to a:
|
|
893
|
+
# @type_callable(ty)
|
|
894
|
+
# def typeddict_call(context):
|
|
895
|
+
# ...
|
|
896
|
+
# For example, see numba/typed/typeddict.py
|
|
897
|
+
# @type_callable(DictType)
|
|
898
|
+
# def typeddict_call(context):
|
|
899
|
+
class Redirect(object):
|
|
900
|
+
def __init__(self, context):
|
|
901
|
+
self.context = context
|
|
902
|
+
|
|
903
|
+
def __call__(self, *args, **kwargs):
|
|
904
|
+
result = self.context.resolve_function_type(
|
|
905
|
+
ty, args, kwargs
|
|
906
|
+
)
|
|
907
|
+
if hasattr(result, "pysig"):
|
|
908
|
+
self.pysig = result.pysig
|
|
909
|
+
return result
|
|
910
|
+
|
|
911
|
+
return types.Function(
|
|
912
|
+
make_callable_template(key=ty, typer=Redirect(self.context))
|
|
913
|
+
)
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
# ------------------------------------------------------------------------------
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
class MinMaxBase(AbstractTemplate):
|
|
920
|
+
def _unify_minmax(self, tys):
|
|
921
|
+
for ty in tys:
|
|
922
|
+
if not isinstance(
|
|
923
|
+
ty, (types.Number, types.NPDatetime, types.NPTimedelta)
|
|
924
|
+
):
|
|
925
|
+
return
|
|
926
|
+
return self.context.unify_types(*tys)
|
|
927
|
+
|
|
928
|
+
def generic(self, args, kws):
|
|
929
|
+
"""
|
|
930
|
+
Resolve a min() or max() call.
|
|
931
|
+
"""
|
|
932
|
+
assert not kws
|
|
933
|
+
|
|
934
|
+
if not args:
|
|
935
|
+
return
|
|
936
|
+
if len(args) == 1:
|
|
937
|
+
# max(arg) only supported if arg is an iterable
|
|
938
|
+
if isinstance(args[0], types.BaseTuple):
|
|
939
|
+
tys = list(args[0])
|
|
940
|
+
if not tys:
|
|
941
|
+
raise errors.TypingError(
|
|
942
|
+
"%s() argument is an empty tuple" % (self.key.__name__,)
|
|
943
|
+
)
|
|
944
|
+
else:
|
|
945
|
+
return
|
|
946
|
+
else:
|
|
947
|
+
# max(*args)
|
|
948
|
+
tys = args
|
|
949
|
+
retty = self._unify_minmax(tys)
|
|
950
|
+
if retty is not None:
|
|
951
|
+
return signature(retty, *args)
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
@infer_global(max)
|
|
955
|
+
class Max(MinMaxBase):
|
|
956
|
+
pass
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
@infer_global(min)
|
|
960
|
+
class Min(MinMaxBase):
|
|
961
|
+
pass
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
@infer_global(round)
|
|
965
|
+
class Round(ConcreteTemplate):
|
|
966
|
+
cases = [
|
|
967
|
+
signature(types.intp, types.float32),
|
|
968
|
+
signature(types.int64, types.float64),
|
|
969
|
+
signature(types.float32, types.float32, types.intp),
|
|
970
|
+
signature(types.float64, types.float64, types.intp),
|
|
971
|
+
]
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
# ------------------------------------------------------------------------------
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
@infer_global(bool)
|
|
978
|
+
class Bool(AbstractTemplate):
|
|
979
|
+
def generic(self, args, kws):
|
|
980
|
+
assert not kws
|
|
981
|
+
[arg] = args
|
|
982
|
+
if isinstance(arg, (types.Boolean, types.Number)):
|
|
983
|
+
return signature(types.boolean, arg)
|
|
984
|
+
# XXX typing for bool cannot be polymorphic because of the
|
|
985
|
+
# types.Function thing, so we redirect to the operator.truth
|
|
986
|
+
# intrinsic.
|
|
987
|
+
return self.context.resolve_function_type(operator.truth, args, kws)
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
@infer_global(int)
|
|
991
|
+
class Int(AbstractTemplate):
|
|
992
|
+
def generic(self, args, kws):
|
|
993
|
+
if kws:
|
|
994
|
+
raise errors.NumbaAssertionError("kws not supported")
|
|
995
|
+
|
|
996
|
+
[arg] = args
|
|
997
|
+
|
|
998
|
+
if isinstance(arg, types.Integer):
|
|
999
|
+
return signature(arg, arg)
|
|
1000
|
+
if isinstance(arg, (types.Float, types.Boolean)):
|
|
1001
|
+
return signature(types.intp, arg)
|
|
1002
|
+
if isinstance(arg, types.NPDatetime):
|
|
1003
|
+
if arg.unit == "ns":
|
|
1004
|
+
return signature(types.int64, arg)
|
|
1005
|
+
else:
|
|
1006
|
+
raise errors.NumbaTypeError(
|
|
1007
|
+
f"Only datetime64[ns] can be converted, but got datetime64[{arg.unit}]"
|
|
1008
|
+
)
|
|
1009
|
+
if isinstance(arg, types.NPTimedelta):
|
|
1010
|
+
return signature(types.int64, arg)
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
@infer_global(float)
|
|
1014
|
+
class Float(AbstractTemplate):
|
|
1015
|
+
def generic(self, args, kws):
|
|
1016
|
+
assert not kws
|
|
1017
|
+
|
|
1018
|
+
[arg] = args
|
|
1019
|
+
|
|
1020
|
+
if isinstance(arg, types.UnicodeType):
|
|
1021
|
+
msg = "argument must be a string literal"
|
|
1022
|
+
raise errors.RequireLiteralValue(msg)
|
|
1023
|
+
|
|
1024
|
+
if isinstance(arg, types.StringLiteral):
|
|
1025
|
+
return signature(types.float64, arg)
|
|
1026
|
+
|
|
1027
|
+
if arg not in types.number_domain:
|
|
1028
|
+
raise errors.NumbaTypeError("float() only support for numbers")
|
|
1029
|
+
|
|
1030
|
+
if arg in types.complex_domain:
|
|
1031
|
+
raise errors.NumbaTypeError("float() does not support complex")
|
|
1032
|
+
|
|
1033
|
+
if arg in types.integer_domain:
|
|
1034
|
+
return signature(types.float64, arg)
|
|
1035
|
+
|
|
1036
|
+
elif arg in types.real_domain:
|
|
1037
|
+
return signature(arg, arg)
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
@infer_global(complex)
|
|
1041
|
+
class Complex(AbstractTemplate):
|
|
1042
|
+
def generic(self, args, kws):
|
|
1043
|
+
assert not kws
|
|
1044
|
+
|
|
1045
|
+
if len(args) == 1:
|
|
1046
|
+
[arg] = args
|
|
1047
|
+
if arg not in types.number_domain:
|
|
1048
|
+
raise errors.NumbaTypeError(
|
|
1049
|
+
"complex() only support for numbers"
|
|
1050
|
+
)
|
|
1051
|
+
if arg == types.float32:
|
|
1052
|
+
return signature(types.complex64, arg)
|
|
1053
|
+
else:
|
|
1054
|
+
return signature(types.complex128, arg)
|
|
1055
|
+
|
|
1056
|
+
elif len(args) == 2:
|
|
1057
|
+
[real, imag] = args
|
|
1058
|
+
if (
|
|
1059
|
+
real not in types.number_domain
|
|
1060
|
+
or imag not in types.number_domain
|
|
1061
|
+
):
|
|
1062
|
+
raise errors.NumbaTypeError(
|
|
1063
|
+
"complex() only support for numbers"
|
|
1064
|
+
)
|
|
1065
|
+
if real == imag == types.float32:
|
|
1066
|
+
return signature(types.complex64, real, imag)
|
|
1067
|
+
else:
|
|
1068
|
+
return signature(types.complex128, real, imag)
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
# ------------------------------------------------------------------------------
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
@infer_global(enumerate)
|
|
1075
|
+
class Enumerate(AbstractTemplate):
|
|
1076
|
+
def generic(self, args, kws):
|
|
1077
|
+
assert not kws
|
|
1078
|
+
it = args[0]
|
|
1079
|
+
if len(args) > 1 and not isinstance(args[1], types.Integer):
|
|
1080
|
+
raise errors.NumbaTypeError(
|
|
1081
|
+
"Only integers supported as start value in enumerate"
|
|
1082
|
+
)
|
|
1083
|
+
elif len(args) > 2:
|
|
1084
|
+
# let python raise its own error
|
|
1085
|
+
enumerate(*args)
|
|
1086
|
+
|
|
1087
|
+
if isinstance(it, types.IterableType):
|
|
1088
|
+
enumerate_type = types.EnumerateType(it)
|
|
1089
|
+
return signature(enumerate_type, *args)
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
@infer_global(zip)
|
|
1093
|
+
class Zip(AbstractTemplate):
|
|
1094
|
+
def generic(self, args, kws):
|
|
1095
|
+
assert not kws
|
|
1096
|
+
if all(isinstance(it, types.IterableType) for it in args):
|
|
1097
|
+
zip_type = types.ZipType(args)
|
|
1098
|
+
return signature(zip_type, *args)
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
@infer_global(iter)
|
|
1102
|
+
class Iter(AbstractTemplate):
|
|
1103
|
+
def generic(self, args, kws):
|
|
1104
|
+
assert not kws
|
|
1105
|
+
if len(args) == 1:
|
|
1106
|
+
it = args[0]
|
|
1107
|
+
if isinstance(it, types.IterableType):
|
|
1108
|
+
return signature(it.iterator_type, *args)
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
@infer_global(next)
|
|
1112
|
+
class Next(AbstractTemplate):
|
|
1113
|
+
def generic(self, args, kws):
|
|
1114
|
+
assert not kws
|
|
1115
|
+
if len(args) == 1:
|
|
1116
|
+
it = args[0]
|
|
1117
|
+
if isinstance(it, types.IteratorType):
|
|
1118
|
+
return signature(it.yield_type, *args)
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
# ------------------------------------------------------------------------------
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
@infer_global(type)
|
|
1125
|
+
class TypeBuiltin(AbstractTemplate):
|
|
1126
|
+
def generic(self, args, kws):
|
|
1127
|
+
assert not kws
|
|
1128
|
+
if len(args) == 1:
|
|
1129
|
+
# One-argument type() -> return the __class__
|
|
1130
|
+
# Avoid literal types
|
|
1131
|
+
arg = types.unliteral(args[0])
|
|
1132
|
+
classty = self.context.resolve_getattr(arg, "__class__")
|
|
1133
|
+
if classty is not None:
|
|
1134
|
+
return signature(classty, *args)
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
# ------------------------------------------------------------------------------
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
@infer_getattr
|
|
1141
|
+
class OptionalAttribute(AttributeTemplate):
|
|
1142
|
+
key = types.Optional
|
|
1143
|
+
|
|
1144
|
+
def generic_resolve(self, optional, attr):
|
|
1145
|
+
return self.context.resolve_getattr(optional.type, attr)
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
# ------------------------------------------------------------------------------
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
@infer_getattr
|
|
1152
|
+
class DeferredAttribute(AttributeTemplate):
|
|
1153
|
+
key = types.DeferredType
|
|
1154
|
+
|
|
1155
|
+
def generic_resolve(self, deferred, attr):
|
|
1156
|
+
return self.context.resolve_getattr(deferred.get(), attr)
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
# ------------------------------------------------------------------------------
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
class IndexValue(object):
|
|
1163
|
+
"""
|
|
1164
|
+
Index and value
|
|
1165
|
+
"""
|
|
1166
|
+
|
|
1167
|
+
def __init__(self, ind, val):
|
|
1168
|
+
self.index = ind
|
|
1169
|
+
self.value = val
|
|
1170
|
+
|
|
1171
|
+
def __repr__(self):
|
|
1172
|
+
return "IndexValue(%f, %f)" % (self.index, self.value)
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
class IndexValueType(types.Type):
|
|
1176
|
+
def __init__(self, val_typ):
|
|
1177
|
+
self.val_typ = val_typ
|
|
1178
|
+
super(IndexValueType, self).__init__(
|
|
1179
|
+
name="IndexValueType({})".format(val_typ)
|
|
1180
|
+
)
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
@typeof_impl.register(IndexValue)
|
|
1184
|
+
def typeof_index(val, c):
|
|
1185
|
+
val_typ = typeof_impl(val.value, c)
|
|
1186
|
+
return IndexValueType(val_typ)
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
@type_callable(IndexValue)
|
|
1190
|
+
def type_index_value(context):
|
|
1191
|
+
def typer(ind, mval):
|
|
1192
|
+
if ind == types.intp or ind == types.uintp:
|
|
1193
|
+
return IndexValueType(mval)
|
|
1194
|
+
|
|
1195
|
+
return typer
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
@register_model(IndexValueType)
|
|
1199
|
+
class IndexValueModel(core_models.StructModel):
|
|
1200
|
+
def __init__(self, dmm, fe_type):
|
|
1201
|
+
members = [
|
|
1202
|
+
("index", types.intp),
|
|
1203
|
+
("value", fe_type.val_typ),
|
|
1204
|
+
]
|
|
1205
|
+
core_models.StructModel.__init__(self, dmm, fe_type, members)
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
make_attribute_wrapper(IndexValueType, "index", "index")
|
|
1209
|
+
make_attribute_wrapper(IndexValueType, "value", "value")
|