Skip to content

Commit b0f9272

Browse files
committed
Fix the compile failure. (#63)
1 parent 844ef56 commit b0f9272

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

aten/src/ATen/mps/MPSDevice.mm

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@
1212
static c10::once_flag mpsdev_init;
1313

1414
static inline MTLLanguageVersion getMetalLanguageVersion(const id<MTLDevice>& device) {
15-
#if defined(__MAC_10_13) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13
16-
#else
17-
#error "Metal is not available on the current platform."
18-
#endif
19-
20-
// MPS Advanced Indexing needs at least Metal 2.0 (support for Argument Buffer and function constants)
15+
// MPS Advanced Indexing needs at least Metal 2.0 (support for Argument Buffers and function constants)
2116
MTLLanguageVersion languageVersion;
22-
if (@available(macOS 13.0, *)) {
23-
languageVersion = MTLLanguageVersion3_0;
24-
} else if (@available(macOS 12.0, *)) {
25-
languageVersion = MTLLanguageVersion2_4;
26-
} else if (@available(macOS 11.0, *)) {
27-
languageVersion = MTLLanguageVersion2_3;
28-
} else if (@available(macOS 10.15, *)) {
29-
languageVersion = MTLLanguageVersion2_2;
30-
} else if (@available(macOS 10.14, *)) {
31-
languageVersion = MTLLanguageVersion2_1;
32-
} else if (@available(macOS 10.13, *)) {
17+
18+
#if defined(__MAC_13_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0
19+
languageVersion = MTLLanguageVersion3_0;
20+
#elif defined(__MAC_12_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0
21+
languageVersion = MTLLanguageVersion2_4;
22+
#elif defined(__MAC_11_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0
23+
languageVersion = MTLLanguageVersion2_3;
24+
#elif defined(__MAC_10_15) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_15
25+
languageVersion = MTLLanguageVersion2_2;
26+
#elif defined(__MAC_10_14) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_14
27+
languageVersion = MTLLanguageVersion2_1;
28+
#elif defined(__MAC_10_13) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13
3329
languageVersion = MTLLanguageVersion2_0;
34-
}
30+
#elif
31+
#error "Metal is not available on the current platform."
32+
#endif
3533

3634
TORCH_CHECK([device supportsFamily:MTLGPUFamilyMac2], "Missing Metal support for MTLGPUFamilyMac2");
3735
return languageVersion;

0 commit comments

Comments
 (0)