Summary: As it results in build failures for some internal targets that stuck on older compiler. Platform update is tracked in [T223408150](https://www.internalfb.com/tasks?t=223408150)

Test Plan: CI

Differential Revision: D74220384

Pull Request resolved: https://github.com/pytorch/pytorch/pull/152909
Approved by: https://github.com/cyyever, https://github.com/wdvr
This commit is contained in:
Nikita Shulga
2025-05-06 22:02:42 +00:00
committed by PyTorch MergeBot
parent 5fe58ab5bd
commit 1c30862d8f

View File

@ -1,5 +1,4 @@
#include <cstdlib>
#include <filesystem>
#include <sstream>
#include <string>
#include <utility>
@ -11,6 +10,9 @@
#include <torch/csrc/jit/api/function_impl.h>
#include <torch/csrc/jit/jit_opt_limit.h>
// NOTE: Don't try to migrate jit to C++17 yet
// As it's used in some embedded platforms
namespace torch::jit {
static std::unordered_map<std::string, int64_t>& passes_to_current_counter() {
@ -38,7 +40,7 @@ static std::unordered_map<std::string, int64_t> parseJITOptLimitOption(
}
auto index_at = line.find_last_of('=');
auto pass_name = line.substr(0, index_at);
pass_name = std::filesystem::path(pass_name).replace_extension().string();
pass_name = c10::detail::ExcludeFileExtension(pass_name);
auto opt_limit = parseOptLimit(line.substr(index_at + 1));
passes_to_opt_limits.emplace(std::move(pass_name), opt_limit);
}
@ -55,7 +57,9 @@ bool opt_limit(const char* pass_name) {
static const std::unordered_map<std::string, int64_t> passes_to_opt_limits =
parseJITOptLimitOption(opt_limit.value());
std::string pass = std::filesystem::path(pass_name).stem().string();
std::string pass{pass_name};
pass = c10::detail::StripBasename(pass);
pass = c10::detail::ExcludeFileExtension(pass);
auto opt_limit_it = passes_to_opt_limits.find(pass);
if (opt_limit_it == passes_to_opt_limits.end()) {