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,456 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Implementation of tuple objects
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import operator
|
|
9
|
+
|
|
10
|
+
from numba.cuda.core.imputils import (
|
|
11
|
+
Registry,
|
|
12
|
+
iternext_impl,
|
|
13
|
+
impl_ret_borrowed,
|
|
14
|
+
impl_ret_untracked,
|
|
15
|
+
RefType,
|
|
16
|
+
)
|
|
17
|
+
from numba.cuda import typing, types
|
|
18
|
+
from numba.cuda import cgutils
|
|
19
|
+
from numba.cuda.extending import overload_method, overload
|
|
20
|
+
|
|
21
|
+
registry = Registry("tupleobj")
|
|
22
|
+
lower = registry.lower
|
|
23
|
+
lower_cast = registry.lower_cast
|
|
24
|
+
lower_constant = registry.lower_constant
|
|
25
|
+
lower_getattr_generic = registry.lower_getattr_generic
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@lower(types.NamedTupleClass, types.VarArg(types.Any))
|
|
29
|
+
def namedtuple_constructor(context, builder, sig, args):
|
|
30
|
+
# A namedtuple has the same representation as a regular tuple
|
|
31
|
+
# the arguments need casting (lower_cast) from the types in the ctor args
|
|
32
|
+
# to those in the ctor return type, this is to handle cases such as a
|
|
33
|
+
# literal present in the args, but a type present in the return type.
|
|
34
|
+
newargs = []
|
|
35
|
+
for i, arg in enumerate(args):
|
|
36
|
+
casted = context.cast(builder, arg, sig.args[i], sig.return_type[i])
|
|
37
|
+
newargs.append(casted)
|
|
38
|
+
res = context.make_tuple(builder, sig.return_type, tuple(newargs))
|
|
39
|
+
# The tuple's contents are borrowed
|
|
40
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@lower(operator.add, types.BaseTuple, types.BaseTuple)
|
|
44
|
+
def tuple_add(context, builder, sig, args):
|
|
45
|
+
left, right = [cgutils.unpack_tuple(builder, x) for x in args]
|
|
46
|
+
res = context.make_tuple(builder, sig.return_type, left + right)
|
|
47
|
+
# The tuple's contents are borrowed
|
|
48
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def tuple_cmp_ordered(context, builder, op, sig, args):
|
|
52
|
+
tu, tv = sig.args
|
|
53
|
+
u, v = args
|
|
54
|
+
res = cgutils.alloca_once_value(builder, cgutils.true_bit)
|
|
55
|
+
bbend = builder.append_basic_block("cmp_end")
|
|
56
|
+
for i, (ta, tb) in enumerate(zip(tu.types, tv.types)):
|
|
57
|
+
a = builder.extract_value(u, i)
|
|
58
|
+
b = builder.extract_value(v, i)
|
|
59
|
+
not_equal = context.generic_compare(
|
|
60
|
+
builder, operator.ne, (ta, tb), (a, b)
|
|
61
|
+
)
|
|
62
|
+
with builder.if_then(not_equal):
|
|
63
|
+
pred = context.generic_compare(builder, op, (ta, tb), (a, b))
|
|
64
|
+
builder.store(pred, res)
|
|
65
|
+
builder.branch(bbend)
|
|
66
|
+
# Everything matched equal => compare lengths
|
|
67
|
+
len_compare = op(len(tu.types), len(tv.types))
|
|
68
|
+
pred = context.get_constant(types.boolean, len_compare)
|
|
69
|
+
builder.store(pred, res)
|
|
70
|
+
builder.branch(bbend)
|
|
71
|
+
builder.position_at_end(bbend)
|
|
72
|
+
return builder.load(res)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@lower(operator.eq, types.BaseTuple, types.BaseTuple)
|
|
76
|
+
def tuple_eq(context, builder, sig, args):
|
|
77
|
+
tu, tv = sig.args
|
|
78
|
+
u, v = args
|
|
79
|
+
if len(tu.types) != len(tv.types):
|
|
80
|
+
res = context.get_constant(types.boolean, False)
|
|
81
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
82
|
+
res = context.get_constant(types.boolean, True)
|
|
83
|
+
for i, (ta, tb) in enumerate(zip(tu.types, tv.types)):
|
|
84
|
+
a = builder.extract_value(u, i)
|
|
85
|
+
b = builder.extract_value(v, i)
|
|
86
|
+
pred = context.generic_compare(builder, operator.eq, (ta, tb), (a, b))
|
|
87
|
+
res = builder.and_(res, pred)
|
|
88
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@lower(operator.ne, types.BaseTuple, types.BaseTuple)
|
|
92
|
+
def tuple_ne(context, builder, sig, args):
|
|
93
|
+
res = builder.not_(tuple_eq(context, builder, sig, args))
|
|
94
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@lower(operator.lt, types.BaseTuple, types.BaseTuple)
|
|
98
|
+
def tuple_lt(context, builder, sig, args):
|
|
99
|
+
res = tuple_cmp_ordered(context, builder, operator.lt, sig, args)
|
|
100
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@lower(operator.le, types.BaseTuple, types.BaseTuple)
|
|
104
|
+
def tuple_le(context, builder, sig, args):
|
|
105
|
+
res = tuple_cmp_ordered(context, builder, operator.le, sig, args)
|
|
106
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@lower(operator.gt, types.BaseTuple, types.BaseTuple)
|
|
110
|
+
def tuple_gt(context, builder, sig, args):
|
|
111
|
+
res = tuple_cmp_ordered(context, builder, operator.gt, sig, args)
|
|
112
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@lower(operator.ge, types.BaseTuple, types.BaseTuple)
|
|
116
|
+
def tuple_ge(context, builder, sig, args):
|
|
117
|
+
res = tuple_cmp_ordered(context, builder, operator.ge, sig, args)
|
|
118
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# for hashing see hashing.py
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@lower_getattr_generic(types.BaseNamedTuple)
|
|
125
|
+
def namedtuple_getattr(context, builder, typ, value, attr):
|
|
126
|
+
"""
|
|
127
|
+
Fetch a namedtuple's field.
|
|
128
|
+
"""
|
|
129
|
+
index = typ.fields.index(attr)
|
|
130
|
+
res = builder.extract_value(value, index)
|
|
131
|
+
return impl_ret_borrowed(context, builder, typ[index], res)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@lower_constant(types.UniTuple)
|
|
135
|
+
@lower_constant(types.NamedUniTuple)
|
|
136
|
+
def unituple_constant(context, builder, ty, pyval): # noqa: F811
|
|
137
|
+
"""
|
|
138
|
+
Create a homogeneous tuple constant.
|
|
139
|
+
"""
|
|
140
|
+
consts = [context.get_constant_generic(builder, ty.dtype, v) for v in pyval]
|
|
141
|
+
return impl_ret_borrowed(
|
|
142
|
+
context,
|
|
143
|
+
builder,
|
|
144
|
+
ty,
|
|
145
|
+
cgutils.pack_array(builder, consts),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@lower_constant(types.Tuple)
|
|
150
|
+
@lower_constant(types.NamedTuple)
|
|
151
|
+
def unituple_constant(context, builder, ty, pyval): # noqa: F811
|
|
152
|
+
"""
|
|
153
|
+
Create a heterogeneous tuple constant.
|
|
154
|
+
"""
|
|
155
|
+
consts = [
|
|
156
|
+
context.get_constant_generic(builder, ty.types[i], v)
|
|
157
|
+
for i, v in enumerate(pyval)
|
|
158
|
+
]
|
|
159
|
+
return impl_ret_borrowed(
|
|
160
|
+
context,
|
|
161
|
+
builder,
|
|
162
|
+
ty,
|
|
163
|
+
cgutils.pack_struct(builder, consts),
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# ------------------------------------------------------------------------------
|
|
168
|
+
# Tuple iterators
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@lower("getiter", types.UniTuple)
|
|
172
|
+
@lower("getiter", types.NamedUniTuple)
|
|
173
|
+
def getiter_unituple(context, builder, sig, args):
|
|
174
|
+
[tupty] = sig.args
|
|
175
|
+
[tup] = args
|
|
176
|
+
|
|
177
|
+
iterval = context.make_helper(builder, types.UniTupleIter(tupty))
|
|
178
|
+
|
|
179
|
+
index0 = context.get_constant(types.intp, 0)
|
|
180
|
+
indexptr = cgutils.alloca_once(builder, index0.type)
|
|
181
|
+
builder.store(index0, indexptr)
|
|
182
|
+
|
|
183
|
+
iterval.index = indexptr
|
|
184
|
+
iterval.tuple = tup
|
|
185
|
+
|
|
186
|
+
res = iterval._getvalue()
|
|
187
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@lower("iternext", types.UniTupleIter)
|
|
191
|
+
@iternext_impl(RefType.BORROWED)
|
|
192
|
+
def iternext_unituple(context, builder, sig, args, result):
|
|
193
|
+
[tupiterty] = sig.args
|
|
194
|
+
[tupiter] = args
|
|
195
|
+
|
|
196
|
+
iterval = context.make_helper(builder, tupiterty, value=tupiter)
|
|
197
|
+
|
|
198
|
+
tup = iterval.tuple
|
|
199
|
+
idxptr = iterval.index
|
|
200
|
+
idx = builder.load(idxptr)
|
|
201
|
+
count = context.get_constant(types.intp, tupiterty.container.count)
|
|
202
|
+
|
|
203
|
+
is_valid = builder.icmp_signed("<", idx, count)
|
|
204
|
+
result.set_valid(is_valid)
|
|
205
|
+
|
|
206
|
+
with builder.if_then(is_valid):
|
|
207
|
+
getitem_sig = typing.signature(
|
|
208
|
+
tupiterty.container.dtype, tupiterty.container, types.intp
|
|
209
|
+
)
|
|
210
|
+
getitem_out = getitem_unituple(
|
|
211
|
+
context, builder, getitem_sig, [tup, idx]
|
|
212
|
+
)
|
|
213
|
+
# As a iternext_impl function, this will incref the yieled value.
|
|
214
|
+
# We need to release the new reference from getitem_unituple.
|
|
215
|
+
if context.enable_nrt:
|
|
216
|
+
context.nrt.decref(builder, tupiterty.container.dtype, getitem_out)
|
|
217
|
+
result.yield_(getitem_out)
|
|
218
|
+
nidx = builder.add(idx, context.get_constant(types.intp, 1))
|
|
219
|
+
builder.store(nidx, iterval.index)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@overload(operator.getitem)
|
|
223
|
+
def getitem_literal_idx(tup, idx):
|
|
224
|
+
"""
|
|
225
|
+
Overloads BaseTuple getitem to cover cases where constant
|
|
226
|
+
inference and RewriteConstGetitems cannot replace it
|
|
227
|
+
with a static_getitem.
|
|
228
|
+
"""
|
|
229
|
+
if not (
|
|
230
|
+
isinstance(tup, types.BaseTuple)
|
|
231
|
+
and isinstance(idx, types.IntegerLiteral)
|
|
232
|
+
):
|
|
233
|
+
return None
|
|
234
|
+
|
|
235
|
+
idx_val = idx.literal_value
|
|
236
|
+
|
|
237
|
+
def getitem_literal_idx_impl(tup, idx):
|
|
238
|
+
return tup[idx_val]
|
|
239
|
+
|
|
240
|
+
return getitem_literal_idx_impl
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@lower("typed_getitem", types.BaseTuple, types.Any)
|
|
244
|
+
def getitem_typed(context, builder, sig, args):
|
|
245
|
+
tupty, _ = sig.args
|
|
246
|
+
tup, idx = args
|
|
247
|
+
errmsg_oob = ("tuple index out of range",)
|
|
248
|
+
|
|
249
|
+
if len(tupty) == 0:
|
|
250
|
+
# Empty tuple.
|
|
251
|
+
|
|
252
|
+
# Always branch and raise IndexError
|
|
253
|
+
with builder.if_then(cgutils.true_bit):
|
|
254
|
+
context.call_conv.return_user_exc(builder, IndexError, errmsg_oob)
|
|
255
|
+
# This is unreachable in runtime,
|
|
256
|
+
# but it exists to not terminate the current basicblock.
|
|
257
|
+
res = context.get_constant_null(sig.return_type)
|
|
258
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
259
|
+
else:
|
|
260
|
+
# The tuple is not empty
|
|
261
|
+
|
|
262
|
+
bbelse = builder.append_basic_block("typed_switch.else")
|
|
263
|
+
bbend = builder.append_basic_block("typed_switch.end")
|
|
264
|
+
switch = builder.switch(idx, bbelse)
|
|
265
|
+
|
|
266
|
+
with builder.goto_block(bbelse):
|
|
267
|
+
context.call_conv.return_user_exc(builder, IndexError, errmsg_oob)
|
|
268
|
+
|
|
269
|
+
lrtty = context.get_value_type(sig.return_type)
|
|
270
|
+
voidptrty = context.get_value_type(types.voidptr)
|
|
271
|
+
with builder.goto_block(bbend):
|
|
272
|
+
phinode = builder.phi(voidptrty)
|
|
273
|
+
|
|
274
|
+
for i in range(tupty.count):
|
|
275
|
+
ki = context.get_constant(types.intp, i)
|
|
276
|
+
bbi = builder.append_basic_block("typed_switch.%d" % i)
|
|
277
|
+
switch.add_case(ki, bbi)
|
|
278
|
+
# handle negative indexing, create case (-tuple.count + i) to
|
|
279
|
+
# reference same block as i
|
|
280
|
+
kin = context.get_constant(types.intp, -tupty.count + i)
|
|
281
|
+
switch.add_case(kin, bbi)
|
|
282
|
+
with builder.goto_block(bbi):
|
|
283
|
+
value = builder.extract_value(tup, i)
|
|
284
|
+
# Dragon warning...
|
|
285
|
+
# The fact the code has made it this far suggests that type
|
|
286
|
+
# inference decided whatever was being done with the item pulled
|
|
287
|
+
# from the tuple was legitimate, it is not the job of lowering
|
|
288
|
+
# to argue about that. However, here lies a problem, the tuple
|
|
289
|
+
# lowering is implemented as a switch table with each case
|
|
290
|
+
# writing to a phi node slot that is returned. The type of this
|
|
291
|
+
# phi node slot needs to be "correct" for the current type but
|
|
292
|
+
# it also needs to survive stores being made to it from the
|
|
293
|
+
# other cases that will in effect never run. To do this a stack
|
|
294
|
+
# slot is made for each case for the specific type and then cast
|
|
295
|
+
# to a void pointer type, this is then added as an incoming on
|
|
296
|
+
# the phi node, at the end of the switch the phi node is then
|
|
297
|
+
# cast back to the required return type for this typed_getitem.
|
|
298
|
+
# The only further complication is that if the value is not a
|
|
299
|
+
# pointer then the void* juggle won't work so a cast is made
|
|
300
|
+
# prior to store, again, that type inference has permitted it
|
|
301
|
+
# suggests this is safe.
|
|
302
|
+
# End Dragon warning...
|
|
303
|
+
DOCAST = (
|
|
304
|
+
context.typing_context.unify_types(
|
|
305
|
+
sig.args[0][i], sig.return_type
|
|
306
|
+
)
|
|
307
|
+
== sig.return_type
|
|
308
|
+
)
|
|
309
|
+
if DOCAST:
|
|
310
|
+
value_slot = builder.alloca(
|
|
311
|
+
lrtty, name="TYPED_VALUE_SLOT%s" % i
|
|
312
|
+
)
|
|
313
|
+
casted = context.cast(
|
|
314
|
+
builder, value, sig.args[0][i], sig.return_type
|
|
315
|
+
)
|
|
316
|
+
builder.store(casted, value_slot)
|
|
317
|
+
else:
|
|
318
|
+
value_slot = builder.alloca(
|
|
319
|
+
value.type, name="TYPED_VALUE_SLOT%s" % i
|
|
320
|
+
)
|
|
321
|
+
builder.store(value, value_slot)
|
|
322
|
+
phinode.add_incoming(
|
|
323
|
+
builder.bitcast(value_slot, voidptrty), bbi
|
|
324
|
+
)
|
|
325
|
+
builder.branch(bbend)
|
|
326
|
+
|
|
327
|
+
builder.position_at_end(bbend)
|
|
328
|
+
res = builder.bitcast(phinode, lrtty.as_pointer())
|
|
329
|
+
res = builder.load(res)
|
|
330
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
@lower(operator.getitem, types.UniTuple, types.intp)
|
|
334
|
+
@lower(operator.getitem, types.UniTuple, types.uintp)
|
|
335
|
+
@lower(operator.getitem, types.NamedUniTuple, types.intp)
|
|
336
|
+
@lower(operator.getitem, types.NamedUniTuple, types.uintp)
|
|
337
|
+
def getitem_unituple(context, builder, sig, args):
|
|
338
|
+
tupty, _ = sig.args
|
|
339
|
+
tup, idx = args
|
|
340
|
+
|
|
341
|
+
errmsg_oob = ("tuple index out of range",)
|
|
342
|
+
|
|
343
|
+
if len(tupty) == 0:
|
|
344
|
+
# Empty tuple.
|
|
345
|
+
|
|
346
|
+
# Always branch and raise IndexError
|
|
347
|
+
with builder.if_then(cgutils.true_bit):
|
|
348
|
+
context.call_conv.return_user_exc(builder, IndexError, errmsg_oob)
|
|
349
|
+
# This is unreachable in runtime,
|
|
350
|
+
# but it exists to not terminate the current basicblock.
|
|
351
|
+
res = context.get_constant_null(sig.return_type)
|
|
352
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
353
|
+
else:
|
|
354
|
+
# The tuple is not empty
|
|
355
|
+
bbelse = builder.append_basic_block("switch.else")
|
|
356
|
+
bbend = builder.append_basic_block("switch.end")
|
|
357
|
+
switch = builder.switch(idx, bbelse)
|
|
358
|
+
|
|
359
|
+
with builder.goto_block(bbelse):
|
|
360
|
+
context.call_conv.return_user_exc(builder, IndexError, errmsg_oob)
|
|
361
|
+
|
|
362
|
+
lrtty = context.get_value_type(tupty.dtype)
|
|
363
|
+
with builder.goto_block(bbend):
|
|
364
|
+
phinode = builder.phi(lrtty)
|
|
365
|
+
|
|
366
|
+
for i in range(tupty.count):
|
|
367
|
+
ki = context.get_constant(types.intp, i)
|
|
368
|
+
bbi = builder.append_basic_block("switch.%d" % i)
|
|
369
|
+
switch.add_case(ki, bbi)
|
|
370
|
+
# handle negative indexing, create case (-tuple.count + i) to
|
|
371
|
+
# reference same block as i
|
|
372
|
+
kin = context.get_constant(types.intp, -tupty.count + i)
|
|
373
|
+
switch.add_case(kin, bbi)
|
|
374
|
+
with builder.goto_block(bbi):
|
|
375
|
+
value = builder.extract_value(tup, i)
|
|
376
|
+
builder.branch(bbend)
|
|
377
|
+
phinode.add_incoming(value, bbi)
|
|
378
|
+
|
|
379
|
+
builder.position_at_end(bbend)
|
|
380
|
+
res = phinode
|
|
381
|
+
assert sig.return_type == tupty.dtype
|
|
382
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
@lower("static_getitem", types.LiteralStrKeyDict, types.StringLiteral)
|
|
386
|
+
@lower("static_getitem", types.LiteralList, types.IntegerLiteral)
|
|
387
|
+
@lower("static_getitem", types.LiteralList, types.SliceLiteral)
|
|
388
|
+
@lower("static_getitem", types.BaseTuple, types.IntegerLiteral)
|
|
389
|
+
@lower("static_getitem", types.BaseTuple, types.SliceLiteral)
|
|
390
|
+
def static_getitem_tuple(context, builder, sig, args):
|
|
391
|
+
tupty, idxty = sig.args
|
|
392
|
+
tup, idx = args
|
|
393
|
+
if isinstance(idx, int):
|
|
394
|
+
if idx < 0:
|
|
395
|
+
idx += len(tupty)
|
|
396
|
+
if not 0 <= idx < len(tupty):
|
|
397
|
+
raise IndexError("cannot index at %d in %s" % (idx, tupty))
|
|
398
|
+
res = builder.extract_value(tup, idx)
|
|
399
|
+
elif isinstance(idx, slice):
|
|
400
|
+
items = cgutils.unpack_tuple(builder, tup)[idx]
|
|
401
|
+
res = context.make_tuple(builder, sig.return_type, items)
|
|
402
|
+
elif isinstance(tupty, types.LiteralStrKeyDict):
|
|
403
|
+
# pretend to be a dictionary
|
|
404
|
+
idx_val = idxty.literal_value
|
|
405
|
+
idx_offset = tupty.fields.index(idx_val)
|
|
406
|
+
res = builder.extract_value(tup, idx_offset)
|
|
407
|
+
else:
|
|
408
|
+
raise NotImplementedError(
|
|
409
|
+
"unexpected index %r for %s" % (idx, sig.args[0])
|
|
410
|
+
)
|
|
411
|
+
return impl_ret_borrowed(context, builder, sig.return_type, res)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
# ------------------------------------------------------------------------------
|
|
415
|
+
# Implicit conversion
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
@lower_cast(types.BaseTuple, types.BaseTuple)
|
|
419
|
+
def tuple_to_tuple(context, builder, fromty, toty, val):
|
|
420
|
+
if isinstance(fromty, types.BaseNamedTuple) or isinstance(
|
|
421
|
+
toty, types.BaseNamedTuple
|
|
422
|
+
):
|
|
423
|
+
# Disallowed by typing layer
|
|
424
|
+
raise NotImplementedError
|
|
425
|
+
|
|
426
|
+
if len(fromty) != len(toty):
|
|
427
|
+
# Disallowed by typing layer
|
|
428
|
+
raise NotImplementedError
|
|
429
|
+
|
|
430
|
+
olditems = cgutils.unpack_tuple(builder, val, len(fromty))
|
|
431
|
+
items = [
|
|
432
|
+
context.cast(builder, v, f, t)
|
|
433
|
+
for v, f, t in zip(olditems, fromty, toty)
|
|
434
|
+
]
|
|
435
|
+
return context.make_tuple(builder, toty, items)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
# ------------------------------------------------------------------------------
|
|
439
|
+
# Methods
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
@overload_method(types.BaseTuple, "index")
|
|
443
|
+
def tuple_index(tup, value):
|
|
444
|
+
def tuple_index_impl(tup, value):
|
|
445
|
+
for i in range(len(tup)):
|
|
446
|
+
if tup[i] == value:
|
|
447
|
+
return i
|
|
448
|
+
raise ValueError("tuple.index(x): x not in tuple")
|
|
449
|
+
|
|
450
|
+
return tuple_index_impl
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
@overload(operator.contains)
|
|
454
|
+
def in_seq_empty_tuple(x, y):
|
|
455
|
+
if isinstance(x, types.Tuple) and not x.types:
|
|
456
|
+
return lambda x, y: False
|