nvmath-python 1.0.0__cp314-cp314t-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.
- nvmath/__init__.pxd +0 -0
- nvmath/__init__.py +45 -0
- nvmath/_internal/__init__.py +0 -0
- nvmath/_internal/attribute_ifc_factory.py +330 -0
- nvmath/_internal/layout.py +70 -0
- nvmath/_internal/templates.py +130 -0
- nvmath/_internal/threadsafe.py +106 -0
- nvmath/_internal/utils.py +43 -0
- nvmath/_internal/workspace.py +490 -0
- nvmath/_utils.py +147 -0
- nvmath/bindings/__init__.py +60 -0
- nvmath/bindings/_internal/__init__.pxd +0 -0
- nvmath/bindings/_internal/__init__.py +0 -0
- nvmath/bindings/_internal/common_types.pxd +31 -0
- nvmath/bindings/_internal/cublas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cublas.pxd +530 -0
- nvmath/bindings/_internal/cublasLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cublasLt.pxd +59 -0
- nvmath/bindings/_internal/cublasMp.pxd +52 -0
- nvmath/bindings/_internal/cudss.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cudss.pxd +54 -0
- nvmath/bindings/_internal/cufft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cufft.pxd +70 -0
- nvmath/bindings/_internal/cufftMp.pxd +77 -0
- nvmath/bindings/_internal/curand.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/curand.pxd +42 -0
- nvmath/bindings/_internal/cusolver.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cusolver.pxd +15 -0
- nvmath/bindings/_internal/cusolverDn.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cusolverDn.pxd +406 -0
- nvmath/bindings/_internal/cusolverMp.pxd +71 -0
- nvmath/bindings/_internal/cusolverSp.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cusolverSp.pxd +75 -0
- nvmath/bindings/_internal/cusparse.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cusparse.pxd +471 -0
- nvmath/bindings/_internal/cusparseLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cusparseLt.pxd +48 -0
- nvmath/bindings/_internal/cutensor.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/cutensor.pxd +58 -0
- nvmath/bindings/_internal/mathdx.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/mathdx.pxd +116 -0
- nvmath/bindings/_internal/nvshmem.pxd +29 -0
- nvmath/bindings/_internal/utils.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/_internal/utils.pxd +174 -0
- nvmath/bindings/_internal/utils.pyi +10 -0
- nvmath/bindings/cublas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cublas.pxd +558 -0
- nvmath/bindings/cublas.pyi +812 -0
- nvmath/bindings/cublasLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cublasLt.pxd +109 -0
- nvmath/bindings/cublasLt.pyi +1461 -0
- nvmath/bindings/cublasMp.pxd +85 -0
- nvmath/bindings/cublasMp.pyi +267 -0
- nvmath/bindings/cudss.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cudss.pxd +98 -0
- nvmath/bindings/cudss.pyi +443 -0
- nvmath/bindings/cufft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cufft.pxd +118 -0
- nvmath/bindings/cufft.pyi +301 -0
- nvmath/bindings/cufftMp.pxd +124 -0
- nvmath/bindings/cufftMp.pyi +326 -0
- nvmath/bindings/curand.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/curand.pxd +71 -0
- nvmath/bindings/curand.pyi +189 -0
- nvmath/bindings/cusolver.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cusolver.pxd +62 -0
- nvmath/bindings/cusolver.pyi +320 -0
- nvmath/bindings/cusolverDn.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cusolverDn.pxd +430 -0
- nvmath/bindings/cusolverDn.pyi +422 -0
- nvmath/bindings/cusolverMp.pxd +98 -0
- nvmath/bindings/cusolverMp.pyi +114 -0
- nvmath/bindings/cusolverSp.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cusolverSp.pxd +95 -0
- nvmath/bindings/cusolverSp.pyi +70 -0
- nvmath/bindings/cusparse.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cusparse.pxd +546 -0
- nvmath/bindings/cusparse.pyi +1017 -0
- nvmath/bindings/cusparseLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cusparseLt.pxd +99 -0
- nvmath/bindings/cusparseLt.pyi +252 -0
- nvmath/bindings/cutensor.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cutensor.pxd +98 -0
- nvmath/bindings/cutensor.pyi +324 -0
- nvmath/bindings/cycublas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycublas.pxd +664 -0
- nvmath/bindings/cycublasLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycublasLt.pxd +1045 -0
- nvmath/bindings/cycublasMp.pxd +171 -0
- nvmath/bindings/cycudss.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycudss.pxd +277 -0
- nvmath/bindings/cycufft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycufft.pxd +333 -0
- nvmath/bindings/cycufftMp.pxd +342 -0
- nvmath/bindings/cycurand.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycurand.pxd +141 -0
- nvmath/bindings/cycusolver.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycusolver.pxd +137 -0
- nvmath/bindings/cycusolverDn.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycusolverDn.pxd +443 -0
- nvmath/bindings/cycusolverMp.pxd +107 -0
- nvmath/bindings/cycusolverSp.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycusolverSp.pxd +93 -0
- nvmath/bindings/cycusparse.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycusparse.pxd +679 -0
- nvmath/bindings/cycusparseLt.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycusparseLt.pxd +135 -0
- nvmath/bindings/cycutensor.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cycutensor.pxd +189 -0
- nvmath/bindings/cymathdx.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/cymathdx.pxd +552 -0
- nvmath/bindings/cynvshmem.pxd +118 -0
- nvmath/bindings/mathdx.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/mathdx.pxd +182 -0
- nvmath/bindings/mathdx.pyi +1562 -0
- nvmath/bindings/nvpl/__init__.pxd +0 -0
- nvmath/bindings/nvpl/__init__.py +13 -0
- nvmath/bindings/nvpl/_internal/__init__.pxd +0 -0
- nvmath/bindings/nvpl/_internal/__init__.py +0 -0
- nvmath/bindings/nvpl/_internal/blas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/_internal/blas.pxd +237 -0
- nvmath/bindings/nvpl/_internal/fft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/_internal/fft.pxd +36 -0
- nvmath/bindings/nvpl/blas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/blas.pxd +131 -0
- nvmath/bindings/nvpl/blas.pyi +168 -0
- nvmath/bindings/nvpl/cyblas.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/cyblas.pxd +280 -0
- nvmath/bindings/nvpl/cyfft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/cyfft.pxd +93 -0
- nvmath/bindings/nvpl/fft.cp314t-win_amd64.pyd +0 -0
- nvmath/bindings/nvpl/fft.pxd +100 -0
- nvmath/bindings/nvpl/fft.pyi +168 -0
- nvmath/bindings/nvshmem.pxd +54 -0
- nvmath/bindings/nvshmem.pyi +191 -0
- nvmath/device/__init__.py +38 -0
- nvmath/device/_deprecated.py +33 -0
- nvmath/device/common.py +315 -0
- nvmath/device/common_backend.py +131 -0
- nvmath/device/common_cuda.py +201 -0
- nvmath/device/common_numba.py +300 -0
- nvmath/device/common_numba_cuda_mlir.py +202 -0
- nvmath/device/common_opaque_tensor.py +201 -0
- nvmath/device/cublasdx.py +1606 -0
- nvmath/device/cublasdx_backend.py +860 -0
- nvmath/device/cublasdx_numba.py +1534 -0
- nvmath/device/cublasdx_numba_cuda_mlir.py +208 -0
- nvmath/device/cufftdx.py +373 -0
- nvmath/device/cufftdx_backend.py +220 -0
- nvmath/device/cufftdx_numba.py +140 -0
- nvmath/device/cufftdx_numba_cuda_mlir.py +79 -0
- nvmath/device/curand_kernel.py +9147 -0
- nvmath/device/cusolverdx.py +2708 -0
- nvmath/device/cusolverdx_backend.py +440 -0
- nvmath/device/cusolverdx_numba.py +567 -0
- nvmath/device/cusolverdx_numba_cuda_mlir.py +604 -0
- nvmath/device/cusolverdx_overload_backend.py +1029 -0
- nvmath/device/llvm_array.py +29 -0
- nvmath/device/random.py +441 -0
- nvmath/device/random_helpers.py +23 -0
- nvmath/device/random_states.py +187 -0
- nvmath/device/types.py +138 -0
- nvmath/device/vector_types_numba.py +259 -0
- nvmath/distributed/__init__.py +200 -0
- nvmath/distributed/_internal/__init__.py +0 -0
- nvmath/distributed/_internal/nccl.py +86 -0
- nvmath/distributed/_internal/nvshmem.py +307 -0
- nvmath/distributed/_internal/symmetric_memory.py +35 -0
- nvmath/distributed/_internal/tensor_ifc.py +70 -0
- nvmath/distributed/_internal/tensor_ifc_cupy.py +68 -0
- nvmath/distributed/_internal/tensor_ifc_host_device.py +172 -0
- nvmath/distributed/_internal/tensor_ifc_numpy.py +46 -0
- nvmath/distributed/_internal/tensor_ifc_torch.py +162 -0
- nvmath/distributed/_internal/tensor_wrapper.py +81 -0
- nvmath/distributed/_utils.py +167 -0
- nvmath/distributed/distribution/__init__.py +30 -0
- nvmath/distributed/distribution/_configuration.py +39 -0
- nvmath/distributed/distribution/distributions.py +1024 -0
- nvmath/distributed/distribution/redistribute.py +1284 -0
- nvmath/distributed/fft/__init__.py +7 -0
- nvmath/distributed/fft/_configuration.py +82 -0
- nvmath/distributed/fft/fft.py +2742 -0
- nvmath/distributed/linalg/__init__.py +22 -0
- nvmath/distributed/linalg/_internal/__init__.py +3 -0
- nvmath/distributed/linalg/_internal/epilog_protocol.py +586 -0
- nvmath/distributed/linalg/_internal/matmul_desc_ifc.py +28 -0
- nvmath/distributed/linalg/advanced/__init__.py +8 -0
- nvmath/distributed/linalg/advanced/_configuration.py +171 -0
- nvmath/distributed/linalg/advanced/matmulmod.py +3573 -0
- nvmath/distributed/linalg/generic/__init__.py +8 -0
- nvmath/distributed/linalg/generic/_caching.py +66 -0
- nvmath/distributed/linalg/generic/_configuration.py +61 -0
- nvmath/distributed/linalg/generic/_factorization.py +172 -0
- nvmath/distributed/linalg/generic/_initialization.py +966 -0
- nvmath/distributed/linalg/generic/_problem_spec.py +511 -0
- nvmath/distributed/linalg/generic/solvermod.py +1368 -0
- nvmath/distributed/process_group.py +408 -0
- nvmath/fft/__init__.py +7 -0
- nvmath/fft/_configuration.py +189 -0
- nvmath/fft/_exec_utils.py +82 -0
- nvmath/fft/_helpers.py +237 -0
- nvmath/fft/fft.py +3122 -0
- nvmath/internal/__init__.pxd +3 -0
- nvmath/internal/__init__.py +10 -0
- nvmath/internal/_bindings.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/_bindings.pxd +18 -0
- nvmath/internal/_device_utils.py +45 -0
- nvmath/internal/_layout/__init__.pxd +3 -0
- nvmath/internal/_layout/__init__.py +7 -0
- nvmath/internal/_layout/_layout.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/_layout/_layout.pxd +1303 -0
- nvmath/internal/_layout/_layout.pyi +1145 -0
- nvmath/internal/enum_utils.py +142 -0
- nvmath/internal/formatters.py +87 -0
- nvmath/internal/mem_limit.py +51 -0
- nvmath/internal/memory.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/memory.pxd +13 -0
- nvmath/internal/memory.pyi +50 -0
- nvmath/internal/ndbuffer/__init__.pxd +3 -0
- nvmath/internal/ndbuffer/__init__.py +9 -0
- nvmath/internal/ndbuffer/_copy_kernel.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/ndbuffer/_copy_kernel.pxd +10 -0
- nvmath/internal/ndbuffer/_jit.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/ndbuffer/_jit.pxd +7 -0
- nvmath/internal/ndbuffer/_ndbuffer.cp314t-win_amd64.pyd +0 -0
- nvmath/internal/ndbuffer/_ndbuffer.pxd +40 -0
- nvmath/internal/ndbuffer/_ndbuffer.pyi +463 -0
- nvmath/internal/ndbuffer/copy_kernel/args.h +34 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/array_view.h +52 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/elementwise.h +68 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/grid_indexer.h +69 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/transposed.h +242 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/type_utils.h +39 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/utils.h +132 -0
- nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/vec.h +159 -0
- nvmath/internal/ndbuffer/copy_kernel/elementwise.h +53 -0
- nvmath/internal/ndbuffer/copy_kernel/transposed.h +58 -0
- nvmath/internal/package_ifc.py +168 -0
- nvmath/internal/package_ifc_cuda.py +57 -0
- nvmath/internal/package_ifc_cupy.py +67 -0
- nvmath/internal/package_ifc_torch.py +69 -0
- nvmath/internal/package_wrapper.py +14 -0
- nvmath/internal/tensor_ifc.py +179 -0
- nvmath/internal/tensor_ifc_cupy.py +234 -0
- nvmath/internal/tensor_ifc_ndbuffer.py +147 -0
- nvmath/internal/tensor_ifc_numpy.py +184 -0
- nvmath/internal/tensor_ifc_torch.py +178 -0
- nvmath/internal/tensor_wrapper.py +160 -0
- nvmath/internal/typemaps.py +113 -0
- nvmath/internal/utils.py +805 -0
- nvmath/linalg/__init__.py +56 -0
- nvmath/linalg/_internal/__init__.py +3 -0
- nvmath/linalg/_internal/algo_cap_ifc.py +82 -0
- nvmath/linalg/_internal/algo_config_ifc.py +43 -0
- nvmath/linalg/_internal/batch.py +234 -0
- nvmath/linalg/_internal/enum_to_tuples.py +64 -0
- nvmath/linalg/_internal/epilog_protocol.py +766 -0
- nvmath/linalg/_internal/layout.py +624 -0
- nvmath/linalg/_internal/matmul_desc_ifc.py +28 -0
- nvmath/linalg/_internal/matmul_pref_ifc.py +27 -0
- nvmath/linalg/_internal/matrix_layout_ifc.py +26 -0
- nvmath/linalg/_internal/solver_utils.py +432 -0
- nvmath/linalg/_internal/typemaps.py +144 -0
- nvmath/linalg/_internal/utils.py +157 -0
- nvmath/linalg/advanced/__init__.py +8 -0
- nvmath/linalg/advanced/_algorithmmod.py +170 -0
- nvmath/linalg/advanced/_configuration.py +351 -0
- nvmath/linalg/advanced/helpers/__init__.py +5 -0
- nvmath/linalg/advanced/helpers/matmul.py +1316 -0
- nvmath/linalg/advanced/matmulmod.py +3734 -0
- nvmath/linalg/generic/__init__.py +53 -0
- nvmath/linalg/generic/_configuration/__init__.py +39 -0
- nvmath/linalg/generic/_configuration/layout.py +263 -0
- nvmath/linalg/generic/_configuration/match.py +734 -0
- nvmath/linalg/generic/_configuration/qualifiers.py +493 -0
- nvmath/linalg/generic/_configuration/solver_configuration.py +59 -0
- nvmath/linalg/generic/_configuration/wrap.py +217 -0
- nvmath/linalg/generic/_dtype.py +15 -0
- nvmath/linalg/generic/matmulmod.py +2094 -0
- nvmath/linalg/generic/solvermod.py +1301 -0
- nvmath/memory.py +279 -0
- nvmath/sparse/__init__.py +38 -0
- nvmath/sparse/_internal/__init__.py +21 -0
- nvmath/sparse/_internal/common_utils.py +147 -0
- nvmath/sparse/_internal/cudss_config_ifc.py +702 -0
- nvmath/sparse/_internal/cudss_data_ifc.py +399 -0
- nvmath/sparse/_internal/cudss_utils.py +506 -0
- nvmath/sparse/_internal/cusparse_utils.py +382 -0
- nvmath/sparse/_internal/sparse_bsc_ifc.py +303 -0
- nvmath/sparse/_internal/sparse_bsr_ifc.py +305 -0
- nvmath/sparse/_internal/sparse_coo_ifc.py +256 -0
- nvmath/sparse/_internal/sparse_csc_ifc.py +268 -0
- nvmath/sparse/_internal/sparse_csr_ifc.py +288 -0
- nvmath/sparse/_internal/sparse_dia_ifc.py +242 -0
- nvmath/sparse/_internal/sparse_format_helpers.py +601 -0
- nvmath/sparse/_internal/sparse_tensor_ifc.py +133 -0
- nvmath/sparse/_internal/sparse_ust_ifc.py +141 -0
- nvmath/sparse/_internal/utils.py +56 -0
- nvmath/sparse/advanced/__init__.py +7 -0
- nvmath/sparse/advanced/_configuration.py +227 -0
- nvmath/sparse/advanced/direct_solver.py +2069 -0
- nvmath/sparse/generic/__init__.py +7 -0
- nvmath/sparse/generic/_configuration.py +129 -0
- nvmath/sparse/generic/_helpers.py +137 -0
- nvmath/sparse/generic/_thunks.py +21 -0
- nvmath/sparse/generic/matmulmod.py +2353 -0
- nvmath/sparse/ust/__init__.py +7 -0
- nvmath/sparse/ust/_converters.py +422 -0
- nvmath/sparse/ust/_cpp.py +28 -0
- nvmath/sparse/ust/_drawer.py +565 -0
- nvmath/sparse/ust/_emitter.py +1033 -0
- nvmath/sparse/ust/_jit.py +188 -0
- nvmath/sparse/ust/_kernel.py +282 -0
- nvmath/sparse/ust/_utils.py +149 -0
- nvmath/sparse/ust/interfaces/__init__.py +0 -0
- nvmath/sparse/ust/interfaces/torch_interface.py +476 -0
- nvmath/sparse/ust/tensor.py +1016 -0
- nvmath/sparse/ust/tensor_format.py +957 -0
- nvmath/tensor/__init__.py +6 -0
- nvmath/tensor/_configuration.py +120 -0
- nvmath/tensor/_internal/__init__.py +3 -0
- nvmath/tensor/_internal/cutensor_config_ifc.py +279 -0
- nvmath/tensor/_internal/cutensor_utils.py +230 -0
- nvmath/tensor/_internal/data.py +43 -0
- nvmath/tensor/_internal/einsum_parser.py +444 -0
- nvmath/tensor/_internal/typemaps.py +96 -0
- nvmath/tensor/contract.py +1900 -0
- nvmath_python-1.0.0.dist-info/METADATA +134 -0
- nvmath_python-1.0.0.dist-info/RECORD +332 -0
- nvmath_python-1.0.0.dist-info/WHEEL +5 -0
- nvmath_python-1.0.0.dist-info/licenses/LICENSE +177 -0
- nvmath_python-1.0.0.dist-info/top_level.txt +2 -0
nvmath/fft/_helpers.py
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
__all__ = ["compile_prolog", "compile_epilog"]
|
|
6
|
+
|
|
7
|
+
import functools
|
|
8
|
+
|
|
9
|
+
from nvmath.bindings import cufft as _cufft # type: ignore
|
|
10
|
+
|
|
11
|
+
# Currently supported element data types for FFT callback functions.
|
|
12
|
+
VALID_DTYPES = {"float32": "Real", "float64": "DoubleReal", "complex64": "Complex", "complex128": "DoubleComplex"}
|
|
13
|
+
|
|
14
|
+
# Python <> CUDA magled types.
|
|
15
|
+
TYPE_MAP = {
|
|
16
|
+
"float32": "f", # float
|
|
17
|
+
"float64": "d", # double
|
|
18
|
+
"complex64": "6float2", # float2
|
|
19
|
+
"complex128": "7double2", # double2
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _check_numba_available():
|
|
24
|
+
try:
|
|
25
|
+
import numba # noqa: F401
|
|
26
|
+
except ModuleNotFoundError as e:
|
|
27
|
+
raise RuntimeError("Numba is required to compile FFT prolog and epilog functions.") from e
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _compile(
|
|
31
|
+
function, element_dtype, user_info_dtype, *, name=None, phase=None, representation="ltoir", compute_capability=None
|
|
32
|
+
):
|
|
33
|
+
_check_numba_available()
|
|
34
|
+
|
|
35
|
+
import numba
|
|
36
|
+
import numba.cuda
|
|
37
|
+
|
|
38
|
+
assert phase in ["Load", "Store"], "Internal error."
|
|
39
|
+
|
|
40
|
+
if element_dtype not in VALID_DTYPES:
|
|
41
|
+
raise ValueError(
|
|
42
|
+
f"The specified operand data type '{element_dtype}' is not currently supported. "
|
|
43
|
+
f"It must be one of {VALID_DTYPES.keys()}."
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
data_type = getattr(numba.cuda.types.types, element_dtype)
|
|
47
|
+
|
|
48
|
+
if user_info_dtype in VALID_DTYPES:
|
|
49
|
+
info_type = getattr(numba.cuda.types.types, user_info_dtype)
|
|
50
|
+
elif isinstance(user_info_dtype, numba.types.Type):
|
|
51
|
+
info_type = user_info_dtype
|
|
52
|
+
else:
|
|
53
|
+
raise ValueError(
|
|
54
|
+
f"The specified user information data type '{user_info_dtype}' is not supported. "
|
|
55
|
+
f"It must be a Numba custom type or one of {VALID_DTYPES.keys()}."
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
dataptr_type = numba.types.CPointer(data_type)
|
|
59
|
+
infoptr_type = numba.types.CPointer(info_type)
|
|
60
|
+
offset_type = numba.types.uint64
|
|
61
|
+
smemptr_type = dataptr_type
|
|
62
|
+
|
|
63
|
+
if phase == "Load":
|
|
64
|
+
insert = ""
|
|
65
|
+
return_type = data_type
|
|
66
|
+
signature = numba.core.typing.signature(return_type, dataptr_type, offset_type, infoptr_type, smemptr_type)
|
|
67
|
+
else:
|
|
68
|
+
insert = TYPE_MAP[element_dtype]
|
|
69
|
+
return_type = numba.types.void
|
|
70
|
+
signature = numba.core.typing.signature(return_type, dataptr_type, offset_type, data_type, infoptr_type, smemptr_type)
|
|
71
|
+
|
|
72
|
+
if name is None:
|
|
73
|
+
snippet = VALID_DTYPES[element_dtype]
|
|
74
|
+
length = 16 + len(phase) + len(snippet)
|
|
75
|
+
# the signature of callbacks differs - the offset argument
|
|
76
|
+
# changed type from size_t to unsigned long long int
|
|
77
|
+
offset_dtype = "m" if _cufft.get_version() < 11300 else "y"
|
|
78
|
+
name = f"_Z{length}cufftJITCallback{phase}{snippet}Pv{offset_dtype}{insert}S_S_"
|
|
79
|
+
|
|
80
|
+
if compute_capability is None:
|
|
81
|
+
compute_capability = numba.cuda.get_current_device().compute_capability
|
|
82
|
+
else:
|
|
83
|
+
if not isinstance(compute_capability, str):
|
|
84
|
+
raise ValueError(
|
|
85
|
+
f"The compute capability must be specified as a string ('80', '89', ...). "
|
|
86
|
+
f"The provided value {compute_capability} is invalid."
|
|
87
|
+
)
|
|
88
|
+
cc_number = int(compute_capability)
|
|
89
|
+
compute_capability = (cc_number // 10, cc_number % 10)
|
|
90
|
+
|
|
91
|
+
return numba.cuda.compile(
|
|
92
|
+
function,
|
|
93
|
+
signature,
|
|
94
|
+
debug=None,
|
|
95
|
+
lineinfo=False,
|
|
96
|
+
device=True,
|
|
97
|
+
fastmath=False,
|
|
98
|
+
cc=compute_capability,
|
|
99
|
+
opt=True,
|
|
100
|
+
abi="c",
|
|
101
|
+
abi_info={"abi_name": name},
|
|
102
|
+
output=representation,
|
|
103
|
+
forceinline=False,
|
|
104
|
+
launch_bounds=None,
|
|
105
|
+
)[0]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
compile_prolog = functools.wraps(_compile)(functools.partial(_compile, phase="Load"))
|
|
109
|
+
compile_epilog = functools.wraps(_compile)(functools.partial(_compile, phase="Store"))
|
|
110
|
+
|
|
111
|
+
SHARED_FFT_HELPER_DOCUMENTATION = {
|
|
112
|
+
"element_dtype": """The data type of the ``data_in`` argument, one of ``['float32', 'float64', 'complex64',
|
|
113
|
+
'complex128']``. It must have the same data type as that of the FFT operand for prolog functions or the FFT
|
|
114
|
+
result for epilog functions.""",
|
|
115
|
+
"user_info_dtype": """The data type of the ``user_info`` argument. It must be one of ``['float32', 'float64',
|
|
116
|
+
'complex64', 'complex128']`` or an object of type :class:`numba.types.Type`. The offset is computed based on
|
|
117
|
+
the memory layout (shape and strides) of the operand (input for prolog, output for epilog). If the user
|
|
118
|
+
would like to pass additional tensor as `user_info` and access it based on the offset, it is crucial to know
|
|
119
|
+
memory layout of the operand. Please note, the actual layout of the input tensor may differ from the layout
|
|
120
|
+
of the tensor passed to fft call. To learn the memory layout of the input or output, please use stateful FFT
|
|
121
|
+
API and :meth:`nvmath.fft.FFT.get_input_layout` :meth:`nvmath.fft.FFT.get_output_layout` respectively.
|
|
122
|
+
|
|
123
|
+
.. note::
|
|
124
|
+
Currently, in the callback, the position of the element in the input and output operands are described
|
|
125
|
+
with a single flat offset, even if the original operand is multi-dimensional tensor.
|
|
126
|
+
|
|
127
|
+
""",
|
|
128
|
+
"compute_capability": """The target compute capability, specified as a string (``'80'``, ``'89'``, ...). The
|
|
129
|
+
default is the compute capability of the current device. For cuFFT in CUDA Toolkit 12.8, 12.9
|
|
130
|
+
on Blackwell devices (compute capability 12.0), the default
|
|
131
|
+
compute capability of the current device may fail to compile. As a workaround, ``'50'``
|
|
132
|
+
can be specified.""",
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
compile_prolog.__doc__ = """
|
|
136
|
+
compile_prolog(prolog_fn, element_dtype, user_info_dtype, *, compute_capability=None)
|
|
137
|
+
|
|
138
|
+
Compile a Python function to LTO-IR to provide as a prolog function for
|
|
139
|
+
:func:`~nvmath.fft.fft` and :meth:`~nvmath.fft.FFT.plan`.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
prolog_fn: The prolog function to be compiled to LTO-IR. It must have the signature:
|
|
143
|
+
``prolog_fn(data_in, offset, user_info, reserved_for_future_use)``, and it
|
|
144
|
+
essentially returns transformed ``data_in`` at ``offset``.
|
|
145
|
+
|
|
146
|
+
element_dtype: {element_dtype}
|
|
147
|
+
|
|
148
|
+
user_info_dtype: {user_info_dtype}
|
|
149
|
+
|
|
150
|
+
compute_capability: {compute_capability}
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
The function compiled to LTO-IR as `bytes` object.
|
|
154
|
+
|
|
155
|
+
.. seealso::
|
|
156
|
+
:func:`~nvmath.fft.fft`, :meth:`~nvmath.fft.FFT.plan`,
|
|
157
|
+
:func:`~nvmath.fft.compile_epilog`.
|
|
158
|
+
|
|
159
|
+
Notes:
|
|
160
|
+
- The user must ensure that the specified argument types meet the requirements
|
|
161
|
+
listed above.
|
|
162
|
+
""".format(**SHARED_FFT_HELPER_DOCUMENTATION)
|
|
163
|
+
compile_prolog.__name__ = "compile_prolog"
|
|
164
|
+
|
|
165
|
+
compile_epilog.__doc__ = """
|
|
166
|
+
compile_epilog(epilog_fn, element_dtype, user_info_dtype, *, compute_capability=None)
|
|
167
|
+
|
|
168
|
+
Compile a Python function to LTO-IR to provide as an epilog function for
|
|
169
|
+
:func:`~nvmath.fft.fft` and :meth:`~nvmath.fft.FFT.plan`.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
epilog_fn: The epilog function to be compiled to LTO-IR. It must have the signature:
|
|
173
|
+
``epilog_fn(data_out, offset, data, user_info, reserved_for_future_use)``, and
|
|
174
|
+
it essentially stores transformed ``data`` into ``data_out`` at ``offset``.
|
|
175
|
+
|
|
176
|
+
element_dtype: {element_dtype}
|
|
177
|
+
|
|
178
|
+
user_info_dtype: {user_info_dtype}
|
|
179
|
+
|
|
180
|
+
compute_capability: {compute_capability}
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
The function compiled to LTO-IR as `bytes` object.
|
|
184
|
+
|
|
185
|
+
.. seealso::
|
|
186
|
+
:func:`~nvmath.fft.fft`, :meth:`~nvmath.fft.FFT.plan`,
|
|
187
|
+
:func:`~nvmath.fft.compile_prolog`.
|
|
188
|
+
|
|
189
|
+
Examples:
|
|
190
|
+
|
|
191
|
+
The cuFFT library expects the end user to manage scaling of the outputs, so in order
|
|
192
|
+
to replicate the ``norm`` option found in `other Python FFT libraries
|
|
193
|
+
<https://numpy.org/doc/stable/reference/routines.fft.html#normalization>`_ we can
|
|
194
|
+
define an epilog which performs the scaling.
|
|
195
|
+
|
|
196
|
+
>>> import cupy as cp
|
|
197
|
+
>>> import nvmath
|
|
198
|
+
>>> import math
|
|
199
|
+
|
|
200
|
+
Create the data for a batched 1-D FFT.
|
|
201
|
+
|
|
202
|
+
>>> B, N = 256, 1024
|
|
203
|
+
>>> a = cp.random.rand(B, N, dtype=cp.float64) + 1j * cp.random.rand(B, N, dtype=cp.float64)
|
|
204
|
+
|
|
205
|
+
Compute a normalization factor that will create unitary transforms.
|
|
206
|
+
|
|
207
|
+
>>> norm_factor = 1.0 / math.sqrt(N)
|
|
208
|
+
|
|
209
|
+
Define the epilog function for the FFT.
|
|
210
|
+
|
|
211
|
+
>>> def rescale(data_out, offset, data, user_info, unused):
|
|
212
|
+
... data_out[offset] = data * norm_factor
|
|
213
|
+
|
|
214
|
+
Compile the epilog to LTO-IR. In a system with GPUs that have different compute
|
|
215
|
+
capability, the `compute_capability` option must be specified to the
|
|
216
|
+
`compile_prolog` or `compile_epilog` helpers. Alternatively, the epilog can be
|
|
217
|
+
compiled in the context of the device where the FFT to which the epilog is provided
|
|
218
|
+
is executed. In this case we use the current device context, where the operands have
|
|
219
|
+
been created.
|
|
220
|
+
|
|
221
|
+
>>> with cp.cuda.Device():
|
|
222
|
+
... epilog = nvmath.fft.compile_epilog(rescale, "complex128", "complex128")
|
|
223
|
+
|
|
224
|
+
Perform the forward FFT, applying the rescaling as a epilog.
|
|
225
|
+
|
|
226
|
+
>>> r = nvmath.fft.fft(a, axes=[-1], epilog=dict(ltoir=epilog))
|
|
227
|
+
|
|
228
|
+
Test that the fused FFT run result matches the result of other libraries.
|
|
229
|
+
|
|
230
|
+
>>> s = cp.fft.fftn(a, axes=[-1], norm="ortho")
|
|
231
|
+
>>> assert cp.allclose(r, s)
|
|
232
|
+
|
|
233
|
+
Notes:
|
|
234
|
+
- The user must ensure that the specified argument types meet the requirements
|
|
235
|
+
listed above.
|
|
236
|
+
""".format(**SHARED_FFT_HELPER_DOCUMENTATION)
|
|
237
|
+
compile_epilog.__name__ = "compile_epilog"
|