Fix invalid format string in libfmt calls (#148855)

Wrap shaderSource inside fmt::runtime because the format string is not a string literal and can't pass libfmt's compile time check in C++23
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148855
Approved by: https://github.com/Skylion007
This commit is contained in:
cyy 2025-03-10 14:47:52 +00:00 committed by PyTorch MergeBot
parent a81751d8b7
commit b8b1b364c9

View File

@ -823,19 +823,19 @@ id<MTLLibrary> MetalShaderLibrary::getLibrary(const std::initializer_list<std::s
auto it = params.begin(); auto it = params.begin();
switch (nparams) { switch (nparams) {
case 1: case 1:
lib = compileLibrary(fmt::format(shaderSource, *it)); lib = compileLibrary(fmt::format(fmt::runtime(shaderSource), *it));
break; break;
case 2: { case 2: {
auto& first = *it++; auto& first = *it++;
auto& second = *it; auto& second = *it;
lib = compileLibrary(fmt::format(shaderSource, first, second)); lib = compileLibrary(fmt::format(fmt::runtime(shaderSource), first, second));
break; break;
} }
case 3: { case 3: {
auto& first = *it++; auto& first = *it++;
auto& second = *it++; auto& second = *it++;
auto& third = *it; auto& third = *it;
lib = compileLibrary(fmt::format(shaderSource, first, second, third)); lib = compileLibrary(fmt::format(fmt::runtime(shaderSource), first, second, third));
break; break;
} }
default: default: