[feat]Provide ACL_OP_COMPILER_CACHE_MODE and ACL_OP_COMPILER_CACHE_DIR  environment variables to enable cache.
This commit is contained in:
w00809619
2023-08-23 11:24:46 +00:00
committed by 万俊伟
parent 3638d7fb14
commit 0252fbaa45
@@ -40,7 +40,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) {
@@ -49,7 +55,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);
}