From 3199d72d66042e0a886bf95f2e518c9b8ce6266e Mon Sep 17 00:00:00 2001 From: seiriosPlus Date: Thu, 24 Sep 2020 11:14:40 +0800 Subject: [PATCH] add mode for save --- paddle/fluid/operators/distributed/large_scale_kv.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/operators/distributed/large_scale_kv.h b/paddle/fluid/operators/distributed/large_scale_kv.h index 4c017e88732..a9363038883 100644 --- a/paddle/fluid/operators/distributed/large_scale_kv.h +++ b/paddle/fluid/operators/distributed/large_scale_kv.h @@ -637,13 +637,13 @@ class SparseVariable { if (mode == 1) { id_need_save = true; } else { - id_need_save = value.second.seen_after_last_save_; + id_need_save = value.second->seen_after_last_save_; } if (id_need_save) { ids.push_back(value.first); } - value.second.seen_after_last_save_ = false; + value.second->seen_after_last_save_ = false; } } } @@ -661,7 +661,7 @@ class SparseVariable { auto *slr = var->GetMutable(); auto *src_t = slr->mutable_value(); - src_t->Resize({ids.size(), dim}); + src_t->Resize({static_cast(ids.size()), dim}); auto *value = src_t->mutable_data(place); dims.push_back(dim); @@ -669,12 +669,11 @@ class SparseVariable { tensors.push_back(value); } - std::vector *>> *values; - Get(ids, variables, values); + std::vector *>> values; + Get(ids, valuenames, &values); int64_t offset = 0; - for (auto *value : values) { - auto vss = value; + for (auto &vss : values) { for (int i = 0; i < static_cast(vss.size()); i++) { auto &vs = vss[i]; std::memcpy(tensors[i] + offset * dims[i], vs->data(), -- GitLab