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,242 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
from numba.cuda.extending import (
|
|
5
|
+
core_models,
|
|
6
|
+
register_model,
|
|
7
|
+
type_callable,
|
|
8
|
+
unbox,
|
|
9
|
+
NativeValue,
|
|
10
|
+
make_attribute_wrapper,
|
|
11
|
+
box,
|
|
12
|
+
)
|
|
13
|
+
from numba.cuda import types
|
|
14
|
+
from numba.cuda import cgutils
|
|
15
|
+
import warnings
|
|
16
|
+
from numba.cuda.core.errors import (
|
|
17
|
+
NumbaExperimentalFeatureWarning,
|
|
18
|
+
NumbaValueError,
|
|
19
|
+
)
|
|
20
|
+
from numpy.polynomial.polynomial import Polynomial
|
|
21
|
+
from contextlib import ExitStack
|
|
22
|
+
import numpy as np
|
|
23
|
+
from llvmlite import ir
|
|
24
|
+
from numba.cuda.core.imputils import Registry
|
|
25
|
+
|
|
26
|
+
registry = Registry("np.polynomial_core")
|
|
27
|
+
lower = registry.lower
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@register_model(types.PolynomialType)
|
|
31
|
+
class PolynomialModel(core_models.StructModel):
|
|
32
|
+
def __init__(self, dmm, fe_type):
|
|
33
|
+
members = [
|
|
34
|
+
("coef", fe_type.coef),
|
|
35
|
+
("domain", fe_type.domain),
|
|
36
|
+
("window", fe_type.window),
|
|
37
|
+
# Introduced in NumPy 1.24, maybe leave it out for now
|
|
38
|
+
# ('symbol', types.string)
|
|
39
|
+
]
|
|
40
|
+
super(PolynomialModel, self).__init__(dmm, fe_type, members)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@type_callable(Polynomial)
|
|
44
|
+
def type_polynomial(context):
|
|
45
|
+
def typer(coef, domain=None, window=None):
|
|
46
|
+
default_domain = types.Array(types.int64, 1, "C")
|
|
47
|
+
double_domain = types.Array(types.double, 1, "C")
|
|
48
|
+
default_window = types.Array(types.int64, 1, "C")
|
|
49
|
+
double_window = types.Array(types.double, 1, "C")
|
|
50
|
+
double_coef = types.Array(types.double, 1, "C")
|
|
51
|
+
|
|
52
|
+
warnings.warn(
|
|
53
|
+
"Polynomial class is experimental",
|
|
54
|
+
category=NumbaExperimentalFeatureWarning,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if isinstance(coef, types.Array) and all(
|
|
58
|
+
[a is None for a in (domain, window)]
|
|
59
|
+
):
|
|
60
|
+
if coef.ndim == 1:
|
|
61
|
+
# If Polynomial(coef) is called, coef is cast to double dtype,
|
|
62
|
+
# and domain and window are set to equal [-1, 1], i.e. have
|
|
63
|
+
# integer dtype
|
|
64
|
+
return types.PolynomialType(
|
|
65
|
+
double_coef, default_domain, default_window, 1
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
msg = "Coefficient array is not 1-d"
|
|
69
|
+
raise NumbaValueError(msg)
|
|
70
|
+
elif all([isinstance(a, types.Array) for a in (coef, domain, window)]):
|
|
71
|
+
if coef.ndim == 1:
|
|
72
|
+
if all([a.ndim == 1 for a in (domain, window)]):
|
|
73
|
+
# If Polynomial(coef, domain, window) is called, then coef,
|
|
74
|
+
# domain and window are cast to double dtype
|
|
75
|
+
return types.PolynomialType(
|
|
76
|
+
double_coef, double_domain, double_window, 3
|
|
77
|
+
)
|
|
78
|
+
else:
|
|
79
|
+
msg = "Coefficient array is not 1-d"
|
|
80
|
+
raise NumbaValueError(msg)
|
|
81
|
+
|
|
82
|
+
return typer
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
make_attribute_wrapper(types.PolynomialType, "coef", "coef")
|
|
86
|
+
make_attribute_wrapper(types.PolynomialType, "domain", "domain")
|
|
87
|
+
make_attribute_wrapper(types.PolynomialType, "window", "window")
|
|
88
|
+
# Introduced in NumPy 1.24, maybe leave it out for now
|
|
89
|
+
# make_attribute_wrapper(types.PolynomialType, 'symbol', 'symbol')
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@lower(Polynomial, types.Array)
|
|
93
|
+
def impl_polynomial1(context, builder, sig, args):
|
|
94
|
+
def to_double(arr):
|
|
95
|
+
return np.asarray(arr, dtype=np.double)
|
|
96
|
+
|
|
97
|
+
def const_impl():
|
|
98
|
+
return np.asarray([-1, 1])
|
|
99
|
+
|
|
100
|
+
typ = sig.return_type
|
|
101
|
+
polynomial = cgutils.create_struct_proxy(typ)(context, builder)
|
|
102
|
+
sig_coef = sig.args[0].copy(dtype=types.double)(sig.args[0])
|
|
103
|
+
coef_cast = context.compile_internal(builder, to_double, sig_coef, args)
|
|
104
|
+
sig_domain = sig.args[0].copy(dtype=types.intp)()
|
|
105
|
+
sig_window = sig.args[0].copy(dtype=types.intp)()
|
|
106
|
+
domain_cast = context.compile_internal(builder, const_impl, sig_domain, ())
|
|
107
|
+
window_cast = context.compile_internal(builder, const_impl, sig_window, ())
|
|
108
|
+
polynomial.coef = coef_cast
|
|
109
|
+
polynomial.domain = domain_cast
|
|
110
|
+
polynomial.window = window_cast
|
|
111
|
+
|
|
112
|
+
return polynomial._getvalue()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@lower(Polynomial, types.Array, types.Array, types.Array)
|
|
116
|
+
def impl_polynomial3(context, builder, sig, args):
|
|
117
|
+
def to_double(coef):
|
|
118
|
+
return np.asarray(coef, dtype=np.double)
|
|
119
|
+
|
|
120
|
+
typ = sig.return_type
|
|
121
|
+
polynomial = cgutils.create_struct_proxy(typ)(context, builder)
|
|
122
|
+
|
|
123
|
+
coef_sig = sig.args[0].copy(dtype=types.double)(sig.args[0])
|
|
124
|
+
domain_sig = sig.args[1].copy(dtype=types.double)(sig.args[1])
|
|
125
|
+
window_sig = sig.args[2].copy(dtype=types.double)(sig.args[2])
|
|
126
|
+
coef_cast = context.compile_internal(
|
|
127
|
+
builder, to_double, coef_sig, (args[0],)
|
|
128
|
+
)
|
|
129
|
+
domain_cast = context.compile_internal(
|
|
130
|
+
builder, to_double, domain_sig, (args[1],)
|
|
131
|
+
)
|
|
132
|
+
window_cast = context.compile_internal(
|
|
133
|
+
builder, to_double, window_sig, (args[2],)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
domain_helper = context.make_helper(
|
|
137
|
+
builder, domain_sig.return_type, value=domain_cast
|
|
138
|
+
)
|
|
139
|
+
window_helper = context.make_helper(
|
|
140
|
+
builder, window_sig.return_type, value=window_cast
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
i64 = ir.IntType(64)
|
|
144
|
+
two = i64(2)
|
|
145
|
+
|
|
146
|
+
s1 = builder.extract_value(domain_helper.shape, 0)
|
|
147
|
+
s2 = builder.extract_value(window_helper.shape, 0)
|
|
148
|
+
pred1 = builder.icmp_signed("!=", s1, two)
|
|
149
|
+
pred2 = builder.icmp_signed("!=", s2, two)
|
|
150
|
+
|
|
151
|
+
with cgutils.if_unlikely(builder, pred1):
|
|
152
|
+
context.call_conv.return_user_exc(
|
|
153
|
+
builder, ValueError, ("Domain has wrong number of elements.",)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
with cgutils.if_unlikely(builder, pred2):
|
|
157
|
+
context.call_conv.return_user_exc(
|
|
158
|
+
builder, ValueError, ("Window has wrong number of elements.",)
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
polynomial.coef = coef_cast
|
|
162
|
+
polynomial.domain = domain_helper._getvalue()
|
|
163
|
+
polynomial.window = window_helper._getvalue()
|
|
164
|
+
|
|
165
|
+
return polynomial._getvalue()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@unbox(types.PolynomialType)
|
|
169
|
+
def unbox_polynomial(typ, obj, c):
|
|
170
|
+
"""
|
|
171
|
+
Convert a Polynomial object to a native polynomial structure.
|
|
172
|
+
"""
|
|
173
|
+
is_error_ptr = cgutils.alloca_once_value(c.builder, cgutils.false_bit)
|
|
174
|
+
polynomial = cgutils.create_struct_proxy(typ)(c.context, c.builder)
|
|
175
|
+
with ExitStack() as stack:
|
|
176
|
+
natives = []
|
|
177
|
+
for name in ("coef", "domain", "window"):
|
|
178
|
+
attr = c.pyapi.object_getattr_string(obj, name)
|
|
179
|
+
with cgutils.early_exit_if_null(c.builder, stack, attr):
|
|
180
|
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
|
181
|
+
t = getattr(typ, name)
|
|
182
|
+
native = c.unbox(t, attr)
|
|
183
|
+
c.pyapi.decref(attr)
|
|
184
|
+
with cgutils.early_exit_if(c.builder, stack, native.is_error):
|
|
185
|
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
|
186
|
+
natives.append(native)
|
|
187
|
+
|
|
188
|
+
polynomial.coef = natives[0]
|
|
189
|
+
polynomial.domain = natives[1]
|
|
190
|
+
polynomial.window = natives[2]
|
|
191
|
+
|
|
192
|
+
return NativeValue(
|
|
193
|
+
polynomial._getvalue(), is_error=c.builder.load(is_error_ptr)
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@box(types.PolynomialType)
|
|
198
|
+
def box_polynomial(typ, val, c):
|
|
199
|
+
"""
|
|
200
|
+
Convert a native polynomial structure to a Polynomial object.
|
|
201
|
+
"""
|
|
202
|
+
ret_ptr = cgutils.alloca_once(c.builder, c.pyapi.pyobj)
|
|
203
|
+
fail_obj = c.pyapi.get_null_object()
|
|
204
|
+
|
|
205
|
+
with ExitStack() as stack:
|
|
206
|
+
polynomial = cgutils.create_struct_proxy(typ)(
|
|
207
|
+
c.context, c.builder, value=val
|
|
208
|
+
)
|
|
209
|
+
coef_obj = c.box(typ.coef, polynomial.coef)
|
|
210
|
+
with cgutils.early_exit_if_null(c.builder, stack, coef_obj):
|
|
211
|
+
c.builder.store(fail_obj, ret_ptr)
|
|
212
|
+
|
|
213
|
+
domain_obj = c.box(typ.domain, polynomial.domain)
|
|
214
|
+
with cgutils.early_exit_if_null(c.builder, stack, domain_obj):
|
|
215
|
+
c.builder.store(fail_obj, ret_ptr)
|
|
216
|
+
|
|
217
|
+
window_obj = c.box(typ.window, polynomial.window)
|
|
218
|
+
with cgutils.early_exit_if_null(c.builder, stack, window_obj):
|
|
219
|
+
c.builder.store(fail_obj, ret_ptr)
|
|
220
|
+
|
|
221
|
+
class_obj = c.pyapi.unserialize(c.pyapi.serialize_object(Polynomial))
|
|
222
|
+
with cgutils.early_exit_if_null(c.builder, stack, class_obj):
|
|
223
|
+
c.pyapi.decref(coef_obj)
|
|
224
|
+
c.pyapi.decref(domain_obj)
|
|
225
|
+
c.pyapi.decref(window_obj)
|
|
226
|
+
c.builder.store(fail_obj, ret_ptr)
|
|
227
|
+
|
|
228
|
+
if typ.n_args == 1:
|
|
229
|
+
res1 = c.pyapi.call_function_objargs(class_obj, (coef_obj,))
|
|
230
|
+
c.builder.store(res1, ret_ptr)
|
|
231
|
+
else:
|
|
232
|
+
res3 = c.pyapi.call_function_objargs(
|
|
233
|
+
class_obj, (coef_obj, domain_obj, window_obj)
|
|
234
|
+
)
|
|
235
|
+
c.builder.store(res3, ret_ptr)
|
|
236
|
+
|
|
237
|
+
c.pyapi.decref(coef_obj)
|
|
238
|
+
c.pyapi.decref(domain_obj)
|
|
239
|
+
c.pyapi.decref(window_obj)
|
|
240
|
+
c.pyapi.decref(class_obj)
|
|
241
|
+
|
|
242
|
+
return c.builder.load(ret_ptr)
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Implementation of operations involving polynomials.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
from numpy.polynomial import polynomial as poly
|
|
10
|
+
from numpy.polynomial import polyutils as pu
|
|
11
|
+
|
|
12
|
+
from numba.cuda.misc.special import literal_unroll
|
|
13
|
+
from numba.cuda import types
|
|
14
|
+
from numba.cuda.core import errors
|
|
15
|
+
from numba.cuda.extending import overload
|
|
16
|
+
from numba.cuda.np.numpy_support import type_can_asarray, as_dtype, from_dtype
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@overload(np.roots)
|
|
20
|
+
def roots_impl(p):
|
|
21
|
+
# cast int vectors to float cf. numpy, this is a bit dicey as
|
|
22
|
+
# the roots could be complex which will fail anyway
|
|
23
|
+
ty = getattr(p, "dtype", p)
|
|
24
|
+
if isinstance(ty, types.Integer):
|
|
25
|
+
cast_t = np.float64
|
|
26
|
+
else:
|
|
27
|
+
cast_t = as_dtype(ty)
|
|
28
|
+
|
|
29
|
+
def roots_impl(p):
|
|
30
|
+
# impl based on numpy:
|
|
31
|
+
# https://github.com/numpy/numpy/blob/master/numpy/lib/polynomial.py
|
|
32
|
+
|
|
33
|
+
if len(p.shape) != 1:
|
|
34
|
+
raise ValueError("Input must be a 1d array.")
|
|
35
|
+
|
|
36
|
+
non_zero = np.nonzero(p)[0]
|
|
37
|
+
|
|
38
|
+
if len(non_zero) == 0:
|
|
39
|
+
return np.zeros(0, dtype=cast_t)
|
|
40
|
+
|
|
41
|
+
tz = len(p) - non_zero[-1] - 1
|
|
42
|
+
|
|
43
|
+
# pull out the coeffs selecting between possible zero pads
|
|
44
|
+
p = p[int(non_zero[0]) : int(non_zero[-1]) + 1]
|
|
45
|
+
|
|
46
|
+
n = len(p)
|
|
47
|
+
if n > 1:
|
|
48
|
+
# construct companion matrix, ensure fortran order
|
|
49
|
+
# to give to eigvals, write to upper diag and then
|
|
50
|
+
# transpose.
|
|
51
|
+
A = np.diag(np.ones((n - 2,), cast_t), 1).T
|
|
52
|
+
A[0, :] = -p[1:] / p[0] # normalize
|
|
53
|
+
roots = np.linalg.eigvals(A)
|
|
54
|
+
else:
|
|
55
|
+
roots = np.zeros(0, dtype=cast_t)
|
|
56
|
+
|
|
57
|
+
# add in additional zeros on the end if needed
|
|
58
|
+
if tz > 0:
|
|
59
|
+
return np.hstack((roots, np.zeros(tz, dtype=cast_t)))
|
|
60
|
+
else:
|
|
61
|
+
return roots
|
|
62
|
+
|
|
63
|
+
return roots_impl
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@overload(pu.trimseq)
|
|
67
|
+
def polyutils_trimseq(seq):
|
|
68
|
+
if not type_can_asarray(seq):
|
|
69
|
+
msg = 'The argument "seq" must be array-like'
|
|
70
|
+
raise errors.TypingError(msg)
|
|
71
|
+
|
|
72
|
+
if isinstance(seq, types.BaseTuple):
|
|
73
|
+
msg = 'Unsupported type %r for argument "seq"'
|
|
74
|
+
raise errors.TypingError(msg % (seq))
|
|
75
|
+
|
|
76
|
+
if np.ndim(seq) > 1:
|
|
77
|
+
msg = "Coefficient array is not 1-d"
|
|
78
|
+
raise errors.NumbaValueError(msg)
|
|
79
|
+
|
|
80
|
+
def impl(seq):
|
|
81
|
+
if len(seq) == 0:
|
|
82
|
+
return seq
|
|
83
|
+
else:
|
|
84
|
+
for i in range(len(seq) - 1, -1, -1):
|
|
85
|
+
if seq[i] != 0:
|
|
86
|
+
break
|
|
87
|
+
return seq[: i + 1]
|
|
88
|
+
|
|
89
|
+
return impl
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@overload(pu.as_series)
|
|
93
|
+
def polyutils_as_series(alist, trim=True):
|
|
94
|
+
if not type_can_asarray(alist):
|
|
95
|
+
msg = 'The argument "alist" must be array-like'
|
|
96
|
+
raise errors.TypingError(msg)
|
|
97
|
+
|
|
98
|
+
if not isinstance(trim, (bool, types.Boolean)):
|
|
99
|
+
msg = 'The argument "trim" must be boolean'
|
|
100
|
+
raise errors.TypingError(msg)
|
|
101
|
+
|
|
102
|
+
res_dtype = np.float64
|
|
103
|
+
|
|
104
|
+
tuple_input = isinstance(alist, types.BaseTuple)
|
|
105
|
+
list_input = isinstance(alist, types.List)
|
|
106
|
+
if tuple_input:
|
|
107
|
+
if np.any(np.array([np.ndim(a) > 1 for a in alist])):
|
|
108
|
+
raise errors.NumbaValueError("Coefficient array is not 1-d")
|
|
109
|
+
|
|
110
|
+
res_dtype = _poly_result_dtype(*alist)
|
|
111
|
+
|
|
112
|
+
elif list_input:
|
|
113
|
+
dt = as_dtype(_get_list_type(alist))
|
|
114
|
+
res_dtype = np.result_type(dt, np.float64)
|
|
115
|
+
|
|
116
|
+
else:
|
|
117
|
+
if np.ndim(alist) <= 2:
|
|
118
|
+
res_dtype = np.result_type(res_dtype, as_dtype(alist.dtype))
|
|
119
|
+
else:
|
|
120
|
+
# If total dimension has ndim > 2, then coeff arrays are not 1D
|
|
121
|
+
raise errors.NumbaValueError("Coefficient array is not 1-d")
|
|
122
|
+
|
|
123
|
+
def impl(alist, trim=True):
|
|
124
|
+
if tuple_input:
|
|
125
|
+
arrays = []
|
|
126
|
+
for item in literal_unroll(alist):
|
|
127
|
+
arrays.append(np.atleast_1d(np.asarray(item)).astype(res_dtype))
|
|
128
|
+
|
|
129
|
+
elif list_input:
|
|
130
|
+
arrays = [
|
|
131
|
+
np.atleast_1d(np.asarray(a)).astype(res_dtype) for a in alist
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
else:
|
|
135
|
+
alist_arr = np.asarray(alist)
|
|
136
|
+
arrays = [
|
|
137
|
+
np.atleast_1d(np.asarray(a)).astype(res_dtype)
|
|
138
|
+
for a in alist_arr
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
if min([a.size for a in arrays]) == 0:
|
|
142
|
+
raise ValueError("Coefficient array is empty")
|
|
143
|
+
|
|
144
|
+
if trim:
|
|
145
|
+
arrays = [pu.trimseq(a) for a in arrays]
|
|
146
|
+
|
|
147
|
+
ret = arrays
|
|
148
|
+
return ret
|
|
149
|
+
|
|
150
|
+
return impl
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _get_list_type(l):
|
|
154
|
+
# A helper function that takes a list (possibly nested) and returns its
|
|
155
|
+
# dtype. Returns a Numba type.
|
|
156
|
+
dt = l.dtype
|
|
157
|
+
if (not isinstance(dt, types.Number)) and type_can_asarray(dt):
|
|
158
|
+
return _get_list_type(dt)
|
|
159
|
+
else:
|
|
160
|
+
return dt
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _poly_result_dtype(*args):
|
|
164
|
+
# A helper function that takes a tuple of inputs and returns their result
|
|
165
|
+
# dtype. Used for poly functions. Returns a NumPy dtype.
|
|
166
|
+
res_dtype = np.float64
|
|
167
|
+
for item in args:
|
|
168
|
+
if isinstance(item, types.BaseTuple):
|
|
169
|
+
s1 = item.types
|
|
170
|
+
elif isinstance(item, types.List):
|
|
171
|
+
s1 = [_get_list_type(item)]
|
|
172
|
+
elif isinstance(item, types.Number):
|
|
173
|
+
s1 = [item]
|
|
174
|
+
elif isinstance(item, types.Array):
|
|
175
|
+
s1 = [item.dtype]
|
|
176
|
+
else:
|
|
177
|
+
msg = "Input dtype must be scalar"
|
|
178
|
+
raise errors.TypingError(msg)
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
l = [as_dtype(t) for t in s1]
|
|
182
|
+
l.append(res_dtype)
|
|
183
|
+
res_dtype = np.result_type(*l)
|
|
184
|
+
except errors.NumbaNotImplementedError:
|
|
185
|
+
msg = "Input dtype must be scalar."
|
|
186
|
+
raise errors.TypingError(msg)
|
|
187
|
+
|
|
188
|
+
return from_dtype(res_dtype)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@overload(poly.polyadd)
|
|
192
|
+
def numpy_polyadd(c1, c2):
|
|
193
|
+
if not type_can_asarray(c1):
|
|
194
|
+
msg = 'The argument "c1" must be array-like'
|
|
195
|
+
raise errors.TypingError(msg)
|
|
196
|
+
|
|
197
|
+
if not type_can_asarray(c2):
|
|
198
|
+
msg = 'The argument "c2" must be array-like'
|
|
199
|
+
raise errors.TypingError(msg)
|
|
200
|
+
|
|
201
|
+
def impl(c1, c2):
|
|
202
|
+
arr1, arr2 = pu.as_series((c1, c2))
|
|
203
|
+
diff = len(arr2) - len(arr1)
|
|
204
|
+
if diff > 0:
|
|
205
|
+
zr = np.zeros(diff)
|
|
206
|
+
arr1 = np.concatenate((arr1, zr))
|
|
207
|
+
if diff < 0:
|
|
208
|
+
zr = np.zeros(-diff)
|
|
209
|
+
arr2 = np.concatenate((arr2, zr))
|
|
210
|
+
val = arr1 + arr2
|
|
211
|
+
return pu.trimseq(val)
|
|
212
|
+
|
|
213
|
+
return impl
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@overload(poly.polysub)
|
|
217
|
+
def numpy_polysub(c1, c2):
|
|
218
|
+
if not type_can_asarray(c1):
|
|
219
|
+
msg = 'The argument "c1" must be array-like'
|
|
220
|
+
raise errors.TypingError(msg)
|
|
221
|
+
|
|
222
|
+
if not type_can_asarray(c2):
|
|
223
|
+
msg = 'The argument "c2" must be array-like'
|
|
224
|
+
raise errors.TypingError(msg)
|
|
225
|
+
|
|
226
|
+
def impl(c1, c2):
|
|
227
|
+
arr1, arr2 = pu.as_series((c1, c2))
|
|
228
|
+
diff = len(arr2) - len(arr1)
|
|
229
|
+
if diff > 0:
|
|
230
|
+
zr = np.zeros(diff)
|
|
231
|
+
arr1 = np.concatenate((arr1, zr))
|
|
232
|
+
if diff < 0:
|
|
233
|
+
zr = np.zeros(-diff)
|
|
234
|
+
arr2 = np.concatenate((arr2, zr))
|
|
235
|
+
val = arr1 - arr2
|
|
236
|
+
return pu.trimseq(val)
|
|
237
|
+
|
|
238
|
+
return impl
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@overload(poly.polymul)
|
|
242
|
+
def numpy_polymul(c1, c2):
|
|
243
|
+
if not type_can_asarray(c1):
|
|
244
|
+
msg = 'The argument "c1" must be array-like'
|
|
245
|
+
raise errors.TypingError(msg)
|
|
246
|
+
|
|
247
|
+
if not type_can_asarray(c2):
|
|
248
|
+
msg = 'The argument "c2" must be array-like'
|
|
249
|
+
raise errors.TypingError(msg)
|
|
250
|
+
|
|
251
|
+
def impl(c1, c2):
|
|
252
|
+
arr1, arr2 = pu.as_series((c1, c2))
|
|
253
|
+
val = np.convolve(arr1, arr2)
|
|
254
|
+
return pu.trimseq(val)
|
|
255
|
+
|
|
256
|
+
return impl
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@overload(poly.polyval, prefer_literal=True)
|
|
260
|
+
def poly_polyval(x, c, tensor=True):
|
|
261
|
+
if not type_can_asarray(x):
|
|
262
|
+
msg = 'The argument "x" must be array-like'
|
|
263
|
+
raise errors.TypingError(msg)
|
|
264
|
+
|
|
265
|
+
if not type_can_asarray(c):
|
|
266
|
+
msg = 'The argument "c" must be array-like'
|
|
267
|
+
raise errors.TypingError(msg)
|
|
268
|
+
|
|
269
|
+
if not isinstance(tensor, (bool, types.BooleanLiteral)):
|
|
270
|
+
msg = 'The argument "tensor" must be boolean'
|
|
271
|
+
raise errors.RequireLiteralValue(msg)
|
|
272
|
+
|
|
273
|
+
res_dtype = _poly_result_dtype(c, x)
|
|
274
|
+
|
|
275
|
+
# Simulate new_shape = (1,) * np.ndim(x) in the general case
|
|
276
|
+
# If x is a number, new_shape is not used
|
|
277
|
+
# If x is a tuple or a list, then it's 1d hence new_shape=(1,)
|
|
278
|
+
x_nd_array = not isinstance(x, types.Number)
|
|
279
|
+
new_shape = (1,)
|
|
280
|
+
if isinstance(x, types.Array):
|
|
281
|
+
# If x is a np.array, then take its dimension
|
|
282
|
+
new_shape = (1,) * np.ndim(x)
|
|
283
|
+
|
|
284
|
+
if isinstance(tensor, bool):
|
|
285
|
+
tensor_arg = tensor
|
|
286
|
+
else:
|
|
287
|
+
tensor_arg = tensor.literal_value
|
|
288
|
+
|
|
289
|
+
def impl(x, c, tensor=True):
|
|
290
|
+
arr = np.asarray(c).astype(res_dtype)
|
|
291
|
+
inputs = np.asarray(x).astype(res_dtype)
|
|
292
|
+
if x_nd_array and tensor_arg:
|
|
293
|
+
arr = arr.reshape(arr.shape + new_shape)
|
|
294
|
+
|
|
295
|
+
l = len(arr)
|
|
296
|
+
y = arr[l - 1] + inputs * 0
|
|
297
|
+
|
|
298
|
+
for i in range(l - 1, 0, -1):
|
|
299
|
+
y = arr[i - 1] + y * inputs
|
|
300
|
+
|
|
301
|
+
return y
|
|
302
|
+
|
|
303
|
+
return impl
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
@overload(poly.polyint)
|
|
307
|
+
def poly_polyint(c, m=1):
|
|
308
|
+
if not type_can_asarray(c):
|
|
309
|
+
msg = 'The argument "c" must be array-like'
|
|
310
|
+
raise errors.TypingError(msg)
|
|
311
|
+
|
|
312
|
+
if not isinstance(m, (int, types.Integer)):
|
|
313
|
+
msg = 'The argument "m" must be an integer'
|
|
314
|
+
raise errors.TypingError(msg)
|
|
315
|
+
|
|
316
|
+
res_dtype = as_dtype(_poly_result_dtype(c))
|
|
317
|
+
|
|
318
|
+
if not np.issubdtype(res_dtype, np.number):
|
|
319
|
+
msg = f"Input dtype must be scalar. Found {res_dtype} instead"
|
|
320
|
+
raise errors.TypingError(msg)
|
|
321
|
+
|
|
322
|
+
is1D = (np.ndim(c) == 1) or (
|
|
323
|
+
isinstance(c, (types.List, types.BaseTuple))
|
|
324
|
+
and isinstance(c.dtype, types.Number)
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
def impl(c, m=1):
|
|
328
|
+
c = np.asarray(c).astype(res_dtype)
|
|
329
|
+
cdt = c.dtype
|
|
330
|
+
for i in range(m):
|
|
331
|
+
n = len(c)
|
|
332
|
+
|
|
333
|
+
tmp = np.empty((n + 1,) + c.shape[1:], dtype=cdt)
|
|
334
|
+
tmp[0] = c[0] * 0
|
|
335
|
+
tmp[1] = c[0]
|
|
336
|
+
for j in range(1, n):
|
|
337
|
+
tmp[j + 1] = c[j] / (j + 1)
|
|
338
|
+
c = tmp
|
|
339
|
+
if is1D:
|
|
340
|
+
return pu.trimseq(c)
|
|
341
|
+
else:
|
|
342
|
+
return c
|
|
343
|
+
|
|
344
|
+
return impl
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@overload(poly.polydiv)
|
|
348
|
+
def numpy_polydiv(c1, c2):
|
|
349
|
+
if not type_can_asarray(c1):
|
|
350
|
+
msg = 'The argument "c1" must be array-like'
|
|
351
|
+
raise errors.TypingError(msg)
|
|
352
|
+
|
|
353
|
+
if not type_can_asarray(c2):
|
|
354
|
+
msg = 'The argument "c2" must be array-like'
|
|
355
|
+
raise errors.TypingError(msg)
|
|
356
|
+
|
|
357
|
+
def impl(c1, c2):
|
|
358
|
+
arr1, arr2 = pu.as_series((c1, c2))
|
|
359
|
+
if arr2[-1] == 0:
|
|
360
|
+
raise ZeroDivisionError()
|
|
361
|
+
|
|
362
|
+
l1 = len(arr1)
|
|
363
|
+
l2 = len(arr2)
|
|
364
|
+
if l1 < l2:
|
|
365
|
+
return arr1[:1] * 0, arr1
|
|
366
|
+
elif l2 == 1:
|
|
367
|
+
return arr1 / arr2[-1], arr1[:1] * 0
|
|
368
|
+
else:
|
|
369
|
+
dlen = l1 - l2
|
|
370
|
+
scl = arr2[-1]
|
|
371
|
+
arr2 = arr2[:-1] / scl
|
|
372
|
+
i = dlen
|
|
373
|
+
j = l1 - 1
|
|
374
|
+
while i >= 0:
|
|
375
|
+
arr1[i:j] -= arr2 * arr1[j]
|
|
376
|
+
i -= 1
|
|
377
|
+
j -= 1
|
|
378
|
+
return arr1[j + 1 :] / scl, pu.trimseq(arr1[: j + 1])
|
|
379
|
+
|
|
380
|
+
return impl
|