fixed 7c08927 from https://gitee.com/wan-junwei4/pytorch/pulls/5578
[feat]Provide ACL_OP_COMPILER_CACHE_MODE and ACL_OP_COMPILER_CACHE_DIR environment variables to enable cache.
This commit is contained in:
@@ -55,7 +55,13 @@ std::string GetCurDirPath() {
|
||||
}
|
||||
|
||||
void MakeCompileCacheDirAndSetOption() {
|
||||
auto compile_cache_dir = GetCurDirPath() + "/cache";
|
||||
char* compile_cache_mode_val = std::getenv("ACL_OP_COMPILER_CACHE_MODE");
|
||||
char* compile_cache_dir_val = std::getenv("ACL_OP_COMPILER_CACHE_DIR");
|
||||
|
||||
std::string compile_cache_mode = (compile_cache_mode_val == nullptr) ? std::string("enable")
|
||||
: std::string(compile_cache_mode_val);
|
||||
std::string compile_cache_dir = (compile_cache_dir_val == nullptr) ? GetCurDirPath() + "/cache"
|
||||
: std::string(compile_cache_dir_val);
|
||||
// mode : 750
|
||||
auto ret = Mkdir(compile_cache_dir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP);
|
||||
if (ret == -1) {
|
||||
@@ -64,7 +70,10 @@ void MakeCompileCacheDirAndSetOption() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
c10_npu::option::register_options::OptionRegister::GetInstance()->Set("ACL_OP_COMPILER_CACHE_MODE", "enable");
|
||||
if (compile_cache_mode != "enable" && compile_cache_mode != "disable" && compile_cache_mode != "force") {
|
||||
compile_cache_mode = std::string("enable");
|
||||
}
|
||||
c10_npu::option::register_options::OptionRegister::GetInstance()->Set("ACL_OP_COMPILER_CACHE_MODE", compile_cache_mode);
|
||||
c10_npu::option::register_options::OptionRegister::GetInstance()->Set("ACL_OP_COMPILER_CACHE_DIR", compile_cache_dir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user