Validate languages support matrix. Raises ------ ValueError If the languages are not valid.
(self)
| 173 | |
| 174 | @model_validator(mode="after") |
| 175 | def _validate_languages(self) -> "BuildSpec": |
| 176 | """Validate languages support matrix. |
| 177 | |
| 178 | Raises |
| 179 | ------ |
| 180 | ValueError |
| 181 | If the languages are not valid. |
| 182 | """ |
| 183 | |
| 184 | python_languages = [ |
| 185 | SupportedLanguages.PYTORCH, |
| 186 | SupportedLanguages.TRITON, |
| 187 | SupportedLanguages.CUTE_DSL, |
| 188 | SupportedLanguages.CUTILE, |
| 189 | SupportedLanguages.CUDNN_FRONTEND, |
| 190 | ] |
| 191 | cpp_languages = [ |
| 192 | SupportedLanguages.CUTLASS, |
| 193 | SupportedLanguages.CUDNN, |
| 194 | SupportedLanguages.CUBLAS, |
| 195 | SupportedLanguages.CUDA_CPP, |
| 196 | ] |
| 197 | |
| 198 | included_python_langs = [ |
| 199 | language for language in self.languages if language in python_languages |
| 200 | ] |
| 201 | included_cpp_langs = [ |
| 202 | language for language in self.languages if language in cpp_languages |
| 203 | ] |
| 204 | if len(included_cpp_langs) and len(included_python_langs): |
| 205 | raise ValueError( |
| 206 | f"C++ and Python cannot be mixed, but got {included_cpp_langs} and {included_python_langs}" |
| 207 | ) |
| 208 | |
| 209 | # Validate entry point file suffix matches the language category. |
| 210 | entry_file = self.entry_point.split("::")[0] |
| 211 | suffix = Path(entry_file).suffix |
| 212 | if included_cpp_langs and suffix not in ( |
| 213 | ".cu", |
| 214 | ".cpp", |
| 215 | ".cc", |
| 216 | ".cxx", |
| 217 | ".c", |
| 218 | ".h", |
| 219 | ".hpp", |
| 220 | ".cuh", |
| 221 | ): |
| 222 | raise ValueError( |
| 223 | f"C++ languages require a C++/CUDA entry point file, " |
| 224 | f"but got '{entry_file}' (suffix '{suffix}')" |
| 225 | ) |
| 226 | if included_python_langs and suffix != ".py": |
| 227 | raise ValueError( |
| 228 | f"Python languages require a .py entry point file, " |
| 229 | f"but got '{entry_file}' (suffix '{suffix}')" |
| 230 | ) |
| 231 | return self |
| 232 |
nothing calls this directly
no outgoing calls
no test coverage detected