From 302746d6a3c8d2aee9606de1f04a1c0f6215d165 Mon Sep 17 00:00:00 2001 From: huangbingjian Date: Fri, 23 Apr 2021 15:47:12 +0800 Subject: [PATCH] fix code check --- mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc | 4 ++-- mindspore/ccsrc/utils/system/sha256.h | 2 +- mindspore/core/ir/tensor.cc | 4 ++-- model_zoo/research/nlp/gpt2/src/gpt2_for_finetune.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc b/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc index 0db90f5863c..27e06fcb293 100644 --- a/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc +++ b/mindspore/ccsrc/frontend/optimizer/ad/dfunctor.cc @@ -880,7 +880,7 @@ static std::vector> FindPrimalJPair(const FuncGrap } else if (IsPrimitive(cnode->inputs().at(0), prim::kPrimJ)) { // To find J user. auto j_user = GetJUser(node_user_map, cnode, index); - primal_j_pair.push_back({nullptr, j_user}); + primal_j_pair.emplace_back(std::pair(nullptr, j_user)); } } @@ -985,7 +985,7 @@ void DFunctor::EliminatePrimalGraph() { idx0->set_abstract(std::make_shared(imm0)); auto getitem0 = construct_wrapper->NewCNode({tuple_getitem, primal_user, idx0}); getitem0->set_abstract(primal_abs); - manager->Replace(primal_user, getitem0); + (void)manager->Replace(primal_user, getitem0); } } } // namespace ad diff --git a/mindspore/ccsrc/utils/system/sha256.h b/mindspore/ccsrc/utils/system/sha256.h index ba255316d31..b2c2f678c73 100644 --- a/mindspore/ccsrc/utils/system/sha256.h +++ b/mindspore/ccsrc/utils/system/sha256.h @@ -131,7 +131,7 @@ std::string ConvertToString(uint32_t *input, const int &size) { oss << std::hex; for (int i = 0; i < size; ++i) { for (int j = static_cast(sizeof(uint32_t) / sizeof(uint8_t)) - 1; j >= 0; --j) { - uint8_t val = static_cast((input[i] >> static_cast(j * kBitNumber)) & 0xff); + auto val = static_cast((input[i] >> static_cast(j * kBitNumber)) & 0xff); oss << std::setw(2) << std::setfill('0') << static_cast(val); } } diff --git a/mindspore/core/ir/tensor.cc b/mindspore/core/ir/tensor.cc index 1630620ea59..d5f934ad5ec 100644 --- a/mindspore/core/ir/tensor.cc +++ b/mindspore/core/ir/tensor.cc @@ -387,12 +387,12 @@ class TensorDataImpl : public TensorData { } // Replace # with placeholder. size_t index = str.find('#'); - while (index != str.npos) { + while (index != std::string::npos) { size_t pos = index; while (str[pos] == '#') { pos++; } - int len = pos - index; + size_t len = pos - index; std::string space(max_width - len, ' '); str = str.replace(index, len, space); index = str.find('#', index); diff --git a/model_zoo/research/nlp/gpt2/src/gpt2_for_finetune.py b/model_zoo/research/nlp/gpt2/src/gpt2_for_finetune.py index 4bc7bd2a560..63ac1af76df 100644 --- a/model_zoo/research/nlp/gpt2/src/gpt2_for_finetune.py +++ b/model_zoo/research/nlp/gpt2/src/gpt2_for_finetune.py @@ -133,7 +133,7 @@ class GPT2FinetuneCell(nn.Cell): init = self.alloc_status() init = F.depend(init, loss) clear_before_grad = self.clear_before_grad(init) - self.depend_parameter_use(clear_before_grad, scaling_sens) + scaling_sens = F.depend(scaling_sens, clear_before_grad) grads = self.grad(self.network, weights)(input_ids, input_mask, label_ids,