forked from mindspore-Ecosystem/mindspore
Remove the hash proto of compilation cache
This commit is contained in:
parent
3a5487c1bb
commit
8bad0f581c
|
@ -59,7 +59,6 @@
|
|||
#include "runtime/hardware/device_context_manager.h"
|
||||
#include "runtime/device/kernel_runtime_manager.h"
|
||||
#include "utils/system/sha256.h"
|
||||
#include "proto/compile_cache.pb.h"
|
||||
|
||||
#ifndef ENABLE_SECURITY
|
||||
#ifdef ENABLE_D
|
||||
|
@ -197,7 +196,7 @@ void SetLoopCount(const ResourcePtr &resource) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string GetUserDefindCachePath() {
|
||||
std::string GetUserDefinedCachePath() {
|
||||
auto user_defined_path = MsContext::GetInstance()->get_param<std::string>(MS_CTX_COMPILE_CACHE_PATH);
|
||||
if (!user_defined_path.empty()) {
|
||||
user_defined_path += "/";
|
||||
|
@ -211,7 +210,7 @@ std::string GetUserDefindCachePath() {
|
|||
}
|
||||
|
||||
std::string GetCompileCacheDir() {
|
||||
static const std::string user_defined_path = GetUserDefindCachePath();
|
||||
static const std::string user_defined_path = GetUserDefinedCachePath();
|
||||
static uint32_t rank_id = IsStandAlone() ? 0 : GetRank();
|
||||
static const std::string compile_cache_dir =
|
||||
user_defined_path + "rank_" + std::to_string(rank_id) + "/" + kCompileCacheSubDir;
|
||||
|
@ -266,16 +265,13 @@ bool CheckDepFilesHashConsistency(const std::string ¤t_dep_files_hash) {
|
|||
<< ErrnoToString(errno);
|
||||
return false;
|
||||
}
|
||||
compile_cache::CompileCacheProto proto;
|
||||
if (!proto.ParseFromIstream(&input)) {
|
||||
MS_LOG(ERROR) << "Parse the file " << realpath.value() << " from input stream failed.";
|
||||
return false;
|
||||
}
|
||||
if (!proto.has_dep_files_hash()) {
|
||||
std::string checkpoint_hash;
|
||||
input >> checkpoint_hash;
|
||||
if (checkpoint_hash.empty()) {
|
||||
MS_LOG(ERROR) << "Get the compilation dependency files hash from " << realpath.value() << " failed.";
|
||||
return false;
|
||||
}
|
||||
if (proto.dep_files_hash() != current_dep_files_hash) {
|
||||
if (checkpoint_hash != current_dep_files_hash) {
|
||||
MS_LOG(WARNING) << "The compilation dependency files are changed.";
|
||||
return false;
|
||||
}
|
||||
|
@ -394,13 +390,7 @@ bool ExportDepFilesHash(const ResourcePtr &resource) {
|
|||
MS_LOG(ERROR) << "Open cache file '" << realpath.value() << "' failed!" << ErrnoToString(errno);
|
||||
return false;
|
||||
}
|
||||
compile_cache::CompileCacheProto proto;
|
||||
proto.set_dep_files_hash(resource->compile_cache_dep_files_hash());
|
||||
if (!proto.SerializeToOstream(&fout)) {
|
||||
MS_LOG(ERROR) << "Failed to write the dependency files hash to file " << realpath.value();
|
||||
fout.close();
|
||||
return false;
|
||||
}
|
||||
fout << resource->compile_cache_dep_files_hash();
|
||||
fout.close();
|
||||
ChangeFileMode(realpath.value(), S_IRUSR);
|
||||
return true;
|
||||
|
|
|
@ -117,6 +117,7 @@ def _check_all_tensor(sequence):
|
|||
return True
|
||||
|
||||
def _get_filename_from_trace(trace):
|
||||
# format: File "xxx.py", line x, in <module>
|
||||
strings = trace.strip().split(' ')
|
||||
filename = strings[1].rstrip(',').strip('"')
|
||||
return filename
|
||||
|
@ -171,19 +172,17 @@ def _get_compile_cache_dep_files():
|
|||
else:
|
||||
return []
|
||||
tb = traceback.format_stack()
|
||||
tb.reverse()
|
||||
compile_cache_dep_files = []
|
||||
filename = None
|
||||
# Get the entry script file.
|
||||
for i in range(1, len(tb)):
|
||||
# format: File "xxx.py", line x, in <module>
|
||||
filename = _get_filename_from_trace(tb[i])
|
||||
if i + 1 < len(tb):
|
||||
next_filename = _get_filename_from_trace(tb[i + 1])
|
||||
if next_filename.startswith(python_bin_dir):
|
||||
break
|
||||
entry_id = 0
|
||||
while entry_id < len(tb) and _get_filename_from_trace(tb[entry_id]).startswith(python_bin_dir):
|
||||
logger.debug(f"trace: {tb[entry_id]}")
|
||||
entry_id += 1
|
||||
if entry_id < len(tb):
|
||||
filename = _get_filename_from_trace(tb[entry_id])
|
||||
if filename is None:
|
||||
return None
|
||||
return []
|
||||
file_path = os.path.realpath(filename)
|
||||
logger.debug(f"entry script file path: {file_path}")
|
||||
compile_cache_dep_files.append(file_path)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
syntax = "proto2";
|
||||
package compile_cache;
|
||||
|
||||
message CompileCacheProto {
|
||||
optional string dep_files_hash = 1;
|
||||
}
|
Loading…
Reference in New Issue