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,493 @@
|
|
|
1
|
+
# Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Matrix qualifier dataclasses for describing structured matrix types and their properties in
|
|
7
|
+
linear algebra operations. Provides qualifiers for general, symmetric, hermitian,
|
|
8
|
+
triangular, and diagonal matrices with associated metadata like fill modes, conjugate flags,
|
|
9
|
+
and BLAS function abbreviations.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import abc
|
|
13
|
+
import dataclasses
|
|
14
|
+
import typing
|
|
15
|
+
|
|
16
|
+
import numpy as np
|
|
17
|
+
import numpy.typing as npt
|
|
18
|
+
|
|
19
|
+
import nvmath.bindings.cublas as cublas
|
|
20
|
+
from nvmath._internal.templates import StatefulAPIOptions
|
|
21
|
+
from nvmath.internal import utils
|
|
22
|
+
|
|
23
|
+
FillMode: typing.TypeAlias = cublas.FillMode
|
|
24
|
+
DiagType: typing.TypeAlias = cublas.DiagType
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclasses.dataclass(frozen=True, slots=True, kw_only=True)
|
|
28
|
+
class MatmulOptions(StatefulAPIOptions):
|
|
29
|
+
"""A dataclass for providing options to a :class:`Matmul` object.
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
allocator: An object that supports the :class:`BaseCUDAMemoryManager` protocol, used
|
|
33
|
+
to draw device memory. If an allocator is not provided, a memory allocator from
|
|
34
|
+
the library package will be used (:func:`torch.cuda.caching_allocator_alloc` for
|
|
35
|
+
PyTorch operands, :func:`cupy.cuda.alloc` otherwise).
|
|
36
|
+
|
|
37
|
+
blocking: A flag specifying the behavior of the stream-ordered functions and
|
|
38
|
+
methods. When ``blocking`` is `True`, the stream-ordered methods do not return
|
|
39
|
+
until the operation is complete. When ``blocking`` is ``"auto"``, the methods
|
|
40
|
+
return immediately when the inputs are on the GPU. The stream-ordered methods
|
|
41
|
+
always block when the operands are on the CPU to ensure that the user doesn't
|
|
42
|
+
inadvertently use the result before it becomes available. The default is
|
|
43
|
+
``"auto"``.
|
|
44
|
+
|
|
45
|
+
inplace: Whether the matrix multiplication is performed in-place (operand C is
|
|
46
|
+
overwritten).
|
|
47
|
+
|
|
48
|
+
.. experimental:: attribute
|
|
49
|
+
|
|
50
|
+
logger: Python Logger object. The root logger will be used if a
|
|
51
|
+
logger object is not provided.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
inplace: bool = False
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
MM_QUALIFIERS_DOCUMENTATION = {
|
|
58
|
+
#
|
|
59
|
+
"abbreviation": """\
|
|
60
|
+
The two character abbreviation of the matrix qualifier.""".replace("\n", " "),
|
|
61
|
+
#
|
|
62
|
+
"conjugate": """\
|
|
63
|
+
Whether the matrix is conjugate.""".replace("\n", " "),
|
|
64
|
+
#
|
|
65
|
+
"uplo": """\
|
|
66
|
+
The :py:class:`~nvmath.bindings.cublas.FillMode` of the matrix. e.g. upper, lower...""".replace("\n", " "),
|
|
67
|
+
#
|
|
68
|
+
"diag": """\
|
|
69
|
+
The :py:class:`~nvmath.bindings.cublas.DiagType` of the matrix. e.g. unit, non-unit...""".replace("\n", " "),
|
|
70
|
+
#
|
|
71
|
+
"incx": """\
|
|
72
|
+
The direction to read the diagonal. +1 for forward; -1 for reverse.""".replace("\n", " "),
|
|
73
|
+
#
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# We name this variable as foo_bar_dtype, so that the docstrings format correctly
|
|
78
|
+
# Docstrings for custom dtypes are defined in docs/sphinx/conf.py
|
|
79
|
+
matrix_qualifiers_dtype = np.dtype(
|
|
80
|
+
[
|
|
81
|
+
("abbreviation", "U2"),
|
|
82
|
+
("conjugate", np.bool_),
|
|
83
|
+
("uplo", np.int_),
|
|
84
|
+
("diag", np.int_),
|
|
85
|
+
("incx", np.int_),
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
"""A NumPy array of type :class:`matrix_qualifiers_dtype`.
|
|
90
|
+
|
|
91
|
+
.. seealso::
|
|
92
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
93
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
94
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
95
|
+
"""
|
|
96
|
+
MatrixQualifier: typing.TypeAlias = npt.NDArray
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class MatrixQualifierConstructor(abc.ABC):
|
|
100
|
+
abbreviation: typing.ClassVar[str]
|
|
101
|
+
|
|
102
|
+
def __init__(self):
|
|
103
|
+
msg = f"The {self.__class__.__name__} constructor should not be called. Use {self.__class__.__name__}.create() instead."
|
|
104
|
+
raise RuntimeError(msg)
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def create(
|
|
108
|
+
cls,
|
|
109
|
+
conjugate: bool = False,
|
|
110
|
+
uplo: FillMode = FillMode.FULL,
|
|
111
|
+
diag: DiagType = DiagType.NON_UNIT,
|
|
112
|
+
incx: typing.Literal[-1, 1, 0] = 0,
|
|
113
|
+
):
|
|
114
|
+
return np.array((cls.abbreviation, conjugate, uplo, diag, incx), dtype=matrix_qualifiers_dtype)
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def is_valid(cls, other: MatrixQualifier) -> np.bool_:
|
|
118
|
+
"""Return ``True`` if all elements of `other` are valid examples of the
|
|
119
|
+
:class:`matrix_qualifiers_dtype` constructed by this class."""
|
|
120
|
+
return np.all(other["abbreviation"] == cls.abbreviation) and np.bool_(
|
|
121
|
+
all(
|
|
122
|
+
n in other.dtype.names # type: ignore[operator]
|
|
123
|
+
for n in ("conjugate",)
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
@classmethod
|
|
128
|
+
def to_string(cls, other: MatrixQualifier) -> str:
|
|
129
|
+
"""Return a pretty string representation of `other`."""
|
|
130
|
+
return (
|
|
131
|
+
f"({other['abbreviation']}, conjugate={other['conjugate']}, "
|
|
132
|
+
f"uplo={FillMode(other['uplo']).name}, "
|
|
133
|
+
f"diag={DiagType(other['diag']).name}, incx={other['incx']})"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
138
|
+
class GeneralMatrixQualifier(MatrixQualifierConstructor):
|
|
139
|
+
"""A class which constructs and validates :class:`matrix_qualifiers_dtype` for a general
|
|
140
|
+
rectangular matrix.
|
|
141
|
+
|
|
142
|
+
Examples:
|
|
143
|
+
|
|
144
|
+
>>> import numpy as np
|
|
145
|
+
>>> from nvmath.linalg import GeneralMatrixQualifier, matrix_qualifiers_dtype
|
|
146
|
+
|
|
147
|
+
Create a general matrix qualifier:
|
|
148
|
+
|
|
149
|
+
>>> GeneralMatrixQualifier.create() # doctest: +ELLIPSIS
|
|
150
|
+
array(('ge', False, 2, 0, 0),
|
|
151
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
152
|
+
|
|
153
|
+
Create a conjugate general matrix qualifier:
|
|
154
|
+
|
|
155
|
+
>>> GeneralMatrixQualifier.create(conjugate=True) # doctest: +ELLIPSIS
|
|
156
|
+
array(('ge', True, 2, 0, 0),
|
|
157
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
158
|
+
|
|
159
|
+
Create an array of general matrix qualifiers:
|
|
160
|
+
|
|
161
|
+
>>> np.full(
|
|
162
|
+
... 2, GeneralMatrixQualifier.create(), dtype=matrix_qualifiers_dtype
|
|
163
|
+
... ) # doctest: +ELLIPSIS
|
|
164
|
+
array([('ge', False, 2, 0, 0), ('ge', False, 2, 0, 0)],
|
|
165
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
166
|
+
|
|
167
|
+
.. seealso::
|
|
168
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
169
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
170
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
abbreviation: typing.ClassVar[str] = "ge"
|
|
174
|
+
|
|
175
|
+
@classmethod
|
|
176
|
+
def create( # type: ignore[override]
|
|
177
|
+
cls,
|
|
178
|
+
conjugate: bool = False,
|
|
179
|
+
):
|
|
180
|
+
"""Return a :class:`np.ndarray` of type :class:`matrix_qualifiers_dtype` whose
|
|
181
|
+
element describes a general matrix.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
conjugate: {conjugate}
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
return super().create(conjugate=conjugate)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
191
|
+
class DiagonalMatrixQualifier(MatrixQualifierConstructor):
|
|
192
|
+
"""A class which constructs and validates :class:`matrix_qualifiers_dtype` for a
|
|
193
|
+
diagonal matrix.
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
|
|
197
|
+
>>> import numpy as np
|
|
198
|
+
>>> from nvmath.linalg import (
|
|
199
|
+
... DiagonalMatrixQualifier,
|
|
200
|
+
... GeneralMatrixQualifier,
|
|
201
|
+
... matrix_qualifiers_dtype,
|
|
202
|
+
... )
|
|
203
|
+
|
|
204
|
+
Create a diagonal matrix qualifier:
|
|
205
|
+
|
|
206
|
+
>>> DiagonalMatrixQualifier.create() # doctest: +ELLIPSIS
|
|
207
|
+
array(('dg', False, 2, 0, 1),
|
|
208
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
209
|
+
|
|
210
|
+
Create a conjugate diagonal matrix qualifier:
|
|
211
|
+
|
|
212
|
+
>>> DiagonalMatrixQualifier.create(conjugate=True) # doctest: +ELLIPSIS
|
|
213
|
+
array(('dg', True, 2, 0, 1),
|
|
214
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
215
|
+
|
|
216
|
+
Create an array of matrix qualifiers with one general and one diagonal matrix:
|
|
217
|
+
|
|
218
|
+
>>> qualifiers = np.full(
|
|
219
|
+
... 2,
|
|
220
|
+
... GeneralMatrixQualifier.create(),
|
|
221
|
+
... dtype=matrix_qualifiers_dtype,
|
|
222
|
+
... )
|
|
223
|
+
>>> qualifiers[1] = DiagonalMatrixQualifier.create()
|
|
224
|
+
>>> qualifiers # doctest: +ELLIPSIS
|
|
225
|
+
array([('ge', False, 2, 0, 0), ('dg', False, 2, 0, 1)],
|
|
226
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
227
|
+
|
|
228
|
+
.. seealso::
|
|
229
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
230
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
231
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
abbreviation: typing.ClassVar[str] = "dg"
|
|
235
|
+
|
|
236
|
+
@classmethod
|
|
237
|
+
def create( # type: ignore[override]
|
|
238
|
+
cls,
|
|
239
|
+
conjugate: bool = False,
|
|
240
|
+
incx: typing.Literal[-1, 1] = 1,
|
|
241
|
+
):
|
|
242
|
+
"""Return a :class:`np.ndarray` of type :class:`matrix_qualifiers_dtype` whose
|
|
243
|
+
element describes a diagonal matrix.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
conjugate: {conjugate}
|
|
247
|
+
|
|
248
|
+
incx: {incx}
|
|
249
|
+
"""
|
|
250
|
+
if incx not in (-1, 1):
|
|
251
|
+
raise ValueError(f"The 'incx' parameter must be '-1' or '1' not {incx}")
|
|
252
|
+
return super().create(conjugate, incx=incx)
|
|
253
|
+
|
|
254
|
+
@classmethod
|
|
255
|
+
def is_valid(cls, other):
|
|
256
|
+
return super().is_valid(other) and np.all(np.logical_or(other["incx"] == -1, other["incx"] == 1))
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
260
|
+
class SquareMatrixQualifier(MatrixQualifierConstructor, abc.ABC):
|
|
261
|
+
@classmethod
|
|
262
|
+
def create( # type: ignore[override]
|
|
263
|
+
cls,
|
|
264
|
+
conjugate: bool = False,
|
|
265
|
+
uplo: FillMode = FillMode.LOWER,
|
|
266
|
+
**kwargs,
|
|
267
|
+
):
|
|
268
|
+
if uplo not in (FillMode.UPPER, FillMode.LOWER):
|
|
269
|
+
raise ValueError(f"The 'uplo' parameter must be 'UPPER' or 'LOWER', not {uplo}.")
|
|
270
|
+
return super().create(conjugate, uplo=uplo, **kwargs)
|
|
271
|
+
|
|
272
|
+
@classmethod
|
|
273
|
+
def is_valid(cls, other):
|
|
274
|
+
return super().is_valid(other) and np.all(
|
|
275
|
+
np.logical_or(other["uplo"] == FillMode.UPPER, other["uplo"] == FillMode.LOWER)
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
280
|
+
class HermitianMatrixQualifier(SquareMatrixQualifier):
|
|
281
|
+
"""A class which constructs and validates :class:`matrix_qualifiers_dtype` for a
|
|
282
|
+
hermitian matrix.
|
|
283
|
+
|
|
284
|
+
Examples:
|
|
285
|
+
|
|
286
|
+
>>> import numpy as np
|
|
287
|
+
>>> from nvmath.linalg import (
|
|
288
|
+
... HermitianMatrixQualifier,
|
|
289
|
+
... GeneralMatrixQualifier,
|
|
290
|
+
... matrix_qualifiers_dtype,
|
|
291
|
+
... )
|
|
292
|
+
|
|
293
|
+
Create a hermitian matrix qualifier:
|
|
294
|
+
|
|
295
|
+
>>> HermitianMatrixQualifier.create() # doctest: +ELLIPSIS
|
|
296
|
+
array(('he', False, 0, 0, 0),
|
|
297
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
298
|
+
|
|
299
|
+
Create a conjugate hermitian matrix qualifier:
|
|
300
|
+
|
|
301
|
+
>>> HermitianMatrixQualifier.create(conjugate=True) # doctest: +ELLIPSIS
|
|
302
|
+
array(('he', True, 0, 0, 0),
|
|
303
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
304
|
+
|
|
305
|
+
Create an array of matrix qualifiers with one general and one hermitian matrix:
|
|
306
|
+
|
|
307
|
+
>>> qualifiers = np.full(
|
|
308
|
+
... 2,
|
|
309
|
+
... GeneralMatrixQualifier.create(),
|
|
310
|
+
... dtype=matrix_qualifiers_dtype,
|
|
311
|
+
... )
|
|
312
|
+
>>> qualifiers[1] = HermitianMatrixQualifier.create()
|
|
313
|
+
>>> qualifiers # doctest: +ELLIPSIS
|
|
314
|
+
array([('ge', False, 2, 0, 0), ('he', False, 0, 0, 0)],
|
|
315
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
316
|
+
|
|
317
|
+
.. seealso::
|
|
318
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
319
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
320
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
abbreviation: typing.ClassVar[str] = "he"
|
|
324
|
+
|
|
325
|
+
@classmethod
|
|
326
|
+
def create( # type: ignore[override]
|
|
327
|
+
cls,
|
|
328
|
+
conjugate: bool = False,
|
|
329
|
+
uplo: FillMode = FillMode.LOWER,
|
|
330
|
+
):
|
|
331
|
+
"""Return a :class:`np.ndarray` of type :class:`matrix_qualifiers_dtype` whose
|
|
332
|
+
element describes a hermitian matrix.
|
|
333
|
+
|
|
334
|
+
Args:
|
|
335
|
+
conjugate: {conjugate}
|
|
336
|
+
|
|
337
|
+
uplo: {uplo}
|
|
338
|
+
"""
|
|
339
|
+
return super().create(conjugate, uplo)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
343
|
+
class SymmetricMatrixQualifier(SquareMatrixQualifier):
|
|
344
|
+
"""A class which constructs and validates :class:`matrix_qualifiers_dtype` for a
|
|
345
|
+
symmetric matrix.
|
|
346
|
+
|
|
347
|
+
Examples:
|
|
348
|
+
|
|
349
|
+
>>> import numpy as np
|
|
350
|
+
>>> from nvmath.linalg import (
|
|
351
|
+
... SymmetricMatrixQualifier,
|
|
352
|
+
... GeneralMatrixQualifier,
|
|
353
|
+
... matrix_qualifiers_dtype,
|
|
354
|
+
... )
|
|
355
|
+
|
|
356
|
+
Create a symmetric matrix qualifier:
|
|
357
|
+
|
|
358
|
+
>>> SymmetricMatrixQualifier.create() # doctest: +ELLIPSIS
|
|
359
|
+
array(('sy', False, 0, 0, 0),
|
|
360
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
361
|
+
|
|
362
|
+
Create a conjugate symmetric matrix qualifier:
|
|
363
|
+
|
|
364
|
+
>>> SymmetricMatrixQualifier.create(conjugate=True) # doctest: +ELLIPSIS
|
|
365
|
+
array(('sy', True, 0, 0, 0),
|
|
366
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
367
|
+
|
|
368
|
+
Create an array of matrix qualifiers with one general and one symmetric matrix:
|
|
369
|
+
|
|
370
|
+
>>> qualifiers = np.full(
|
|
371
|
+
... 2,
|
|
372
|
+
... GeneralMatrixQualifier.create(),
|
|
373
|
+
... dtype=matrix_qualifiers_dtype,
|
|
374
|
+
... )
|
|
375
|
+
>>> qualifiers[1] = SymmetricMatrixQualifier.create()
|
|
376
|
+
>>> qualifiers # doctest: +ELLIPSIS
|
|
377
|
+
array([('ge', False, 2, 0, 0), ('sy', False, 0, 0, 0)],
|
|
378
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
379
|
+
|
|
380
|
+
.. seealso::
|
|
381
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
382
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
383
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
384
|
+
"""
|
|
385
|
+
|
|
386
|
+
abbreviation: typing.ClassVar[str] = "sy"
|
|
387
|
+
|
|
388
|
+
@classmethod
|
|
389
|
+
def create( # type: ignore[override]
|
|
390
|
+
cls,
|
|
391
|
+
conjugate: bool = False,
|
|
392
|
+
uplo: FillMode = FillMode.LOWER,
|
|
393
|
+
):
|
|
394
|
+
"""Return a :class:`np.ndarray` of type :class:`matrix_qualifiers_dtype` whose
|
|
395
|
+
element describes a symmetric matrix.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
conjugate: {conjugate}
|
|
399
|
+
|
|
400
|
+
uplo: {uplo}
|
|
401
|
+
"""
|
|
402
|
+
return super().create(conjugate, uplo)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
@utils.docstring_decorator(MM_QUALIFIERS_DOCUMENTATION, skip_missing=False)
|
|
406
|
+
class TriangularMatrixQualifier(SquareMatrixQualifier):
|
|
407
|
+
"""A class which constructs and validates :class:`matrix_qualifiers_dtype` for a
|
|
408
|
+
triangular matrix.
|
|
409
|
+
|
|
410
|
+
Examples:
|
|
411
|
+
|
|
412
|
+
>>> import numpy as np
|
|
413
|
+
>>> from nvmath.linalg import (
|
|
414
|
+
... TriangularMatrixQualifier,
|
|
415
|
+
... GeneralMatrixQualifier,
|
|
416
|
+
... matrix_qualifiers_dtype,
|
|
417
|
+
... )
|
|
418
|
+
|
|
419
|
+
Create a triangular matrix qualifier:
|
|
420
|
+
|
|
421
|
+
>>> TriangularMatrixQualifier.create() # doctest: +ELLIPSIS
|
|
422
|
+
array(('tr', False, 0, 0, 0),
|
|
423
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
424
|
+
|
|
425
|
+
Create a conjugate triangular matrix qualifier:
|
|
426
|
+
|
|
427
|
+
>>> TriangularMatrixQualifier.create(conjugate=True) # doctest: +ELLIPSIS
|
|
428
|
+
array(('tr', True, 0, 0, 0),
|
|
429
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
430
|
+
|
|
431
|
+
Create an array of matrix qualifiers with one general and one triangular matrix:
|
|
432
|
+
|
|
433
|
+
>>> qualifiers = np.full(
|
|
434
|
+
... 2,
|
|
435
|
+
... GeneralMatrixQualifier.create(),
|
|
436
|
+
... dtype=matrix_qualifiers_dtype,
|
|
437
|
+
... )
|
|
438
|
+
>>> qualifiers[1] = TriangularMatrixQualifier.create()
|
|
439
|
+
>>> qualifiers # doctest: +ELLIPSIS
|
|
440
|
+
array([('ge', False, 2, 0, 0), ('tr', False, 0, 0, 0)],
|
|
441
|
+
dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...
|
|
442
|
+
|
|
443
|
+
.. seealso::
|
|
444
|
+
:class:`GeneralMatrixQualifier`, :class:`HermitianMatrixQualifier`,
|
|
445
|
+
:class:`SymmetricMatrixQualifier`, :class:`TriangularMatrixQualifier`
|
|
446
|
+
:class:`DiagonalMatrixQualifier`, :class:`matrix_qualifiers_dtype`
|
|
447
|
+
"""
|
|
448
|
+
|
|
449
|
+
abbreviation: typing.ClassVar[str] = "tr"
|
|
450
|
+
|
|
451
|
+
@classmethod
|
|
452
|
+
def create( # type: ignore[override]
|
|
453
|
+
cls,
|
|
454
|
+
conjugate: bool = False,
|
|
455
|
+
uplo: FillMode = FillMode.LOWER,
|
|
456
|
+
diag: DiagType = DiagType.NON_UNIT,
|
|
457
|
+
):
|
|
458
|
+
"""Return a :class:`np.ndarray` of type :class:`matrix_qualifiers_dtype` whose
|
|
459
|
+
element describes a triangular matrix.
|
|
460
|
+
|
|
461
|
+
Args:
|
|
462
|
+
conjugate: {conjugate}
|
|
463
|
+
|
|
464
|
+
uplo: {uplo}
|
|
465
|
+
|
|
466
|
+
diag: {diag}
|
|
467
|
+
"""
|
|
468
|
+
if diag not in (DiagType.UNIT, DiagType.NON_UNIT):
|
|
469
|
+
raise ValueError(f"The 'diag' parameter must be 'UNIT' or 'NON_UNIT', not {diag}.")
|
|
470
|
+
return super().create(conjugate, diag=diag, uplo=uplo)
|
|
471
|
+
|
|
472
|
+
@classmethod
|
|
473
|
+
def is_valid(cls, other):
|
|
474
|
+
return super().is_valid(other) and np.all(
|
|
475
|
+
np.logical_or(other["diag"] == DiagType.UNIT, other["diag"] == DiagType.NON_UNIT)
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def vector_to_square(
|
|
480
|
+
shape: typing.Sequence[int], strides: typing.Sequence[int], qualifier: MatrixQualifier
|
|
481
|
+
) -> tuple[typing.Sequence[int], typing.Sequence[int]]:
|
|
482
|
+
"""If `qualifier` is a DiagonalMatrixQualifier, convert `shape` and `stride` from a
|
|
483
|
+
vector to the equivalent square matrix."""
|
|
484
|
+
if DiagonalMatrixQualifier.is_valid(qualifier):
|
|
485
|
+
if len(shape) != 1:
|
|
486
|
+
msg = f"The shape of a diagonal matrix must be 1D; not {shape}."
|
|
487
|
+
raise ValueError(msg)
|
|
488
|
+
shape = tuple(shape) * 2
|
|
489
|
+
if len(strides) != 1:
|
|
490
|
+
msg = f"The strides of a diagonal matrix must be 1D; not {strides}."
|
|
491
|
+
raise ValueError(msg)
|
|
492
|
+
strides = (0, *strides)
|
|
493
|
+
return shape, strides
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
__all__ = ["DirectSolverOptions"]
|
|
6
|
+
|
|
7
|
+
import dataclasses
|
|
8
|
+
|
|
9
|
+
from nvmath._internal.templates import StatefulAPIOptions
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclasses.dataclass(frozen=True, slots=True, kw_only=True)
|
|
13
|
+
class DirectSolverOptions(StatefulAPIOptions):
|
|
14
|
+
"""A data class for providing options to :func:`~nvmath.linalg.direct_solver` and
|
|
15
|
+
:class:`DirectSolver`.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
handle: If ``None`` (the default), the required library handle will be created
|
|
19
|
+
automatically for the computation. If users wish to manage the library
|
|
20
|
+
handle themselves, they may provide a **cuSOLVER** handle, which will be
|
|
21
|
+
used unless the execution is dispatched to cuBLAS, e.g, for linear
|
|
22
|
+
equation solver on batched operands.
|
|
23
|
+
In this case, a cuBLAS handle will be created.
|
|
24
|
+
|
|
25
|
+
blocking: A flag specifying the behavior of the stream-ordered functions and
|
|
26
|
+
methods. When ``blocking`` is `True`, the stream-ordered methods do not return
|
|
27
|
+
until the operation is complete. When ``blocking`` is ``"auto"``, the methods
|
|
28
|
+
may execute asynchronously when the inputs are on the GPU, depending on the
|
|
29
|
+
problem specification and runtime conditions. The stream-ordered methods always
|
|
30
|
+
block when the operands are on the CPU to ensure that the user doesn't
|
|
31
|
+
inadvertently use the result before it becomes available. The default is
|
|
32
|
+
``"auto"``.
|
|
33
|
+
|
|
34
|
+
allocator: An object that supports the :class:`BaseCUDAMemoryManager` protocol, used
|
|
35
|
+
to draw device memory. If an allocator is not provided, a memory allocator from
|
|
36
|
+
the library package will be used (:func:`torch.cuda.caching_allocator_alloc` for
|
|
37
|
+
PyTorch operands, :func:`cupy.cuda.alloc` otherwise).
|
|
38
|
+
|
|
39
|
+
logger: Python Logger object. The root logger will be used if a
|
|
40
|
+
logger object is not provided.
|
|
41
|
+
|
|
42
|
+
inplace_a: Whether LU factorization overwrites the input left-hand side
|
|
43
|
+
matrix ``a`` with the factors L, D, and U. The default is ``False``.
|
|
44
|
+
|
|
45
|
+
.. experimental:: attribute
|
|
46
|
+
|
|
47
|
+
inplace_b: Whether the solve overwrites the input right-hand side ``b``
|
|
48
|
+
with the solution ``x``. The default is ``False``.
|
|
49
|
+
|
|
50
|
+
.. experimental:: attribute
|
|
51
|
+
|
|
52
|
+
.. seealso::
|
|
53
|
+
:func:`~nvmath.linalg.direct_solver`, :class:`~nvmath.linalg.DirectSolver`.
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
handle: int | None = None
|
|
58
|
+
inplace_a: bool = False
|
|
59
|
+
inplace_b: bool = False
|