Debian Codegraph @

tensilelite/Tensile/Common/Types.py

raw symbols SCIP
1 ################################################################################
2 #
3 # Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
22 #
23 ################################################################################
24
25 from dataclasses import dataclass
26 from typing import NamedTuple
27
28 @dataclass
29 class IsaInfo:
30 asmCaps: dict
31 archCaps: dict
32 regCaps: dict
33 asmBugs: dict
34
35
36 class SemanticVersion(NamedTuple):
37 major: int
38 minor: int
39 patch: int
40
41 IsaVersion = SemanticVersion
42
43 class DebugConfig(NamedTuple):
44 """
45 Members:
46 debugKernel: assembly only, kernel gets buffer for debug "printing";
47 kernel writes data to memory, gets coppied to host and printed.
48 forceGenerateKernel: Even if error occurs in kernel generation (i.e. due to resource overflow),
49 generate the kernel source anyway. Tensile will also attempt to run
50 the kernel. Useful to examine and debug overflow errors.
51 printSolutionRejectionReason: Print why a solution is marked as invalid.
52 printIndexAssignmentInfo: Print the tensor index assignment info.
53
54 """
55 enableAsserts: bool=False
56 enableDebugA: bool=False
57 enableDebugB: bool=False
58 enableDebugC: bool=False
59 expectedValueC: float=16.0
60 forceCExpectedValue: bool=False
61 debugKernel: bool=False
62 forceGenerateKernel: bool=False
63 printSolutionRejectionReason: bool=False
64 splitGSU: bool=False
65 printIndexAssignmentInfo: bool=False
66
67
68 def makeDebugConfig(config: dict) -> DebugConfig:
69
70 enableAsserts = False
71 enableDebugA = False
72 enableDebugB = False
73 enableDebugC = False
74 expectedValueC = 16.0
75 forceCExpectedValue = False
76 debugKernel = False
77 forceGenerateKernel = False
78 printSolutionRejectionReason = False
79 splitGSU = False
80 printIndexAssignmentInfo = False
81
82 if "EnableAsserts" in config:
83 enableAsserts = config["EnableAsserts"]
84 if "EnableDebugA" in config:
85 enableDebugA = config["EnableDebugA"]
86 if "EnableDebugB" in config:
87 enableDebugB = config["EnableDebugB"]
88 if "EnableDebugC" in config:
89 enableDebugC = config["EnableDebugC"]
90 if "ExpectedValueC" in config:
91 expectedValueC = config["ExpectedValueC"]
92 if "ForceCExpectedValue" in config:
93 forceCExpectedValue = config["ForceCExpectedValue"]
94 if "DebugKernel" in config:
95 debugKernel = config["DebugKernel"]
96 if "ForceGenerateKernel" in config:
97 forceGenerateKernel = config["ForceGenerateKernel"]
98 if "PrintSolutionRejectionReason" in config:
99 printSolutionRejectionReason = config["PrintSolutionRejectionReason"]
100 if "SplitGSU" in config:
101 splitGSU = config["SplitGSU"]
102 if "PrintIndexAssignmentInfo" in config:
103 printIndexAssignmentInfo = config["PrintIndexAssignmentInfo"]
104
105 return DebugConfig(
106 enableAsserts,
107 enableDebugA,
108 enableDebugB,
109 enableDebugC,
110 expectedValueC,
111 forceCExpectedValue,
112 debugKernel,
113 forceGenerateKernel,
114 printSolutionRejectionReason,
115 splitGSU,
116 printIndexAssignmentInfo,
117 )