From 11568ba959540cfd6d5c9c3a0dfc7e8c28586f2c Mon Sep 17 00:00:00 2001 From: jianghui58 Date: Sat, 7 May 2022 11:04:44 +0800 Subject: [PATCH] fix GetOptimizerParams && fix assign op bug --- mindspore/lite/src/runtime/kernel/cpu/fp32_grad/assign.cc | 4 ++-- mindspore/lite/src/train/optimizer_kernel.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/assign.cc b/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/assign.cc index 62d9299e418..3e69e61aa78 100644 --- a/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/assign.cc +++ b/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/assign.cc @@ -36,12 +36,12 @@ int AssignCPUKernel::DoExecute(int task_id) { CHECK_NULL_RETURN(y); int length = in_tensors_.at(0)->ElementsNum(); int stride = UP_DIV(length, thread_count_); - size_t count = MSMIN(stride, length - stride * task_id); + int count = MSMIN(stride, length - stride * task_id); int start = stride * task_id; if (count > 0) { - memcpy(&(x[start]), &(y[start]), count * sizeof(float)); + memcpy(&(x[start]), &(y[start]), static_cast(count) * sizeof(float)); } return RET_OK; } diff --git a/mindspore/lite/src/train/optimizer_kernel.h b/mindspore/lite/src/train/optimizer_kernel.h index 78d58e6c76f..af389fd058d 100644 --- a/mindspore/lite/src/train/optimizer_kernel.h +++ b/mindspore/lite/src/train/optimizer_kernel.h @@ -70,7 +70,7 @@ class OptimizerKernel : public LiteKernel { indices.push_back(lr_idx_); for (size_t ix = 0; ix < indices.size(); ix++) { auto param = in_tensors_.at(indices[ix]); - if (param->data() == nullptr) { + if (!param->IsConst()) { continue; } params.push_back(param);