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
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from numba_cuda_mlir import types
|
|
6
|
+
from numba_cuda_mlir.compiler import declare_device
|
|
7
|
+
from numba_cuda_mlir.extending import (
|
|
8
|
+
overload,
|
|
9
|
+
overload_method,
|
|
10
|
+
typing_registry,
|
|
11
|
+
)
|
|
12
|
+
from numba_cuda_mlir.lowering_utilities.type_conversions import to_numba_type
|
|
13
|
+
from numba_cuda_mlir.numba_cuda.cudadrv.linkable_code import LTOIR
|
|
14
|
+
from numba_cuda_mlir.numba_cuda.extending import typeof_impl
|
|
15
|
+
|
|
16
|
+
from nvmath.device.common import (
|
|
17
|
+
axpby,
|
|
18
|
+
clear,
|
|
19
|
+
copy,
|
|
20
|
+
copy_fragment,
|
|
21
|
+
copy_wait,
|
|
22
|
+
make_fragment_like,
|
|
23
|
+
make_tensor,
|
|
24
|
+
)
|
|
25
|
+
from nvmath.device.common_cuda import get_default_code_type
|
|
26
|
+
from nvmath.device.common_numba_cuda_mlir import (
|
|
27
|
+
HostDescriptorBase,
|
|
28
|
+
get_array_pointer,
|
|
29
|
+
get_value_ptr,
|
|
30
|
+
int_to_uint32_ptr,
|
|
31
|
+
register_dummy_type,
|
|
32
|
+
)
|
|
33
|
+
from nvmath.device.cublasdx import (
|
|
34
|
+
DevicePipeline,
|
|
35
|
+
Matmul,
|
|
36
|
+
TilePipeline,
|
|
37
|
+
_BlasMatmulLayout,
|
|
38
|
+
_BlasMatmulLikeLayout,
|
|
39
|
+
compile_blas_execute,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
from .cublasdx_backend import (
|
|
43
|
+
_BLAS_COMPILED_ARGS,
|
|
44
|
+
_BLAS_DEFINITION_ARGS,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# ==============================================
|
|
48
|
+
# Helpers
|
|
49
|
+
# ==============================================
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _check_array_value_types(MM: Matmul, a: types.Array, b: types.Array, c: types.Array) -> bool:
|
|
53
|
+
expected = tuple(to_numba_type(vt) for vt in MM._traits.value_types)
|
|
54
|
+
return (a.dtype, b.dtype, c.dtype) == expected
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
_NOT_SUPPORTED = (
|
|
58
|
+
"Advanced matmul and opaque tensor APIs are not yet supported by the numba-cuda-mlir backend."
|
|
59
|
+
" Only Matmul.execute with array operands is available."
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _unsupported(*args, **kwargs):
|
|
64
|
+
raise NotImplementedError(_NOT_SUPPORTED)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ==============================================
|
|
68
|
+
# Matmul Type
|
|
69
|
+
# ==============================================
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class BlasType(HostDescriptorBase):
|
|
73
|
+
"""
|
|
74
|
+
Type class associated with the `cublasdx.Matmul`.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def __init__(self, blas: Matmul) -> None:
|
|
78
|
+
assert isinstance(blas, Matmul)
|
|
79
|
+
super().__init__(blas, _BLAS_DEFINITION_ARGS, "BlasNumba")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
register_dummy_type(BlasType, Matmul, _BLAS_DEFINITION_ARGS + _BLAS_COMPILED_ARGS)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ==============================================
|
|
86
|
+
# Matmul executes
|
|
87
|
+
# ==============================================
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@overload_method(BlasType, "execute", strict=False, typing_registry=typing_registry)
|
|
91
|
+
def ol_blas_execute(blas_numba: BlasType, _arg1, _arg2, _arg3, _arg4=None, _arg5=None, _arg6=None, _arg7=None, _arg8=None):
|
|
92
|
+
if not isinstance(blas_numba, BlasType):
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
none_set = {None, types.Omitted(None)}
|
|
96
|
+
MM = blas_numba.host_descriptor
|
|
97
|
+
|
|
98
|
+
if {_arg4, _arg5, _arg6, _arg7, _arg8} <= none_set:
|
|
99
|
+
_unsupported()
|
|
100
|
+
|
|
101
|
+
if {_arg6, _arg7, _arg8} <= none_set:
|
|
102
|
+
if not all(isinstance(x, types.Array) for x in (_arg2, _arg3, _arg5)):
|
|
103
|
+
_unsupported()
|
|
104
|
+
return _build_basic_impl(MM, _arg1, _arg2, _arg3, _arg4, _arg5)
|
|
105
|
+
|
|
106
|
+
if not all(isinstance(x, types.Array) for x in (_arg2, _arg4, _arg7)):
|
|
107
|
+
_unsupported()
|
|
108
|
+
return _build_ldabc_impl(MM, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _build_basic_impl(MM: Matmul, alpha, a, b, beta, c):
|
|
112
|
+
if (
|
|
113
|
+
not all(isinstance(x, types.Number) for x in (alpha, beta))
|
|
114
|
+
or not all(isinstance(x, types.Array) for x in (a, b, c))
|
|
115
|
+
or not _check_array_value_types(MM, a, b, c)
|
|
116
|
+
):
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
code, symbol = compile_blas_execute(
|
|
120
|
+
MM,
|
|
121
|
+
code_type=get_default_code_type(),
|
|
122
|
+
execute_api="static_leading_dimensions",
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
c_value_type = MM.c_value_type
|
|
126
|
+
c_ptr = types.CPointer(c.dtype)
|
|
127
|
+
sig = types.void(c_ptr, types.CPointer(a.dtype), types.CPointer(b.dtype), c_ptr, c_ptr)
|
|
128
|
+
blas_device_func = declare_device(symbol, sig, link=LTOIR(code.data), abi="c")
|
|
129
|
+
|
|
130
|
+
def impl(_, alpha, a, b, beta, c, _arg6=None, _arg7=None, _arg8=None):
|
|
131
|
+
aptr = get_array_pointer(a)
|
|
132
|
+
bptr = get_array_pointer(b)
|
|
133
|
+
cptr = get_array_pointer(c)
|
|
134
|
+
alpha_ptr = get_value_ptr(c_value_type(alpha))
|
|
135
|
+
beta_ptr = get_value_ptr(c_value_type(beta))
|
|
136
|
+
|
|
137
|
+
blas_device_func(alpha_ptr, aptr, bptr, beta_ptr, cptr)
|
|
138
|
+
|
|
139
|
+
return impl
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _build_ldabc_impl(MM: Matmul, alpha, a, lda, b, ldb, beta, c, ldc):
|
|
143
|
+
if (
|
|
144
|
+
not all(isinstance(x, types.Number) for x in (alpha, beta))
|
|
145
|
+
or not all(isinstance(x, types.Array) for x in (a, b, c))
|
|
146
|
+
or not all(isinstance(x, types.Integer) for x in (lda, ldb, ldc))
|
|
147
|
+
or not _check_array_value_types(MM, a, b, c)
|
|
148
|
+
):
|
|
149
|
+
return None
|
|
150
|
+
|
|
151
|
+
code, symbol = compile_blas_execute(
|
|
152
|
+
MM,
|
|
153
|
+
code_type=get_default_code_type(),
|
|
154
|
+
execute_api="dynamic_leading_dimensions",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
c_value_type = MM.c_value_type
|
|
158
|
+
ld_ptr = types.CPointer(types.uint32)
|
|
159
|
+
c_ptr = types.CPointer(c.dtype)
|
|
160
|
+
sig = types.void(c_ptr, types.CPointer(a.dtype), ld_ptr, types.CPointer(b.dtype), ld_ptr, c_ptr, c_ptr, ld_ptr)
|
|
161
|
+
blas_device_func = declare_device(symbol, sig, link=LTOIR(code.data), abi="c")
|
|
162
|
+
|
|
163
|
+
def impl(_, alpha, a, lda, b, ldb, beta, c, ldc):
|
|
164
|
+
aptr = get_array_pointer(a)
|
|
165
|
+
bptr = get_array_pointer(b)
|
|
166
|
+
cptr = get_array_pointer(c)
|
|
167
|
+
alpha_ptr = get_value_ptr(c_value_type(alpha))
|
|
168
|
+
beta_ptr = get_value_ptr(c_value_type(beta))
|
|
169
|
+
lda_ptr = int_to_uint32_ptr(lda)
|
|
170
|
+
ldb_ptr = int_to_uint32_ptr(ldb)
|
|
171
|
+
ldc_ptr = int_to_uint32_ptr(ldc)
|
|
172
|
+
|
|
173
|
+
blas_device_func(alpha_ptr, aptr, lda_ptr, bptr, ldb_ptr, beta_ptr, cptr, ldc_ptr)
|
|
174
|
+
|
|
175
|
+
return impl
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# ==============================================
|
|
179
|
+
# Unsupported API surface
|
|
180
|
+
# ==============================================
|
|
181
|
+
|
|
182
|
+
_UNSUPPORTED_BLAS_METHODS = (
|
|
183
|
+
"get_accumulator",
|
|
184
|
+
"suggest_accumulator",
|
|
185
|
+
"get_layout_smem_a",
|
|
186
|
+
"get_layout_smem_b",
|
|
187
|
+
"get_layout_smem_c",
|
|
188
|
+
"get_layout_gmem_a",
|
|
189
|
+
"get_layout_gmem_b",
|
|
190
|
+
"get_layout_gmem_c",
|
|
191
|
+
"suggest_layout_smem_a",
|
|
192
|
+
"suggest_layout_smem_b",
|
|
193
|
+
"suggest_layout_smem_c",
|
|
194
|
+
"suggest_layout_rmem_c",
|
|
195
|
+
"get_layout_rmem_c",
|
|
196
|
+
"_get_accumulator_c",
|
|
197
|
+
"_suggest_accumulator_c",
|
|
198
|
+
)
|
|
199
|
+
for _method in _UNSUPPORTED_BLAS_METHODS:
|
|
200
|
+
overload_method(BlasType, _method, strict=False, typing_registry=typing_registry)(_unsupported)
|
|
201
|
+
|
|
202
|
+
_UNSUPPORTED_FREE_FUNCTIONS = (make_tensor, make_fragment_like, copy, copy_fragment, clear, copy_wait, axpby)
|
|
203
|
+
for _func in _UNSUPPORTED_FREE_FUNCTIONS:
|
|
204
|
+
overload(_func, strict=False, typing_registry=typing_registry)(_unsupported)
|
|
205
|
+
|
|
206
|
+
_UNSUPPORTED_TYPES = (DevicePipeline, TilePipeline, _BlasMatmulLayout, _BlasMatmulLikeLayout)
|
|
207
|
+
for _cls in _UNSUPPORTED_TYPES:
|
|
208
|
+
typeof_impl.register(_cls)(_unsupported)
|
nvmath/device/cufftdx.py
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
__all__ = ["FFT", "compile_fft_execute"]
|
|
6
|
+
from functools import cached_property
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from nvmath.bindings import mathdx
|
|
10
|
+
from nvmath.internal.utils import docstring_decorator
|
|
11
|
+
|
|
12
|
+
from .common import (
|
|
13
|
+
SHARED_DEVICE_DOCSTRINGS,
|
|
14
|
+
check_code_type,
|
|
15
|
+
parse_code_type,
|
|
16
|
+
parse_sm,
|
|
17
|
+
)
|
|
18
|
+
from .common_backend import MATHDX_TYPES_TO_NP, get_isa_version, get_lto
|
|
19
|
+
from .common_cuda import (
|
|
20
|
+
Code,
|
|
21
|
+
Dim3,
|
|
22
|
+
)
|
|
23
|
+
from .cufftdx_backend import (
|
|
24
|
+
generate_code,
|
|
25
|
+
generate_FFT,
|
|
26
|
+
get_data_type_trait,
|
|
27
|
+
get_int_trait,
|
|
28
|
+
get_int_traits,
|
|
29
|
+
get_knobs,
|
|
30
|
+
get_str_trait,
|
|
31
|
+
validate,
|
|
32
|
+
validate_execute_api,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
CUFFTDX_DATABASE = None
|
|
36
|
+
|
|
37
|
+
FFTDX_DOCSTRING = SHARED_DEVICE_DOCSTRINGS.copy()
|
|
38
|
+
FFTDX_DOCSTRING.update(
|
|
39
|
+
{
|
|
40
|
+
"size": """\
|
|
41
|
+
The size of the FFT to calculate.""".replace("\n", " "),
|
|
42
|
+
#
|
|
43
|
+
"fft_type": """\
|
|
44
|
+
A string specifying the type of FFT operation, can be ``'c2c'``, ``'c2r'`` or ``'r2c'``.""".replace("\n", " "),
|
|
45
|
+
#
|
|
46
|
+
"direction": """\
|
|
47
|
+
A string specifying the direction of FFT, can be ``'forward'`` or ``'inverse'``. If not provided, will be ``'forward'``
|
|
48
|
+
if real-to-complex FFT is specified and ``'inverse'`` if complex-to-real FFT is specified.""".replace("\n", " "),
|
|
49
|
+
#
|
|
50
|
+
"ffts_per_block": """\
|
|
51
|
+
The number of FFTs calculated per CUDA block, optional. The default is 1. Alternatively, if provided as ``'suggested'``,
|
|
52
|
+
will be set to a suggested value.""".replace("\n", " "),
|
|
53
|
+
#
|
|
54
|
+
"elements_per_thread": """\
|
|
55
|
+
The number of elements per thread, optional. If not provided, the default value selected by cuFFTDx is used.
|
|
56
|
+
Alternatively, if provided as ``'suggested'``, will be set to a suggested value.""".replace("\n", " "),
|
|
57
|
+
#
|
|
58
|
+
"real_fft_options": """\
|
|
59
|
+
A dictionary specifying the options for real FFT operation, optional.""".replace("\n", " "),
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@docstring_decorator(FFTDX_DOCSTRING, skip_missing=False)
|
|
65
|
+
class FFT:
|
|
66
|
+
"""
|
|
67
|
+
A class that encapsulates a partial FFT device function. A partial device function can
|
|
68
|
+
be queried for available or optimal values for some knobs (such as `ffts_per_block`
|
|
69
|
+
or `elements_per_thread`).
|
|
70
|
+
|
|
71
|
+
.. versionchanged:: 0.7.0
|
|
72
|
+
`FFT` has replaced `FFTOptions` and `FFTOptionsComplete`.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
size (int): {size}
|
|
76
|
+
|
|
77
|
+
precision (type[np.floating]): {precision}
|
|
78
|
+
|
|
79
|
+
fft_type (str): {fft_type}
|
|
80
|
+
|
|
81
|
+
execution (str): {execution}
|
|
82
|
+
|
|
83
|
+
sm (ComputeCapability): {sm}
|
|
84
|
+
|
|
85
|
+
direction (str): {direction}
|
|
86
|
+
|
|
87
|
+
ffts_per_block (int): {ffts_per_block}
|
|
88
|
+
|
|
89
|
+
elements_per_thread (int): {elements_per_thread}
|
|
90
|
+
|
|
91
|
+
real_fft_options (dict): {real_fft_options} User may specify the following options
|
|
92
|
+
in the dictionary:
|
|
93
|
+
|
|
94
|
+
- ``'complex_layout'``, currently supports ``'natural'``, ``'packed'``, and
|
|
95
|
+
``'full'``.
|
|
96
|
+
- ``'real_mode'``, currently supports ``'normal'`` and ``'folded'``.
|
|
97
|
+
|
|
98
|
+
.. seealso::
|
|
99
|
+
The attributes of this class provide a 1:1 mapping with the CUDA C++ cuFFTDx APIs.
|
|
100
|
+
For further details, please refer to :cufftdx_doc:`cuFFTDx documentation
|
|
101
|
+
<index.html>`.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
def __init__(
|
|
105
|
+
self,
|
|
106
|
+
size,
|
|
107
|
+
precision,
|
|
108
|
+
fft_type,
|
|
109
|
+
execution,
|
|
110
|
+
*,
|
|
111
|
+
sm=None,
|
|
112
|
+
direction=None,
|
|
113
|
+
ffts_per_block=None,
|
|
114
|
+
elements_per_thread=None,
|
|
115
|
+
real_fft_options=None,
|
|
116
|
+
):
|
|
117
|
+
sm = parse_sm(sm)
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
# Check that the knobs are, individually, valid
|
|
121
|
+
#
|
|
122
|
+
|
|
123
|
+
validate(
|
|
124
|
+
size=size,
|
|
125
|
+
precision=precision,
|
|
126
|
+
fft_type=fft_type,
|
|
127
|
+
sm=sm,
|
|
128
|
+
execution=execution,
|
|
129
|
+
direction=direction,
|
|
130
|
+
ffts_per_block=ffts_per_block,
|
|
131
|
+
elements_per_thread=elements_per_thread,
|
|
132
|
+
real_fft_options=real_fft_options,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if direction is None and fft_type == "r2c":
|
|
136
|
+
direction = "forward"
|
|
137
|
+
elif direction is None and fft_type == "c2r":
|
|
138
|
+
direction = "inverse"
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Traits set by input
|
|
142
|
+
#
|
|
143
|
+
|
|
144
|
+
self._precision = precision
|
|
145
|
+
self._fft_type = fft_type
|
|
146
|
+
self._direction = direction
|
|
147
|
+
self._size = size
|
|
148
|
+
self._execution = execution
|
|
149
|
+
self._ffts_per_block = ffts_per_block
|
|
150
|
+
self._elements_per_thread = elements_per_thread
|
|
151
|
+
self._real_fft_options = real_fft_options
|
|
152
|
+
self._sm = sm
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Update suggested traits
|
|
156
|
+
#
|
|
157
|
+
|
|
158
|
+
if elements_per_thread == "suggested":
|
|
159
|
+
self._elements_per_thread = self._suggested_elements_per_thread
|
|
160
|
+
|
|
161
|
+
if ffts_per_block == "suggested":
|
|
162
|
+
self._ffts_per_block = self._suggested_ffts_per_block
|
|
163
|
+
|
|
164
|
+
@cached_property
|
|
165
|
+
def _traits(self):
|
|
166
|
+
return _FFTTraits(self)
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def elements_per_thread(self):
|
|
170
|
+
if self._elements_per_thread is None:
|
|
171
|
+
return self._traits.elements_per_thread
|
|
172
|
+
return self._elements_per_thread
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def precision(self):
|
|
176
|
+
return self._precision
|
|
177
|
+
|
|
178
|
+
@property
|
|
179
|
+
def ffts_per_block(self):
|
|
180
|
+
if self._ffts_per_block is None:
|
|
181
|
+
return self._traits.ffts_per_block
|
|
182
|
+
return self._ffts_per_block
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def fft_type(self):
|
|
186
|
+
return self._fft_type
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def direction(self):
|
|
190
|
+
return self._direction
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def size(self):
|
|
194
|
+
return self._size
|
|
195
|
+
|
|
196
|
+
@property
|
|
197
|
+
def execution(self):
|
|
198
|
+
return self._execution
|
|
199
|
+
|
|
200
|
+
@property
|
|
201
|
+
def real_fft_options(self):
|
|
202
|
+
return self._real_fft_options
|
|
203
|
+
|
|
204
|
+
@property
|
|
205
|
+
def sm(self):
|
|
206
|
+
return self._sm
|
|
207
|
+
|
|
208
|
+
#
|
|
209
|
+
# Extensions
|
|
210
|
+
#
|
|
211
|
+
|
|
212
|
+
def valid(self, *knobs):
|
|
213
|
+
if not (set(knobs) <= {"ffts_per_block", "elements_per_thread"}):
|
|
214
|
+
raise ValueError(f"Unsupported knob. Only valid knobs are ffts_per_block and elements_per_thread but got {knobs}")
|
|
215
|
+
|
|
216
|
+
return self._get_knobs(*knobs)
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def value_type(self):
|
|
220
|
+
return self._traits.value_type
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def input_type(self):
|
|
224
|
+
return self._traits.input_type
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
def output_type(self):
|
|
228
|
+
return self._traits.output_type
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def storage_size(self):
|
|
232
|
+
return self._traits.storage_size
|
|
233
|
+
|
|
234
|
+
@property
|
|
235
|
+
def shared_memory_size(self):
|
|
236
|
+
return self._traits.shared_memory_size
|
|
237
|
+
|
|
238
|
+
@property
|
|
239
|
+
def stride(self):
|
|
240
|
+
return self._traits.stride
|
|
241
|
+
|
|
242
|
+
@property
|
|
243
|
+
def block_dim(self):
|
|
244
|
+
return self._traits.block_dim
|
|
245
|
+
|
|
246
|
+
@property
|
|
247
|
+
def implicit_type_batching(self):
|
|
248
|
+
return self._traits.implicit_type_batching
|
|
249
|
+
|
|
250
|
+
@property
|
|
251
|
+
def extensions(self):
|
|
252
|
+
raise NotImplementedError("Extensions not supported yet")
|
|
253
|
+
|
|
254
|
+
def execute(*args):
|
|
255
|
+
raise RuntimeError("execute should not be called directly outside of a jitted kernel.")
|
|
256
|
+
|
|
257
|
+
#
|
|
258
|
+
# Private implementations
|
|
259
|
+
#
|
|
260
|
+
|
|
261
|
+
def _suggested(self, what):
|
|
262
|
+
# Generate full PTX
|
|
263
|
+
h = generate_FFT(
|
|
264
|
+
size=self._size,
|
|
265
|
+
precision=self._precision,
|
|
266
|
+
fft_type=self._fft_type,
|
|
267
|
+
direction=self._direction,
|
|
268
|
+
ffts_per_block=(None if self._ffts_per_block == "suggested" else self._ffts_per_block),
|
|
269
|
+
elements_per_thread=(None if self._elements_per_thread == "suggested" else self._elements_per_thread),
|
|
270
|
+
real_fft_options=frozenset(self._real_fft_options.items()) if self._real_fft_options else None,
|
|
271
|
+
sm=self._sm,
|
|
272
|
+
execution=self._execution,
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
if what == "elements_per_thread":
|
|
276
|
+
return get_int_trait(h.descriptor, mathdx.CufftdxTraitType.ELEMENTS_PER_THREAD)
|
|
277
|
+
|
|
278
|
+
if what == "suggested_ffts_per_block":
|
|
279
|
+
return get_int_trait(h.descriptor, mathdx.CufftdxTraitType.SUGGESTED_FFTS_PER_BLOCK)
|
|
280
|
+
|
|
281
|
+
raise Exception(f"Unknown suggested option '{what}'")
|
|
282
|
+
|
|
283
|
+
@cached_property
|
|
284
|
+
def _suggested_ffts_per_block(self):
|
|
285
|
+
return self._suggested("suggested_ffts_per_block")
|
|
286
|
+
|
|
287
|
+
@cached_property
|
|
288
|
+
def _suggested_elements_per_thread(self):
|
|
289
|
+
return self._suggested("elements_per_thread")
|
|
290
|
+
|
|
291
|
+
def _get_knobs(self, *knobs):
|
|
292
|
+
if not (set(knobs) <= {"ffts_per_block", "elements_per_thread"}):
|
|
293
|
+
raise ValueError(f"Unsupported knob. Only valid knobs are ffts_per_block and elements_per_thread but got {knobs}")
|
|
294
|
+
|
|
295
|
+
h = generate_FFT(
|
|
296
|
+
size=self._size,
|
|
297
|
+
precision=self._precision,
|
|
298
|
+
fft_type=self._fft_type,
|
|
299
|
+
direction=self._direction,
|
|
300
|
+
ffts_per_block=self._ffts_per_block,
|
|
301
|
+
elements_per_thread=self._elements_per_thread,
|
|
302
|
+
real_fft_options=frozenset(self._real_fft_options.items()) if self._real_fft_options else None,
|
|
303
|
+
sm=self._sm,
|
|
304
|
+
execution=self._execution,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
return get_knobs(h.descriptor, knobs)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class _FFTTraits:
|
|
311
|
+
def __init__(self, FFT: FFT):
|
|
312
|
+
h = generate_FFT(
|
|
313
|
+
size=FFT._size,
|
|
314
|
+
precision=FFT._precision,
|
|
315
|
+
fft_type=FFT._fft_type,
|
|
316
|
+
direction=FFT._direction,
|
|
317
|
+
sm=FFT._sm,
|
|
318
|
+
execution=FFT._execution,
|
|
319
|
+
ffts_per_block=FFT._ffts_per_block if FFT._execution == "Block" else None,
|
|
320
|
+
elements_per_thread=FFT._elements_per_thread if FFT._execution == "Block" else None,
|
|
321
|
+
real_fft_options=frozenset(FFT._real_fft_options.items()) if FFT._real_fft_options else None,
|
|
322
|
+
).descriptor
|
|
323
|
+
|
|
324
|
+
self.value_type = MATHDX_TYPES_TO_NP[get_data_type_trait(h, mathdx.CufftdxTraitType.VALUE_TYPE)]
|
|
325
|
+
self.input_type = MATHDX_TYPES_TO_NP[get_data_type_trait(h, mathdx.CufftdxTraitType.INPUT_TYPE)]
|
|
326
|
+
self.output_type = MATHDX_TYPES_TO_NP[get_data_type_trait(h, mathdx.CufftdxTraitType.OUTPUT_TYPE)]
|
|
327
|
+
|
|
328
|
+
self.storage_size = get_int_trait(h, mathdx.CufftdxTraitType.STORAGE_SIZE)
|
|
329
|
+
self.stride = get_int_trait(h, mathdx.CufftdxTraitType.STRIDE)
|
|
330
|
+
self.elements_per_thread = get_int_trait(h, mathdx.CufftdxTraitType.ELEMENTS_PER_THREAD)
|
|
331
|
+
self.implicit_type_batching = get_int_trait(h, mathdx.CufftdxTraitType.IMPLICIT_TYPE_BATCHING)
|
|
332
|
+
|
|
333
|
+
if FFT.execution == "Block":
|
|
334
|
+
self.block_dim: Dim3 | None = Dim3(*get_int_traits(h, mathdx.CufftdxTraitType.BLOCK_DIM, 3))
|
|
335
|
+
self.shared_memory_size: int | None = get_int_trait(h, mathdx.CufftdxTraitType.SHARED_MEMORY_SIZE)
|
|
336
|
+
self.ffts_per_block: int | None = get_int_trait(h, mathdx.CufftdxTraitType.FFTS_PER_BLOCK)
|
|
337
|
+
else:
|
|
338
|
+
self.block_dim = None
|
|
339
|
+
self.shared_memory_size = None
|
|
340
|
+
self.ffts_per_block = None
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def compile_fft_execute(
|
|
344
|
+
fft: FFT,
|
|
345
|
+
code_type: Any,
|
|
346
|
+
execute_api: str | None = None,
|
|
347
|
+
) -> tuple[Code, str]:
|
|
348
|
+
code_type = parse_code_type(code_type)
|
|
349
|
+
check_code_type(code_type, "cuFFTDx")
|
|
350
|
+
validate_execute_api(fft.execution, execute_api)
|
|
351
|
+
|
|
352
|
+
h = generate_FFT(
|
|
353
|
+
size=fft._size,
|
|
354
|
+
precision=fft._precision,
|
|
355
|
+
fft_type=fft._fft_type,
|
|
356
|
+
direction=fft._direction,
|
|
357
|
+
sm=fft._sm,
|
|
358
|
+
execution=fft._execution,
|
|
359
|
+
ffts_per_block=fft._ffts_per_block if fft._execution == "Block" else None,
|
|
360
|
+
elements_per_thread=fft._elements_per_thread if fft._execution == "Block" else None,
|
|
361
|
+
real_fft_options=frozenset(fft._real_fft_options.items()) if fft._real_fft_options else None,
|
|
362
|
+
execute_api=execute_api,
|
|
363
|
+
).descriptor
|
|
364
|
+
|
|
365
|
+
code = generate_code(h, code_type.cc)
|
|
366
|
+
|
|
367
|
+
# Compile
|
|
368
|
+
lto_fn = get_lto(code.descriptor)
|
|
369
|
+
isa_version = get_isa_version(code.descriptor)
|
|
370
|
+
|
|
371
|
+
symbol = get_str_trait(h, mathdx.CufftdxTraitType.SYMBOL_NAME)
|
|
372
|
+
|
|
373
|
+
return Code(code_type, isa_version, lto_fn), symbol
|