From d19d15257e9c6176a5a314703e981452d003862a Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 23 May 2026 18:47:21 +0800 Subject: [PATCH] [Metal] Enable Metal 4 shader compilation Use the latest SDK language version when available so generated MPP tensor_ops shaders can compile on M5+ while preserving the existing fallback for older SDKs. --- src/runtime/metal/metal_module.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/metal/metal_module.mm b/src/runtime/metal/metal_module.mm index 782fc92235ba..d1212b3adf9f 100644 --- a/src/runtime/metal/metal_module.mm +++ b/src/runtime/metal/metal_module.mm @@ -124,7 +124,11 @@ int GetPropertyMask() const final { if (fmt_ == "metal") { MTLCompileOptions* opts = [MTLCompileOptions alloc]; +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000 + opts.languageVersion = MTLLanguageVersion4_0; +#else opts.languageVersion = MTLLanguageVersion2_3; +#endif opts.fastMathEnabled = YES; // opts = nil; // Per-kernel payload is bytes; treat as UTF-8 MSL source.