Coverage for cuda / core / typing.py: 96.77%
62 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-22 01:37 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-22 01:37 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
5"""Public type aliases, protocols, and enumerations used in cuda.core API signatures."""
7try:
8 from enum import StrEnum
9except ImportError:
10 from backports.strenum import StrEnum
11from typing import Literal as _Literal
13from cuda.core._context import DeviceResourcesType
14from cuda.core._stream import IsStreamType
15from cuda.core._utils.cuda_utils import driver
17__all__ = [
18 "CompilerBackendType",
19 "DevicePointerType",
20 "DeviceResourcesType",
21 "GraphConditionalType",
22 "GraphMemoryType",
23 "IsStreamType",
24 "ManagedMemoryLocationType",
25 "ObjectCodeFormatType",
26 "PCHStatusType",
27 "ProcessStateType",
28 "SourceCodeType",
29 "VirtualMemoryAccessType",
30 "VirtualMemoryAllocationType",
31 "VirtualMemoryGranularityType",
32 "VirtualMemoryHandleType",
33 "VirtualMemoryLocationType",
34]
37# A type union of :obj:`~driver.CUdeviceptr`, `int` and `None` for hinting
38# :attr:`Buffer.handle`.
39DevicePointerType = driver.CUdeviceptr | int | None
42ProcessStateType = _Literal["running", "locked", "checkpointed", "failed"]
45class SourceCodeType(StrEnum):
46 CXX = "c++"
47 PTX = "ptx"
48 NVVM = "nvvm"
51class ObjectCodeFormatType(StrEnum):
52 PTX = "ptx"
53 CUBIN = "cubin"
54 LTOIR = "ltoir"
55 FATBIN = "fatbin"
56 OBJECT = "object"
57 LIBRARY = "library"
60class CompilerBackendType(StrEnum):
61 NVRTC = "NVRTC"
62 NVVM = "NVVM"
63 NVJITLINK = "nvJitLink"
64 DRIVER = "driver"
67class PCHStatusType(StrEnum):
68 CREATED = "created"
69 NOT_ATTEMPTED = "not_attempted"
70 FAILED = "failed"
73class GraphConditionalType(StrEnum):
74 IF = "if"
75 WHILE = "while"
76 SWITCH = "switch"
79class GraphMemoryType(StrEnum):
80 DEVICE = "device"
81 HOST = "host"
82 MANAGED = "managed"
85class ManagedMemoryLocationType(StrEnum):
86 DEVICE = "device"
87 HOST = "host"
88 HOST_NUMA = "host_numa"
91class VirtualMemoryHandleType(StrEnum):
92 POSIX_FD = "posix_fd"
93 WIN32_KMT = "win32_kmt"
94 FABRIC = "fabric"
97class VirtualMemoryLocationType(StrEnum):
98 DEVICE = "device"
99 HOST = "host"
100 HOST_NUMA = "host_numa"
101 HOST_NUMA_CURRENT = "host_numa_current"
104class VirtualMemoryGranularityType(StrEnum):
105 MINIMUM = "minimum"
106 RECOMMENDED = "recommended"
109class VirtualMemoryAccessType(StrEnum):
110 READ_WRITE = "rw"
111 READ = "r"
114class VirtualMemoryAllocationType(StrEnum):
115 PINNED = "pinned"
116 MANAGED = "managed"
119del StrEnum