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

1# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: Apache-2.0 

4 

5"""Public type aliases, protocols, and enumerations used in cuda.core API signatures.""" 

6 

7try: 

8 from enum import StrEnum 

9except ImportError: 

10 from backports.strenum import StrEnum 

11from typing import Literal as _Literal 

12 

13from cuda.core._context import DeviceResourcesType 

14from cuda.core._stream import IsStreamType 

15from cuda.core._utils.cuda_utils import driver 

16 

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] 

35 

36 

37# A type union of :obj:`~driver.CUdeviceptr`, `int` and `None` for hinting 

38# :attr:`Buffer.handle`. 

39DevicePointerType = driver.CUdeviceptr | int | None 

40 

41 

42ProcessStateType = _Literal["running", "locked", "checkpointed", "failed"] 

43 

44 

45class SourceCodeType(StrEnum): 

46 CXX = "c++" 

47 PTX = "ptx" 

48 NVVM = "nvvm" 

49 

50 

51class ObjectCodeFormatType(StrEnum): 

52 PTX = "ptx" 

53 CUBIN = "cubin" 

54 LTOIR = "ltoir" 

55 FATBIN = "fatbin" 

56 OBJECT = "object" 

57 LIBRARY = "library" 

58 

59 

60class CompilerBackendType(StrEnum): 

61 NVRTC = "NVRTC" 

62 NVVM = "NVVM" 

63 NVJITLINK = "nvJitLink" 

64 DRIVER = "driver" 

65 

66 

67class PCHStatusType(StrEnum): 

68 CREATED = "created" 

69 NOT_ATTEMPTED = "not_attempted" 

70 FAILED = "failed" 

71 

72 

73class GraphConditionalType(StrEnum): 

74 IF = "if" 

75 WHILE = "while" 

76 SWITCH = "switch" 

77 

78 

79class GraphMemoryType(StrEnum): 

80 DEVICE = "device" 

81 HOST = "host" 

82 MANAGED = "managed" 

83 

84 

85class ManagedMemoryLocationType(StrEnum): 

86 DEVICE = "device" 

87 HOST = "host" 

88 HOST_NUMA = "host_numa" 

89 

90 

91class VirtualMemoryHandleType(StrEnum): 

92 POSIX_FD = "posix_fd" 

93 WIN32_KMT = "win32_kmt" 

94 FABRIC = "fabric" 

95 

96 

97class VirtualMemoryLocationType(StrEnum): 

98 DEVICE = "device" 

99 HOST = "host" 

100 HOST_NUMA = "host_numa" 

101 HOST_NUMA_CURRENT = "host_numa_current" 

102 

103 

104class VirtualMemoryGranularityType(StrEnum): 

105 MINIMUM = "minimum" 

106 RECOMMENDED = "recommended" 

107 

108 

109class VirtualMemoryAccessType(StrEnum): 

110 READ_WRITE = "rw" 

111 READ = "r" 

112 

113 

114class VirtualMemoryAllocationType(StrEnum): 

115 PINNED = "pinned" 

116 MANAGED = "managed" 

117 

118 

119del StrEnum