fix codedex warning
This commit is contained in:
parent
12641803cf
commit
5c98edb31f
|
@ -215,8 +215,7 @@ KernelPackPtr SearchCache(const std::string &kernel_name, const std::string &pro
|
|||
KernelPackPtr InsertCache(const std::string &kernel_name, const std::string &processor) {
|
||||
MS_LOG(INFO) << "Insert cache for kernel:" << kernel_name << ", processr:" << processor;
|
||||
KernelMeta *bin_map = KernelMeta::GetInstance();
|
||||
std::string kernel_json;
|
||||
kernel_json = bin_map->kernel_meta_path();
|
||||
std::string kernel_json = bin_map->kernel_meta_path();
|
||||
(void)kernel_json.append(kernel_name).append(kJsonSuffix);
|
||||
KernelPackPtr kernel_pack = std::make_shared<KernelPack>();
|
||||
if (!kernel_pack->ReadFromJsonFile(kernel_json, processor)) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <fstream>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/convert_utils_base.h"
|
||||
#include "utils/log_adapter.h"
|
||||
|
||||
namespace mindspore {
|
||||
|
@ -28,18 +29,18 @@ namespace distributed {
|
|||
namespace storage {
|
||||
namespace {
|
||||
bool CheckFStreamLength(const std::string &file_name, std::fstream &fs, size_t size) {
|
||||
size_t cur_pos = fs.tellp();
|
||||
fs.seekp(0, std::ios::end);
|
||||
size_t cur_pos = LongToSize(fs.tellp());
|
||||
(void)fs.seekp(0, std::ios::end);
|
||||
if (!fs.good() || fs.fail() || fs.bad()) {
|
||||
MS_LOG(ERROR) << "Failed to seedp file pos, file name: " << file_name;
|
||||
return false;
|
||||
}
|
||||
size_t end_pos = fs.tellp();
|
||||
size_t end_pos = LongToSize(fs.tellp());
|
||||
if (end_pos - cur_pos < size) {
|
||||
MS_LOG(ERROR) << "The content length of file:" << file_name << " is less than expected size: " << size;
|
||||
return false;
|
||||
}
|
||||
fs.seekp(cur_pos);
|
||||
(void)fs.seekp(cur_pos);
|
||||
if (!fs.good() || fs.fail() || fs.bad()) {
|
||||
MS_LOG(ERROR) << "Failed to seedp file pos, file name: " << file_name;
|
||||
return false;
|
||||
|
@ -66,13 +67,13 @@ bool FileIOUtils::Write(const std::string &file_name, const std::vector<std::pai
|
|||
const void *data = item.first;
|
||||
MS_ERROR_IF_NULL(data);
|
||||
size_t size = item.second;
|
||||
fs.write(reinterpret_cast<const char *>(data), size);
|
||||
(void)fs.write(reinterpret_cast<const char *>(data), SizeToLong(size));
|
||||
if (!fs.good() || fs.fail() || fs.bad()) {
|
||||
fs.close();
|
||||
MS_LOG(ERROR) << "Insert data to fstream failed.";
|
||||
return false;
|
||||
}
|
||||
fs.flush();
|
||||
(void)fs.flush();
|
||||
if (!fs.good() || fs.fail() || fs.bad()) {
|
||||
fs.close();
|
||||
MS_LOG(ERROR) << "Insert data to fstream failed.";
|
||||
|
@ -106,7 +107,7 @@ bool FileIOUtils::Read(const std::string &file_name, const std::vector<std::pair
|
|||
return false;
|
||||
}
|
||||
|
||||
fs.read(reinterpret_cast<char *>(data), size);
|
||||
(void)fs.read(reinterpret_cast<char *>(data), SizeToLong(size));
|
||||
if (!fs.good() || fs.fail() || fs.bad()) {
|
||||
fs.close();
|
||||
MS_LOG(ERROR) << "Read data from fstream failed.";
|
||||
|
|
|
@ -126,9 +126,12 @@ void LocalFile::WriteBlockFiles(const std::vector<InputData> &inputs) {
|
|||
size_t offset = 0;
|
||||
for (size_t block_index = 0; block_index < block_num; ++block_index) {
|
||||
// Create block meta.
|
||||
auto block_meta_ptr =
|
||||
std::make_shared<BlockMeta>(file_path_ + "/" + kBlockMetaFilePrefix + std::to_string(block_index) + kJsonSuffix);
|
||||
block_meta_ptr->Initialize();
|
||||
std::string block_meta_file_name =
|
||||
file_path_ + "/" + kBlockMetaFilePrefix + std::to_string(block_index) + kJsonSuffix;
|
||||
auto block_meta_ptr = std::make_shared<BlockMeta>(block_meta_file_name);
|
||||
if (!block_meta_ptr->Initialize()) {
|
||||
MS_LOG(EXCEPTION) << "Initialize block meta failed, file name [" << block_meta_file_name << "]";
|
||||
}
|
||||
|
||||
size_t cur_lower_bound = slice_size * block_index;
|
||||
block_meta_ptr->Insert(kShardRangeLowerBound, cur_lower_bound);
|
||||
|
@ -165,7 +168,7 @@ void LocalFile::WriteOneBlockFile(size_t block_index, const std::vector<InputDat
|
|||
for (size_t input_index = 0; input_index < inputs.size(); ++input_index) {
|
||||
const void *data_ptr = reinterpret_cast<const char *>(std::get<1>(inputs.at(input_index))) + offset;
|
||||
size_t data_size = field_size;
|
||||
block_inputs_data.emplace_back(data_ptr, data_size);
|
||||
(void)block_inputs_data.emplace_back(data_ptr, data_size);
|
||||
}
|
||||
|
||||
const auto &block_ptr = block_list_.at(block_index);
|
||||
|
@ -205,7 +208,7 @@ void LocalFile::Read(const std::vector<OutputData> &outputs) {
|
|||
for (size_t output_index = 0; output_index < outputs.size(); ++output_index) {
|
||||
void *data_ptr = reinterpret_cast<char *>(std::get<0>(outputs[output_index])) + offset;
|
||||
size_t data_size = field_size;
|
||||
block_output_data.emplace_back(data_ptr, data_size);
|
||||
(void)block_output_data.emplace_back(data_ptr, data_size);
|
||||
}
|
||||
|
||||
const auto &block_ptr = block_list_[block_index];
|
||||
|
@ -213,7 +216,10 @@ void LocalFile::Read(const std::vector<OutputData> &outputs) {
|
|||
if (!block_ptr->CheckSha256Seq()) {
|
||||
MS_LOG(EXCEPTION) << "CheckSha256 failed, file name [" << block_ptr->block_file_name() << "]";
|
||||
}
|
||||
FileIOUtils::Read(block_ptr->block_file_name(), block_output_data);
|
||||
|
||||
if (!FileIOUtils::Read(block_ptr->block_file_name(), block_output_data)) {
|
||||
MS_LOG(EXCEPTION) << "Read block file failed, file name [" << block_ptr->block_file_name() << "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +260,10 @@ bool LocalFile::LoadBlocksInfo() {
|
|||
sort(block_meta_file_name_list.begin(), block_meta_file_name_list.end());
|
||||
for (size_t i = 0; i < block_file_name_list.size(); i++) {
|
||||
auto block_meta_ptr = std::make_shared<BlockMeta>(block_meta_file_name_list[i]);
|
||||
block_meta_ptr->Initialize();
|
||||
if (!block_meta_ptr->Initialize()) {
|
||||
MS_LOG(ERROR) << "Initialize block meta failed, file name [" << block_meta_file_name_list[i] << "]";
|
||||
return false;
|
||||
}
|
||||
block_meta_list_.push_back(block_meta_ptr);
|
||||
|
||||
auto block_ptr = std::make_shared<Block>(block_file_name_list[i]);
|
||||
|
|
|
@ -372,7 +372,7 @@ bool NodeManager::IsNodePersisting(const std::string &node_id) const {
|
|||
return nodes_persisting_.find(node_id) != nodes_persisting_.end();
|
||||
}
|
||||
|
||||
void NodeManager::AddPersistingNode(const std::string &node_id) { nodes_persisting_.insert(node_id); }
|
||||
void NodeManager::AddPersistingNode(const std::string &node_id) { (void)nodes_persisting_.insert(node_id); }
|
||||
|
||||
bool NodeManager::IsAllNodeInPersisting() {
|
||||
// The worker role does not support disaster recovery currently.
|
||||
|
|
|
@ -64,7 +64,7 @@ bool ParameterServer::Init(const FuncGraphPtr &func_graph) {
|
|||
handler_.reset(new ServerHandler(this));
|
||||
handler_->Init();
|
||||
|
||||
recover_handler_.reset(new RecoverHandler(this));
|
||||
recover_handler_ = std::make_unique<RecoverHandler>(this);
|
||||
|
||||
InitOptimInfoBuilders();
|
||||
server_node_->set_handler(*handler_);
|
||||
|
@ -266,7 +266,7 @@ void ParameterServer::PersistKernels(const Key &key,
|
|||
}
|
||||
if (shapes_list.size() < keys.size()) {
|
||||
std::vector<std::vector<size_t>> shape_tmp;
|
||||
std::transform(shapes->begin(), shapes->end(), std::back_inserter(shape_tmp),
|
||||
(void)std::transform(shapes->begin(), shapes->end(), std::back_inserter(shape_tmp),
|
||||
[](const std::shared_ptr<std::vector<size_t>> &shape_ptr) { return *shape_ptr; });
|
||||
shapes_list.push_back(shape_tmp);
|
||||
config_storage->PutValue<std::vector<std::vector<std::vector<size_t>>>>(kShapes, shapes_list);
|
||||
|
@ -308,7 +308,7 @@ void ParameterServer::PersistInitParameters(const Key &key, const WeightPtr &par
|
|||
config_map[distributed::storage::kFileStoragePath] = real_storage_file_path;
|
||||
persistent_weight->Initialize(config_map);
|
||||
|
||||
weights_dirty_info_.emplace(key, distributed::storage::DirtyInfo());
|
||||
(void)weights_dirty_info_.emplace(key, distributed::storage::DirtyInfo());
|
||||
persistent_weight->Persist(distributed::storage::DirtyInfo());
|
||||
|
||||
MS_LOG(INFO) << "Finish persist initialized parameter, key: " << key;
|
||||
|
@ -340,7 +340,7 @@ void ParameterServer::InitEmbeddingTable(
|
|||
std::accumulate(input_shapes.begin(), input_shapes.end(), IntToSize(1), std::multiplies<size_t>());
|
||||
|
||||
std::shared_ptr<std::vector<int>> embedding_shape = std::make_shared<std::vector<int>>();
|
||||
std::transform(input_shapes.begin(), input_shapes.end(), std::back_inserter(*embedding_shape),
|
||||
(void)std::transform(input_shapes.begin(), input_shapes.end(), std::back_inserter(*embedding_shape),
|
||||
[](size_t dim) { return static_cast<int>(dim); });
|
||||
|
||||
WeightPtr embedding =
|
||||
|
@ -582,9 +582,9 @@ void ParameterServer::UpdateEmbeddings(const Key &key, const LookupIds &lookup_i
|
|||
void ParameterServer::UpdateDirtyInfo(const Key &key, const LookupIds &lookup_ids, int64_t offset) {
|
||||
if (EnableRecovery()) {
|
||||
std::set<int> sorted_ids;
|
||||
std::for_each(lookup_ids.begin(), lookup_ids.end(), [&](uint64_t id) {
|
||||
(void)std::for_each(lookup_ids.begin(), lookup_ids.end(), [&](uint64_t id) {
|
||||
int index = SizeToInt(id) - LongToInt(offset);
|
||||
sorted_ids.insert(index);
|
||||
(void)sorted_ids.insert(index);
|
||||
});
|
||||
|
||||
auto iter = weights_dirty_info_.find(key);
|
||||
|
@ -592,7 +592,7 @@ void ParameterServer::UpdateDirtyInfo(const Key &key, const LookupIds &lookup_id
|
|||
MS_LOG(EXCEPTION) << "Cannot find dirty info for embedding table, key: " << key;
|
||||
}
|
||||
distributed::storage::DirtyInfo &dirty_info = iter->second;
|
||||
std::for_each(sorted_ids.begin(), sorted_ids.end(), [&](int id) { dirty_info.push_back(id); });
|
||||
(void)std::for_each(sorted_ids.begin(), sorted_ids.end(), [&](int id) { dirty_info.push_back(id); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -744,7 +744,7 @@ void ParameterServer::RecoverParameters(const std::vector<Key> &keys) {
|
|||
std::accumulate(input_shapes.begin(), input_shapes.end(), IntToSize(1), std::multiplies<size_t>());
|
||||
|
||||
std::shared_ptr<std::vector<int>> embedding_shape = std::make_shared<std::vector<int>>();
|
||||
std::transform(input_shapes.begin(), input_shapes.end(), std::back_inserter(*embedding_shape),
|
||||
(void)std::transform(input_shapes.begin(), input_shapes.end(), std::back_inserter(*embedding_shape),
|
||||
[](size_t dim) { return static_cast<int>(dim); });
|
||||
|
||||
PersistentWeightPtr embedding =
|
||||
|
@ -767,7 +767,7 @@ void ParameterServer::RecoverParameters(const std::vector<Key> &keys) {
|
|||
embedding->Initialize(config_map);
|
||||
embedding->Restore();
|
||||
weights_[key] = embedding;
|
||||
weights_dirty_info_.emplace(key, distributed::storage::DirtyInfo());
|
||||
(void)weights_dirty_info_.emplace(key, distributed::storage::DirtyInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ void GraphScheduler::Run(ActorSet *const actor_set, const std::vector<DeviceCont
|
|||
std::unique_lock<std::mutex> locker(mutex);
|
||||
std::condition_variable thread_blocker;
|
||||
const int64_t kTimeToWait = 2;
|
||||
thread_blocker.wait_for(locker, std::chrono::seconds(kTimeToWait));
|
||||
(void)thread_blocker.wait_for(locker, std::chrono::seconds(kTimeToWait));
|
||||
MS_LOG(EXCEPTION) << op_context.error_info_;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue