diff --git a/mindspore/core/mindrt/src/thread/threadpool.cc b/mindspore/core/mindrt/src/thread/threadpool.cc index a67502e32f653975ac570091008d583e6b39b984..1a9e675b92e17b5b1fd1d59e031f63eb28f69d4d 100644 --- a/mindspore/core/mindrt/src/thread/threadpool.cc +++ b/mindspore/core/mindrt/src/thread/threadpool.cc @@ -1,5 +1,5 @@ /** - * Copyright 2021 Huawei Technologies Co., Ltd + * Copyright 2021-2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -192,7 +192,7 @@ int ThreadPool::CreateThreads(size_t thread_num, const std::vector &core_li int ThreadPool::ParallelLaunch(const Func &func, Content content, int task_num) const { // if single thread, run master thread - if (thread_num() <= 1 || task_num <= 1) { + if (task_num <= 1) { for (int i = 0; i < task_num; ++i) { int ret = func(content, i, 0, 1); if (ret != 0) { diff --git a/mindspore/lite/src/lite_session.cc b/mindspore/lite/src/lite_session.cc index cec037a72d425706253957e504f9c410fef85eff..2f94b9d387451a3a64ee560bc110712ac926b7f7 100644 --- a/mindspore/lite/src/lite_session.cc +++ b/mindspore/lite/src/lite_session.cc @@ -221,7 +221,7 @@ int LiteSession::ConvertTensorsData(const lite::LiteModel *model, size_t tensor_ auto shape_info = dst_tensor->shape(); if (shape_info.end() != std::find_if(shape_info.begin(), shape_info.end(), [](const int shape) { return shape <= 0; })) { - MS_LOG(ERROR) << "Invalid shape size." << src_tensor->handler()->name()->c_str(); + MS_LOG(ERROR) << "Invalid shape size, tensor name: " << src_tensor->handler()->name(); return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/string/skip_gram.cc b/mindspore/lite/src/runtime/kernel/arm/string/skip_gram.cc index d161bbbe2383dc6316a946370c9f7d9b9119d1fc..d612975a999f6b09e42a8ec2a3fcdf2248465e31 100644 --- a/mindspore/lite/src/runtime/kernel/arm/string/skip_gram.cc +++ b/mindspore/lite/src/runtime/kernel/arm/string/skip_gram.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2020-2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ int SkipGramCPUKernel::Prepare() { CHECK_LESS_RETURN(out_tensors_.size(), 1); CHECK_NULL_RETURN(in_tensors_[0]); CHECK_NULL_RETURN(out_tensors_[0]); + MS_CHECK_TRUE_RET(in_tensors_[0]->data_type() == kObjectTypeString, RET_ERROR); if (!InferShapeDone()) { return RET_OK; } @@ -92,14 +93,15 @@ int SkipGramCPUKernel::Run() { } else { if (index > 0 && ((skip_gram_parameter_->include_all_ngrams && index <= skip_gram_parameter_->ngram_size) || (!skip_gram_parameter_->include_all_ngrams && index == skip_gram_parameter_->ngram_size))) { - std::vector gram(2 * index - 1); + const int twice = 2; + std::vector gram(twice * index - 1); char blank[1] = {' '}; StringPack blank_str = {1, blank}; - for (int i = 0; i < 2 * index - 2; i += 2) { - gram.at(i) = words.at(stack.at(i / 2)); + for (int i = 0; i < twice * index - twice; i += twice) { + gram.at(i) = words.at(stack.at(i / twice)); gram.at(i + 1) = blank_str; } - gram.at(2 * index - 2) = words.at(stack.at(index - 1)); + gram.at(twice * index - twice) = words.at(stack.at(index - 1)); result.push_back(gram); } index--;