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,560 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Implement the cmath module functions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import cmath
|
|
9
|
+
import math
|
|
10
|
+
|
|
11
|
+
from numba.cuda.core.imputils import impl_ret_untracked, Registry
|
|
12
|
+
from numba.cuda import types
|
|
13
|
+
from numba.cuda.typing import signature
|
|
14
|
+
from numba.cuda.cpython import mathimpl
|
|
15
|
+
from numba.cuda.extending import overload
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
registry = Registry("cmathimpl")
|
|
19
|
+
lower = registry.lower
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def is_nan(builder, z):
|
|
23
|
+
return builder.fcmp_unordered("uno", z.real, z.imag)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def is_inf(builder, z):
|
|
27
|
+
return builder.or_(
|
|
28
|
+
mathimpl.is_inf(builder, z.real), mathimpl.is_inf(builder, z.imag)
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def is_finite(builder, z):
|
|
33
|
+
return builder.and_(
|
|
34
|
+
mathimpl.is_finite(builder, z.real), mathimpl.is_finite(builder, z.imag)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@lower(cmath.isnan, types.Complex)
|
|
39
|
+
def isnan_float_impl(context, builder, sig, args):
|
|
40
|
+
[typ] = sig.args
|
|
41
|
+
[value] = args
|
|
42
|
+
z = context.make_complex(builder, typ, value=value)
|
|
43
|
+
res = is_nan(builder, z)
|
|
44
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@lower(cmath.isinf, types.Complex)
|
|
48
|
+
def isinf_float_impl(context, builder, sig, args):
|
|
49
|
+
[typ] = sig.args
|
|
50
|
+
[value] = args
|
|
51
|
+
z = context.make_complex(builder, typ, value=value)
|
|
52
|
+
res = is_inf(builder, z)
|
|
53
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@lower(cmath.isfinite, types.Complex)
|
|
57
|
+
def isfinite_float_impl(context, builder, sig, args):
|
|
58
|
+
[typ] = sig.args
|
|
59
|
+
[value] = args
|
|
60
|
+
z = context.make_complex(builder, typ, value=value)
|
|
61
|
+
res = is_finite(builder, z)
|
|
62
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@overload(cmath.rect)
|
|
66
|
+
def impl_cmath_rect(r, phi):
|
|
67
|
+
if all([isinstance(typ, types.Float) for typ in [r, phi]]):
|
|
68
|
+
|
|
69
|
+
def impl(r, phi):
|
|
70
|
+
if not math.isfinite(phi):
|
|
71
|
+
if not r:
|
|
72
|
+
# cmath.rect(0, phi={inf, nan}) = 0
|
|
73
|
+
return abs(r)
|
|
74
|
+
if math.isinf(r):
|
|
75
|
+
# cmath.rect(inf, phi={inf, nan}) = inf + j phi
|
|
76
|
+
return complex(r, phi)
|
|
77
|
+
real = math.cos(phi)
|
|
78
|
+
imag = math.sin(phi)
|
|
79
|
+
if real == 0.0 and math.isinf(r):
|
|
80
|
+
# 0 * inf would return NaN, we want to keep 0 but xor the sign
|
|
81
|
+
real /= r
|
|
82
|
+
else:
|
|
83
|
+
real *= r
|
|
84
|
+
if imag == 0.0 and math.isinf(r):
|
|
85
|
+
# ditto
|
|
86
|
+
imag /= r
|
|
87
|
+
else:
|
|
88
|
+
imag *= r
|
|
89
|
+
return complex(real, imag)
|
|
90
|
+
|
|
91
|
+
return impl
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def intrinsic_complex_unary(inner_func):
|
|
95
|
+
def wrapper(context, builder, sig, args):
|
|
96
|
+
[typ] = sig.args
|
|
97
|
+
[value] = args
|
|
98
|
+
z = context.make_complex(builder, typ, value=value)
|
|
99
|
+
x = z.real
|
|
100
|
+
y = z.imag
|
|
101
|
+
# Same as above: math.isfinite() is unavailable on 2.x so we precompute
|
|
102
|
+
# its value and pass it to the pure Python implementation.
|
|
103
|
+
x_is_finite = mathimpl.is_finite(builder, x)
|
|
104
|
+
y_is_finite = mathimpl.is_finite(builder, y)
|
|
105
|
+
inner_sig = signature(
|
|
106
|
+
sig.return_type, *(typ.underlying_float,) * 2 + (types.boolean,) * 2
|
|
107
|
+
)
|
|
108
|
+
res = context.compile_internal(
|
|
109
|
+
builder, inner_func, inner_sig, (x, y, x_is_finite, y_is_finite)
|
|
110
|
+
)
|
|
111
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
112
|
+
|
|
113
|
+
return wrapper
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
NAN = float("nan")
|
|
117
|
+
INF = float("inf")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@lower(cmath.exp, types.Complex)
|
|
121
|
+
@intrinsic_complex_unary
|
|
122
|
+
def exp_impl(x, y, x_is_finite, y_is_finite):
|
|
123
|
+
"""cmath.exp(x + y j)"""
|
|
124
|
+
if x_is_finite:
|
|
125
|
+
if y_is_finite:
|
|
126
|
+
c = math.cos(y)
|
|
127
|
+
s = math.sin(y)
|
|
128
|
+
r = math.exp(x)
|
|
129
|
+
return complex(r * c, r * s)
|
|
130
|
+
else:
|
|
131
|
+
return complex(NAN, NAN)
|
|
132
|
+
elif math.isnan(x):
|
|
133
|
+
if y:
|
|
134
|
+
return complex(x, x) # nan + j nan
|
|
135
|
+
else:
|
|
136
|
+
return complex(x, y) # nan + 0j
|
|
137
|
+
elif x > 0.0:
|
|
138
|
+
# x == +inf
|
|
139
|
+
if y_is_finite:
|
|
140
|
+
real = math.cos(y)
|
|
141
|
+
imag = math.sin(y)
|
|
142
|
+
# Avoid NaNs if math.cos(y) or math.sin(y) == 0
|
|
143
|
+
# (e.g. cmath.exp(inf + 0j) == inf + 0j)
|
|
144
|
+
if real != 0:
|
|
145
|
+
real *= x
|
|
146
|
+
if imag != 0:
|
|
147
|
+
imag *= x
|
|
148
|
+
return complex(real, imag)
|
|
149
|
+
else:
|
|
150
|
+
return complex(x, NAN)
|
|
151
|
+
else:
|
|
152
|
+
# x == -inf
|
|
153
|
+
if y_is_finite:
|
|
154
|
+
r = math.exp(x)
|
|
155
|
+
c = math.cos(y)
|
|
156
|
+
s = math.sin(y)
|
|
157
|
+
return complex(r * c, r * s)
|
|
158
|
+
else:
|
|
159
|
+
r = 0
|
|
160
|
+
return complex(r, r)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@lower(cmath.log, types.Complex)
|
|
164
|
+
@intrinsic_complex_unary
|
|
165
|
+
def log_impl(x, y, x_is_finite, y_is_finite):
|
|
166
|
+
"""cmath.log(x + y j)"""
|
|
167
|
+
a = math.log(math.hypot(x, y))
|
|
168
|
+
b = math.atan2(y, x)
|
|
169
|
+
return complex(a, b)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@lower(cmath.log, types.Complex, types.Complex)
|
|
173
|
+
def log_base_impl(context, builder, sig, args):
|
|
174
|
+
"""cmath.log(z, base)"""
|
|
175
|
+
[z, base] = args
|
|
176
|
+
|
|
177
|
+
def log_base(z, base):
|
|
178
|
+
return cmath.log(z) / cmath.log(base)
|
|
179
|
+
|
|
180
|
+
res = context.compile_internal(builder, log_base, sig, args)
|
|
181
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@overload(cmath.log10)
|
|
185
|
+
def impl_cmath_log10(z):
|
|
186
|
+
if not isinstance(z, types.Complex):
|
|
187
|
+
return
|
|
188
|
+
|
|
189
|
+
LN_10 = 2.302585092994045684
|
|
190
|
+
|
|
191
|
+
def log10_impl(z):
|
|
192
|
+
"""cmath.log10(z)"""
|
|
193
|
+
z = cmath.log(z)
|
|
194
|
+
# This formula gives better results on +/-inf than cmath.log(z, 10)
|
|
195
|
+
# See http://bugs.python.org/issue22544
|
|
196
|
+
return complex(z.real / LN_10, z.imag / LN_10)
|
|
197
|
+
|
|
198
|
+
return log10_impl
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@overload(cmath.phase)
|
|
202
|
+
def phase_impl(x):
|
|
203
|
+
"""cmath.phase(x + y j)"""
|
|
204
|
+
|
|
205
|
+
if not isinstance(x, types.Complex):
|
|
206
|
+
return
|
|
207
|
+
|
|
208
|
+
def impl(x):
|
|
209
|
+
return math.atan2(x.imag, x.real)
|
|
210
|
+
|
|
211
|
+
return impl
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@overload(cmath.polar)
|
|
215
|
+
def polar_impl(x):
|
|
216
|
+
if not isinstance(x, types.Complex):
|
|
217
|
+
return
|
|
218
|
+
|
|
219
|
+
def impl(x):
|
|
220
|
+
r, i = x.real, x.imag
|
|
221
|
+
return math.hypot(r, i), math.atan2(i, r)
|
|
222
|
+
|
|
223
|
+
return impl
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
@lower(cmath.sqrt, types.Complex)
|
|
227
|
+
def sqrt_impl(context, builder, sig, args):
|
|
228
|
+
# We risk spurious overflow for components >= FLT_MAX / (1 + sqrt(2)).
|
|
229
|
+
|
|
230
|
+
SQRT2 = 1.414213562373095048801688724209698079e0
|
|
231
|
+
ONE_PLUS_SQRT2 = 1.0 + SQRT2
|
|
232
|
+
theargflt = sig.args[0].underlying_float
|
|
233
|
+
# Get a type specific maximum value so scaling for overflow is based on that
|
|
234
|
+
MAX = mathimpl.DBL_MAX if theargflt.bitwidth == 64 else mathimpl.FLT_MAX
|
|
235
|
+
# THRES will be double precision, should not impact typing as it's just
|
|
236
|
+
# used for comparison, there *may* be a few values near THRES which
|
|
237
|
+
# deviate from e.g. NumPy due to rounding that occurs in the computation
|
|
238
|
+
# of this value in the case of a 32bit argument.
|
|
239
|
+
THRES = MAX / ONE_PLUS_SQRT2
|
|
240
|
+
|
|
241
|
+
def sqrt_impl(z):
|
|
242
|
+
"""cmath.sqrt(z)"""
|
|
243
|
+
# This is NumPy's algorithm, see npy_csqrt() in npy_math_complex.c.src
|
|
244
|
+
a = z.real
|
|
245
|
+
b = z.imag
|
|
246
|
+
if a == 0.0 and b == 0.0:
|
|
247
|
+
return complex(abs(b), b)
|
|
248
|
+
if math.isinf(b):
|
|
249
|
+
return complex(abs(b), b)
|
|
250
|
+
if math.isnan(a):
|
|
251
|
+
return complex(a, a)
|
|
252
|
+
if math.isinf(a):
|
|
253
|
+
if a < 0.0:
|
|
254
|
+
return complex(abs(b - b), math.copysign(a, b))
|
|
255
|
+
else:
|
|
256
|
+
return complex(a, math.copysign(b - b, b))
|
|
257
|
+
|
|
258
|
+
# The remaining special case (b is NaN) is handled just fine by
|
|
259
|
+
# the normal code path below.
|
|
260
|
+
|
|
261
|
+
# Scale to avoid overflow
|
|
262
|
+
if abs(a) >= THRES or abs(b) >= THRES:
|
|
263
|
+
a *= 0.25
|
|
264
|
+
b *= 0.25
|
|
265
|
+
scale = True
|
|
266
|
+
else:
|
|
267
|
+
scale = False
|
|
268
|
+
# Algorithm 312, CACM vol 10, Oct 1967
|
|
269
|
+
if a >= 0:
|
|
270
|
+
t = math.sqrt((a + math.hypot(a, b)) * 0.5)
|
|
271
|
+
real = t
|
|
272
|
+
imag = b / (2 * t)
|
|
273
|
+
else:
|
|
274
|
+
t = math.sqrt((-a + math.hypot(a, b)) * 0.5)
|
|
275
|
+
real = abs(b) / (2 * t)
|
|
276
|
+
imag = math.copysign(t, b)
|
|
277
|
+
# Rescale
|
|
278
|
+
if scale:
|
|
279
|
+
return complex(real * 2, imag)
|
|
280
|
+
else:
|
|
281
|
+
return complex(real, imag)
|
|
282
|
+
|
|
283
|
+
res = context.compile_internal(builder, sqrt_impl, sig, args)
|
|
284
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
@lower(cmath.cos, types.Complex)
|
|
288
|
+
def cos_impl(context, builder, sig, args):
|
|
289
|
+
def cos_impl(z):
|
|
290
|
+
"""cmath.cos(z) = cmath.cosh(z j)"""
|
|
291
|
+
return cmath.cosh(complex(-z.imag, z.real))
|
|
292
|
+
|
|
293
|
+
res = context.compile_internal(builder, cos_impl, sig, args)
|
|
294
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@overload(cmath.cosh)
|
|
298
|
+
def impl_cmath_cosh(z):
|
|
299
|
+
if not isinstance(z, types.Complex):
|
|
300
|
+
return
|
|
301
|
+
|
|
302
|
+
def cosh_impl(z):
|
|
303
|
+
"""cmath.cosh(z)"""
|
|
304
|
+
x = z.real
|
|
305
|
+
y = z.imag
|
|
306
|
+
if math.isinf(x):
|
|
307
|
+
if math.isnan(y):
|
|
308
|
+
# x = +inf, y = NaN => cmath.cosh(x + y j) = inf + Nan * j
|
|
309
|
+
real = abs(x)
|
|
310
|
+
imag = y
|
|
311
|
+
elif y == 0.0:
|
|
312
|
+
# x = +inf, y = 0 => cmath.cosh(x + y j) = inf + 0j
|
|
313
|
+
real = abs(x)
|
|
314
|
+
imag = y
|
|
315
|
+
else:
|
|
316
|
+
real = math.copysign(x, math.cos(y))
|
|
317
|
+
imag = math.copysign(x, math.sin(y))
|
|
318
|
+
if x < 0.0:
|
|
319
|
+
# x = -inf => negate imaginary part of result
|
|
320
|
+
imag = -imag
|
|
321
|
+
return complex(real, imag)
|
|
322
|
+
return complex(math.cos(y) * math.cosh(x), math.sin(y) * math.sinh(x))
|
|
323
|
+
|
|
324
|
+
return cosh_impl
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
@lower(cmath.sin, types.Complex)
|
|
328
|
+
def sin_impl(context, builder, sig, args):
|
|
329
|
+
def sin_impl(z):
|
|
330
|
+
"""cmath.sin(z) = -j * cmath.sinh(z j)"""
|
|
331
|
+
r = cmath.sinh(complex(-z.imag, z.real))
|
|
332
|
+
return complex(r.imag, -r.real)
|
|
333
|
+
|
|
334
|
+
res = context.compile_internal(builder, sin_impl, sig, args)
|
|
335
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
@overload(cmath.sinh)
|
|
339
|
+
def impl_cmath_sinh(z):
|
|
340
|
+
if not isinstance(z, types.Complex):
|
|
341
|
+
return
|
|
342
|
+
|
|
343
|
+
def sinh_impl(z):
|
|
344
|
+
"""cmath.sinh(z)"""
|
|
345
|
+
x = z.real
|
|
346
|
+
y = z.imag
|
|
347
|
+
if math.isinf(x):
|
|
348
|
+
if math.isnan(y):
|
|
349
|
+
# x = +/-inf, y = NaN => cmath.sinh(x + y j) = x + NaN * j
|
|
350
|
+
real = x
|
|
351
|
+
imag = y
|
|
352
|
+
else:
|
|
353
|
+
real = math.cos(y)
|
|
354
|
+
imag = math.sin(y)
|
|
355
|
+
if real != 0.0:
|
|
356
|
+
real *= x
|
|
357
|
+
if imag != 0.0:
|
|
358
|
+
imag *= abs(x)
|
|
359
|
+
return complex(real, imag)
|
|
360
|
+
return complex(math.cos(y) * math.sinh(x), math.sin(y) * math.cosh(x))
|
|
361
|
+
|
|
362
|
+
return sinh_impl
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
@lower(cmath.tan, types.Complex)
|
|
366
|
+
def tan_impl(context, builder, sig, args):
|
|
367
|
+
def tan_impl(z):
|
|
368
|
+
"""cmath.tan(z) = -j * cmath.tanh(z j)"""
|
|
369
|
+
r = cmath.tanh(complex(-z.imag, z.real))
|
|
370
|
+
return complex(r.imag, -r.real)
|
|
371
|
+
|
|
372
|
+
res = context.compile_internal(builder, tan_impl, sig, args)
|
|
373
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
@overload(cmath.tanh)
|
|
377
|
+
def impl_cmath_tanh(z):
|
|
378
|
+
if not isinstance(z, types.Complex):
|
|
379
|
+
return
|
|
380
|
+
|
|
381
|
+
def tanh_impl(z):
|
|
382
|
+
"""cmath.tanh(z)"""
|
|
383
|
+
x = z.real
|
|
384
|
+
y = z.imag
|
|
385
|
+
if math.isinf(x):
|
|
386
|
+
real = math.copysign(1.0, x)
|
|
387
|
+
if math.isinf(y):
|
|
388
|
+
imag = 0.0
|
|
389
|
+
else:
|
|
390
|
+
imag = math.copysign(0.0, math.sin(2.0 * y))
|
|
391
|
+
return complex(real, imag)
|
|
392
|
+
# This is CPython's algorithm (see c_tanh() in cmathmodule.c).
|
|
393
|
+
# XXX how to force float constants into single precision?
|
|
394
|
+
tx = math.tanh(x)
|
|
395
|
+
ty = math.tan(y)
|
|
396
|
+
cx = 1.0 / math.cosh(x)
|
|
397
|
+
txty = tx * ty
|
|
398
|
+
denom = 1.0 + txty * txty
|
|
399
|
+
return complex(tx * (1.0 + ty * ty) / denom, ((ty / denom) * cx) * cx)
|
|
400
|
+
|
|
401
|
+
return tanh_impl
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
@lower(cmath.acos, types.Complex)
|
|
405
|
+
def acos_impl(context, builder, sig, args):
|
|
406
|
+
LN_4 = math.log(4)
|
|
407
|
+
THRES = mathimpl.FLT_MAX / 4
|
|
408
|
+
|
|
409
|
+
def acos_impl(z):
|
|
410
|
+
"""cmath.acos(z)"""
|
|
411
|
+
# CPython's algorithm (see c_acos() in cmathmodule.c)
|
|
412
|
+
if abs(z.real) > THRES or abs(z.imag) > THRES:
|
|
413
|
+
# Avoid unnecessary overflow for large arguments
|
|
414
|
+
# (also handles infinities gracefully)
|
|
415
|
+
real = math.atan2(abs(z.imag), z.real)
|
|
416
|
+
imag = math.copysign(
|
|
417
|
+
math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, -z.imag
|
|
418
|
+
)
|
|
419
|
+
return complex(real, imag)
|
|
420
|
+
else:
|
|
421
|
+
s1 = cmath.sqrt(complex(1.0 - z.real, -z.imag))
|
|
422
|
+
s2 = cmath.sqrt(complex(1.0 + z.real, z.imag))
|
|
423
|
+
real = 2.0 * math.atan2(s1.real, s2.real)
|
|
424
|
+
imag = math.asinh(s2.real * s1.imag - s2.imag * s1.real)
|
|
425
|
+
return complex(real, imag)
|
|
426
|
+
|
|
427
|
+
res = context.compile_internal(builder, acos_impl, sig, args)
|
|
428
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
@overload(cmath.acosh)
|
|
432
|
+
def impl_cmath_acosh(z):
|
|
433
|
+
if not isinstance(z, types.Complex):
|
|
434
|
+
return
|
|
435
|
+
|
|
436
|
+
LN_4 = math.log(4)
|
|
437
|
+
THRES = mathimpl.FLT_MAX / 4
|
|
438
|
+
|
|
439
|
+
def acosh_impl(z):
|
|
440
|
+
"""cmath.acosh(z)"""
|
|
441
|
+
# CPython's algorithm (see c_acosh() in cmathmodule.c)
|
|
442
|
+
if abs(z.real) > THRES or abs(z.imag) > THRES:
|
|
443
|
+
# Avoid unnecessary overflow for large arguments
|
|
444
|
+
# (also handles infinities gracefully)
|
|
445
|
+
real = math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4
|
|
446
|
+
imag = math.atan2(z.imag, z.real)
|
|
447
|
+
return complex(real, imag)
|
|
448
|
+
else:
|
|
449
|
+
s1 = cmath.sqrt(complex(z.real - 1.0, z.imag))
|
|
450
|
+
s2 = cmath.sqrt(complex(z.real + 1.0, z.imag))
|
|
451
|
+
real = math.asinh(s1.real * s2.real + s1.imag * s2.imag)
|
|
452
|
+
imag = 2.0 * math.atan2(s1.imag, s2.real)
|
|
453
|
+
return complex(real, imag)
|
|
454
|
+
# Condensed formula (NumPy)
|
|
455
|
+
# return cmath.log(z + cmath.sqrt(z + 1.) * cmath.sqrt(z - 1.))
|
|
456
|
+
|
|
457
|
+
return acosh_impl
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
@lower(cmath.asinh, types.Complex)
|
|
461
|
+
def asinh_impl(context, builder, sig, args):
|
|
462
|
+
LN_4 = math.log(4)
|
|
463
|
+
THRES = mathimpl.FLT_MAX / 4
|
|
464
|
+
|
|
465
|
+
def asinh_impl(z):
|
|
466
|
+
"""cmath.asinh(z)"""
|
|
467
|
+
# CPython's algorithm (see c_asinh() in cmathmodule.c)
|
|
468
|
+
if abs(z.real) > THRES or abs(z.imag) > THRES:
|
|
469
|
+
real = math.copysign(
|
|
470
|
+
math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, z.real
|
|
471
|
+
)
|
|
472
|
+
imag = math.atan2(z.imag, abs(z.real))
|
|
473
|
+
return complex(real, imag)
|
|
474
|
+
else:
|
|
475
|
+
s1 = cmath.sqrt(complex(1.0 + z.imag, -z.real))
|
|
476
|
+
s2 = cmath.sqrt(complex(1.0 - z.imag, z.real))
|
|
477
|
+
real = math.asinh(s1.real * s2.imag - s2.real * s1.imag)
|
|
478
|
+
imag = math.atan2(z.imag, s1.real * s2.real - s1.imag * s2.imag)
|
|
479
|
+
return complex(real, imag)
|
|
480
|
+
|
|
481
|
+
res = context.compile_internal(builder, asinh_impl, sig, args)
|
|
482
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
@lower(cmath.asin, types.Complex)
|
|
486
|
+
def asin_impl(context, builder, sig, args):
|
|
487
|
+
def asin_impl(z):
|
|
488
|
+
"""cmath.asin(z) = -j * cmath.asinh(z j)"""
|
|
489
|
+
r = cmath.asinh(complex(-z.imag, z.real))
|
|
490
|
+
return complex(r.imag, -r.real)
|
|
491
|
+
|
|
492
|
+
res = context.compile_internal(builder, asin_impl, sig, args)
|
|
493
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
@lower(cmath.atan, types.Complex)
|
|
497
|
+
def atan_impl(context, builder, sig, args):
|
|
498
|
+
def atan_impl(z):
|
|
499
|
+
"""cmath.atan(z) = -j * cmath.atanh(z j)"""
|
|
500
|
+
r = cmath.atanh(complex(-z.imag, z.real))
|
|
501
|
+
if math.isinf(z.real) and math.isnan(z.imag):
|
|
502
|
+
# XXX this is odd but necessary
|
|
503
|
+
return complex(r.imag, r.real)
|
|
504
|
+
else:
|
|
505
|
+
return complex(r.imag, -r.real)
|
|
506
|
+
|
|
507
|
+
res = context.compile_internal(builder, atan_impl, sig, args)
|
|
508
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
@lower(cmath.atanh, types.Complex)
|
|
512
|
+
def atanh_impl(context, builder, sig, args):
|
|
513
|
+
THRES_LARGE = math.sqrt(mathimpl.FLT_MAX / 4)
|
|
514
|
+
THRES_SMALL = math.sqrt(mathimpl.FLT_MIN)
|
|
515
|
+
PI_12 = math.pi / 2
|
|
516
|
+
|
|
517
|
+
def atanh_impl(z):
|
|
518
|
+
"""cmath.atanh(z)"""
|
|
519
|
+
# CPython's algorithm (see c_atanh() in cmathmodule.c)
|
|
520
|
+
if z.real < 0.0:
|
|
521
|
+
# Reduce to case where z.real >= 0., using atanh(z) = -atanh(-z).
|
|
522
|
+
negate = True
|
|
523
|
+
z = -z
|
|
524
|
+
else:
|
|
525
|
+
negate = False
|
|
526
|
+
|
|
527
|
+
ay = abs(z.imag)
|
|
528
|
+
if math.isnan(z.real) or z.real > THRES_LARGE or ay > THRES_LARGE:
|
|
529
|
+
if math.isinf(z.imag):
|
|
530
|
+
real = math.copysign(0.0, z.real)
|
|
531
|
+
elif math.isinf(z.real):
|
|
532
|
+
real = 0.0
|
|
533
|
+
else:
|
|
534
|
+
# may be safe from overflow, depending on hypot's implementation...
|
|
535
|
+
h = math.hypot(z.real * 0.5, z.imag * 0.5)
|
|
536
|
+
real = z.real / 4.0 / h / h
|
|
537
|
+
imag = -math.copysign(PI_12, -z.imag)
|
|
538
|
+
elif z.real == 1.0 and ay < THRES_SMALL:
|
|
539
|
+
# C99 standard says: atanh(1+/-0.) should be inf +/- 0j
|
|
540
|
+
if ay == 0.0:
|
|
541
|
+
real = INF
|
|
542
|
+
imag = z.imag
|
|
543
|
+
else:
|
|
544
|
+
real = -math.log(math.sqrt(ay) / math.sqrt(math.hypot(ay, 2.0)))
|
|
545
|
+
imag = math.copysign(math.atan2(2.0, -ay) / 2, z.imag)
|
|
546
|
+
else:
|
|
547
|
+
sqay = ay * ay
|
|
548
|
+
zr1 = 1 - z.real
|
|
549
|
+
real = math.log1p(4.0 * z.real / (zr1 * zr1 + sqay)) * 0.25
|
|
550
|
+
imag = -math.atan2(-2.0 * z.imag, zr1 * (1 + z.real) - sqay) * 0.5
|
|
551
|
+
|
|
552
|
+
if math.isnan(z.imag):
|
|
553
|
+
imag = NAN
|
|
554
|
+
if negate:
|
|
555
|
+
return complex(-real, -imag)
|
|
556
|
+
else:
|
|
557
|
+
return complex(real, imag)
|
|
558
|
+
|
|
559
|
+
res = context.compile_internal(builder, atanh_impl, sig, args)
|
|
560
|
+
return impl_ret_untracked(context, builder, sig, res)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Implementation of enums.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import operator
|
|
9
|
+
|
|
10
|
+
from numba.cuda.core.imputils import Registry, impl_ret_untracked
|
|
11
|
+
from numba.cuda import types
|
|
12
|
+
from numba.cuda.extending import overload_method
|
|
13
|
+
|
|
14
|
+
registry = Registry("enumimpl")
|
|
15
|
+
lower = registry.lower
|
|
16
|
+
lower_getattr = registry.lower_getattr
|
|
17
|
+
lower_getattr_generic = registry.lower_getattr_generic
|
|
18
|
+
lower_cast = registry.lower_cast
|
|
19
|
+
lower_constant = registry.lower_constant
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@lower(operator.eq, types.EnumMember, types.EnumMember)
|
|
23
|
+
def enum_eq(context, builder, sig, args):
|
|
24
|
+
tu, tv = sig.args
|
|
25
|
+
u, v = args
|
|
26
|
+
res = context.generic_compare(
|
|
27
|
+
builder, operator.eq, (tu.dtype, tv.dtype), (u, v)
|
|
28
|
+
)
|
|
29
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@lower(operator.is_, types.EnumMember, types.EnumMember)
|
|
33
|
+
def enum_is(context, builder, sig, args):
|
|
34
|
+
tu, tv = sig.args
|
|
35
|
+
u, v = args
|
|
36
|
+
if tu == tv:
|
|
37
|
+
res = context.generic_compare(
|
|
38
|
+
builder, operator.eq, (tu.dtype, tv.dtype), (u, v)
|
|
39
|
+
)
|
|
40
|
+
else:
|
|
41
|
+
res = context.get_constant(sig.return_type, False)
|
|
42
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@lower(operator.ne, types.EnumMember, types.EnumMember)
|
|
46
|
+
def enum_ne(context, builder, sig, args):
|
|
47
|
+
tu, tv = sig.args
|
|
48
|
+
u, v = args
|
|
49
|
+
res = context.generic_compare(
|
|
50
|
+
builder, operator.ne, (tu.dtype, tv.dtype), (u, v)
|
|
51
|
+
)
|
|
52
|
+
return impl_ret_untracked(context, builder, sig.return_type, res)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@lower_getattr(types.EnumMember, "value")
|
|
56
|
+
def enum_value(context, builder, ty, val):
|
|
57
|
+
return val
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@lower_cast(types.IntEnumMember, types.Integer)
|
|
61
|
+
def int_enum_to_int(context, builder, fromty, toty, val):
|
|
62
|
+
"""
|
|
63
|
+
Convert an IntEnum member to its raw integer value.
|
|
64
|
+
"""
|
|
65
|
+
return context.cast(builder, val, fromty.dtype, toty)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@lower_constant(types.EnumMember)
|
|
69
|
+
def enum_constant(context, builder, ty, pyval):
|
|
70
|
+
"""
|
|
71
|
+
Return a LLVM constant representing enum member *pyval*.
|
|
72
|
+
"""
|
|
73
|
+
return context.get_constant_generic(builder, ty.dtype, pyval.value)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@lower_getattr_generic(types.EnumClass)
|
|
77
|
+
def enum_class_getattr(context, builder, ty, val, attr):
|
|
78
|
+
"""
|
|
79
|
+
Return an enum member by attribute name.
|
|
80
|
+
"""
|
|
81
|
+
member = getattr(ty.instance_class, attr)
|
|
82
|
+
return context.get_constant_generic(builder, ty.dtype, member.value)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@lower("static_getitem", types.EnumClass, types.StringLiteral)
|
|
86
|
+
def enum_class_getitem(context, builder, sig, args):
|
|
87
|
+
"""
|
|
88
|
+
Return an enum member by index name.
|
|
89
|
+
"""
|
|
90
|
+
enum_cls_typ, idx = sig.args
|
|
91
|
+
member = enum_cls_typ.instance_class[idx.literal_value]
|
|
92
|
+
return context.get_constant_generic(
|
|
93
|
+
builder, enum_cls_typ.dtype, member.value
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@overload_method(types.IntEnumMember, "__hash__")
|
|
98
|
+
def intenum_hash(val):
|
|
99
|
+
# uses the hash of the value, for IntEnums this will be int.__hash__
|
|
100
|
+
def hash_impl(val):
|
|
101
|
+
return hash(val.value)
|
|
102
|
+
|
|
103
|
+
return hash_impl
|