From d81cb6b5cf2e7669994144e3031dd37c6244f5f6 Mon Sep 17 00:00:00 2001 From: zengxianglong Date: Wed, 2 Dec 2020 15:24:38 +0800 Subject: [PATCH] fix a bug in normalize operator --- .../lite/src/runtime/kernel/arm/string/normalize.cc | 9 +++++---- mindspore/lite/src/runtime/kernel/arm/string/normalize.h | 2 +- mindspore/lite/test/models_mindspore.cfg | 1 + mindspore/lite/test/models_onnx_fp16.cfg | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/arm/string/normalize.cc b/mindspore/lite/src/runtime/kernel/arm/string/normalize.cc index cff856ba8f6..4af5b127f9d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/string/normalize.cc +++ b/mindspore/lite/src/runtime/kernel/arm/string/normalize.cc @@ -49,12 +49,13 @@ int NormalizeCPUKernel::Init() { int NormalizeCPUKernel::ReSize() { return RET_OK; } -std::string NormalizeCPUKernel::Trim(const std::string &str, const std::string &whitespace /*= " \t\n\v\f\r"*/) { - if (str.empty()) { +std::string NormalizeCPUKernel::Trim(const std::string &str, const std::string &pattern /*= " \t\n\v\f\r"*/) { + auto begin = str.find_first_not_of(pattern); + if (begin == std::string::npos) { + MS_LOG(WARNING) << "Meaningless input string!"; return ""; } - auto begin = str.find_first_not_of(whitespace); - auto end = str.find_last_not_of(whitespace); + auto end = str.find_last_not_of(pattern); const auto range = end - begin + 1; return str.substr(begin, range); } diff --git a/mindspore/lite/src/runtime/kernel/arm/string/normalize.h b/mindspore/lite/src/runtime/kernel/arm/string/normalize.h index b911af8b325..de7ea81a275 100644 --- a/mindspore/lite/src/runtime/kernel/arm/string/normalize.h +++ b/mindspore/lite/src/runtime/kernel/arm/string/normalize.h @@ -36,7 +36,7 @@ class NormalizeCPUKernel : public LiteKernel { int Run() override; private: - std::string Trim(const std::string &str, const std::string &whitespace = " \t\n\v\f\r"); + std::string Trim(const std::string &str, const std::string &pattern = " \t\n\v\f\r"); std::string GlobalReplace(const std::string &str, const std::string ®, const std::string &replace); std::string Normalize(const std::string &str); std::vector normalized_strs; diff --git a/mindspore/lite/test/models_mindspore.cfg b/mindspore/lite/test/models_mindspore.cfg index d684b289d04..e3d3105df62 100644 --- a/mindspore/lite/test/models_mindspore.cfg +++ b/mindspore/lite/test/models_mindspore.cfg @@ -15,3 +15,4 @@ mindspore_ghost-nose-pets-811.mindir 0.5 mindspore_ghost-pets-8244.mindir 1.5 mindspore_ghostnet600M-pets.mindir 1.5 mindspore_ghostnet_1x_pets_int8.mindir 12 +mindspore_deeplab_v3_s16.mindir 6.5 diff --git a/mindspore/lite/test/models_onnx_fp16.cfg b/mindspore/lite/test/models_onnx_fp16.cfg index 8e2d0c55cf0..318037a9ae8 100644 --- a/mindspore/lite/test/models_onnx_fp16.cfg +++ b/mindspore/lite/test/models_onnx_fp16.cfg @@ -33,3 +33,4 @@ rain-princess-9.onnx 5 udnie-9.onnx 3 adversarial_pruning.onnx 3 residual_distill_res34_cifar10_bs_1_update.onnx 2 +residual_distill_res50_cifar10_bs_1_update.onnx 2