From fc7ea3db78537145b91af31578f677c45d305285 Mon Sep 17 00:00:00 2001 From: liubuyu Date: Sat, 19 Sep 2020 17:27:01 +0800 Subject: [PATCH] code warning clean --- build.bat | 7 ++++--- build.sh | 2 +- include/inference.h | 1 - .../gpu/nn/mirror_pad_gpu_kernel.h | 1 - .../gpu/nn/mirror_pad_grad_gpu_kernel.h | 1 - .../gpu/nn/roi_align_gpu_kernel.cc | 1 - .../gpu/nn/roi_align_grad_gpu_kernel.cc | 1 - mindspore/ccsrc/runtime/device/CMakeLists.txt | 4 ++-- .../runtime/device/ascend/dump/data_dumper.cc | 1 - mindspore/ccsrc/runtime/device/gpu/gpu_common.h | 1 - .../runtime/device/gpu/mpi/mpi_initializer.cc | 1 - mindspore/ccsrc/utils/scoped_long_running.h | 1 - .../official/cv/psenet/src/ETSNET/pse/adaptor.cpp | 2 -- .../app/src/main/cpp/MSNetWork.cpp | 4 +--- .../app/src/main/cpp/MSNetWork.h | 2 +- .../app/src/main/cpp/MindSporeNetnative.cpp | 13 ++++++------- .../app/src/main/cpp/MindSporeNetnative.h | 2 -- .../app/src/main/cpp/MSNetWork.cpp | 3 +-- .../object_detection/app/src/main/cpp/MSNetWork.h | 2 +- .../app/src/main/cpp/MindSporeNetnative.cpp | 15 +++++++-------- .../app/src/main/cpp/ssd_util/ssd_util.cpp | 1 - 21 files changed, 24 insertions(+), 42 deletions(-) diff --git a/build.bat b/build.bat index cc5646aa0d9..b8568966aa9 100644 --- a/build.bat +++ b/build.bat @@ -16,12 +16,13 @@ @title mindspore_build SET BASEPATH=%CD% -IF NOT EXIST "%BASEPATH%/build" ( +SET BUILD_PATH=%BASEPATH%/build + +IF NOT EXIST "%BUILD_PATH%" ( md "build" ) -cd %BASEPATH%/build -set BUILD_PATH=%CD% +cd %BUILD_PATH% IF NOT EXIST "%BUILD_PATH%/mindspore" ( md "mindspore" diff --git a/build.sh b/build.sh index 8b66050ab68..27ac337bc8a 100755 --- a/build.sh +++ b/build.sh @@ -235,7 +235,7 @@ checkopts() ;; z) eval ARG=\$\{$OPTIND\} - if [[ -n $ARG && $ARG != -* ]]; then + if [[ -n "$ARG" && "$ARG" != -* ]]; then OPTARG="$ARG" check_on_off $OPTARG z OPTIND=$((OPTIND + 1)) diff --git a/include/inference.h b/include/inference.h index 7af19e1736e..ec45109b746 100644 --- a/include/inference.h +++ b/include/inference.h @@ -81,7 +81,6 @@ class MS_API InferSession { } static std::shared_ptr CreateSession(const std::string &device, uint32_t device_id); }; - } // namespace inference } // namespace mindspore #endif // MINDSPORE_INCLUDE_MS_SESSION_H diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_gpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_gpu_kernel.h index c7c4aefb761..59e22b79d2f 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_gpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_gpu_kernel.h @@ -66,7 +66,6 @@ class MirrorPadGpuFwdKernel : public GpuKernel { } string mode = GetValue(AnfAlgo::GetCNodePrimitive(kernel_node)->GetAttr("mode")); - if (mode == "REFLECT") { mode_ = 0; // reflected mirroring } else { diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_grad_gpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_grad_gpu_kernel.h index 2f793aba770..b0b37338460 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_grad_gpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/mirror_pad_grad_gpu_kernel.h @@ -66,7 +66,6 @@ class MirrorPadGpuBackKernel : public GpuKernel { } string mode = GetValue(AnfAlgo::GetCNodePrimitive(kernel_node)->GetAttr("mode")); - if (mode == "REFLECT") { mode_ = 0; // reflected mirroring } else { diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_gpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_gpu_kernel.cc index c79e3af0805..2665b4b40ec 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_gpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_gpu_kernel.cc @@ -27,6 +27,5 @@ MS_REG_GPU_KERNEL_ONE( ROIAlign, KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16), ROIAlignGpuFwdKernel, half) - } // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_grad_gpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_grad_gpu_kernel.cc index 42f310f5e56..f5be234b10a 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_grad_gpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/nn/roi_align_grad_gpu_kernel.cc @@ -27,6 +27,5 @@ MS_REG_GPU_KERNEL_ONE( ROIAlignGrad, KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16), ROIAlignGradGpuFwdKernel, half) - } // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/runtime/device/CMakeLists.txt b/mindspore/ccsrc/runtime/device/CMakeLists.txt index 490e783e73f..6666d08c3c0 100644 --- a/mindspore/ccsrc/runtime/device/CMakeLists.txt +++ b/mindspore/ccsrc/runtime/device/CMakeLists.txt @@ -14,12 +14,12 @@ endif () if (ENABLE_CPU) file(GLOB_RECURSE CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "cpu/*.cc") - list(REMOVE_ITEM CPU_SRC_LIST "cpu/mpi/mpi_adapter.cc", "cpu/mpi/mpi_export.cc") + list(REMOVE_ITEM CPU_SRC_LIST "cpu/mpi/mpi_adapter.cc" "cpu/mpi/mpi_export.cc") endif () if (ENABLE_MPI) if (ENABLE_CPU) - file(GLOB_RECURSE MPI_SRC_LIST "cpu/mpi/mpi_adapter.cc", "cpu/mpi/mpi_export.cc") + file(GLOB_RECURSE MPI_SRC_LIST "cpu/mpi/mpi_adapter.cc" "cpu/mpi/mpi_export.cc") set_property(SOURCE ${MPI_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) add_library(mpi_adapter SHARED ${MPI_SRC_LIST}) diff --git a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc index 58e7f234468..4d1595a18ac 100644 --- a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc +++ b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc @@ -57,7 +57,6 @@ constexpr const char *kOpTypeOpDebug = "Opdebug"; namespace mindspore { namespace device { namespace ascend { - DataDumper::~DataDumper() { ReleaseDevMem(&dev_load_mem_); ReleaseDevMem(&dev_unload_mem_); diff --git a/mindspore/ccsrc/runtime/device/gpu/gpu_common.h b/mindspore/ccsrc/runtime/device/gpu/gpu_common.h index 83f00e0fae1..d1505ea55e5 100644 --- a/mindspore/ccsrc/runtime/device/gpu/gpu_common.h +++ b/mindspore/ccsrc/runtime/device/gpu/gpu_common.h @@ -141,7 +141,6 @@ inline bool CheckNullInput(std::vector input_shape) { MS_LOG(EXCEPTION) << "CUAD curand Error: " << message << " | curandStatus: " << status; \ } \ } - } // namespace gpu } // namespace device } // namespace mindspore diff --git a/mindspore/ccsrc/runtime/device/gpu/mpi/mpi_initializer.cc b/mindspore/ccsrc/runtime/device/gpu/mpi/mpi_initializer.cc index 0a3bb3da722..d4046477ab7 100644 --- a/mindspore/ccsrc/runtime/device/gpu/mpi/mpi_initializer.cc +++ b/mindspore/ccsrc/runtime/device/gpu/mpi/mpi_initializer.cc @@ -25,7 +25,6 @@ namespace mindspore { namespace device { namespace gpu { - MPIInitializer &MPIInitializer::GetInstance() { static MPIInitializer instance; return instance; diff --git a/mindspore/ccsrc/utils/scoped_long_running.h b/mindspore/ccsrc/utils/scoped_long_running.h index b986c8f8c95..d81592d7d89 100644 --- a/mindspore/ccsrc/utils/scoped_long_running.h +++ b/mindspore/ccsrc/utils/scoped_long_running.h @@ -21,7 +21,6 @@ #include namespace mindspore { - // Base Class for scoped long running code. // Enter() should release some global resoure, like Python GIL; // Leave() should acquire the same global resource released. diff --git a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp index 777d3b45f8a..f2305d40858 100644 --- a/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp +++ b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp @@ -63,10 +63,8 @@ namespace pse_adaptor { vector row(label_mat.cols); for (int y = 0; y < label_mat.cols; ++y) { int label = label_mat.at(x, y); - if (label == 0) continue; if (area[label] < min_area) continue; - Point point(x, y); queue.push(point); row[y] = label; diff --git a/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.cpp b/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.cpp index ea1736e6f48..17d0d5373d1 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.cpp +++ b/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.cpp @@ -26,8 +26,7 @@ MSNetWork::MSNetWork(void) : session_(nullptr) {} MSNetWork::~MSNetWork(void) {} -void -MSNetWork::CreateSessionMS(char *modelBuffer, size_t bufferLen, mindspore::lite::Context *ctx) { +void MSNetWork::CreateSessionMS(char *modelBuffer, size_t bufferLen, mindspore::lite::Context *ctx) { session_ = mindspore::session::LiteSession::CreateSession(ctx); if (session_ == nullptr) { MS_PRINT("Create Session failed."); @@ -52,4 +51,3 @@ int MSNetWork::ReleaseNets(void) { delete session_; return 0; } - diff --git a/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.h b/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.h index 9ba12e53fc1..a6498b95a66 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.h +++ b/model_zoo/official/lite/image_classification/app/src/main/cpp/MSNetWork.h @@ -52,7 +52,7 @@ class MSNetWork { int ReleaseNets(void); - mindspore::session::LiteSession * session() const { return session_; } + mindspore::session::LiteSession *session() const { return session_; } private: mindspore::session::LiteSession *session_; }; diff --git a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp index 75f022461b8..4f9542e8fbd 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp +++ b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp @@ -145,9 +145,8 @@ char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { * @param msOutputs * @return */ -std::string -ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], - std::unordered_map msOutputs) { +std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], + std::unordered_map msOutputs) { // Get the branch of the model output. // Use iterators to get map elements. std::unordered_map::iterator iter; @@ -160,7 +159,7 @@ ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_ma MS_PRINT("Number of tensor elements:%d", tensorNum); // Get a pointer to the first score. - float *temp_scores = static_cast(outputTensor->MutableData()); + float *temp_scores = static_cast(outputTensor->MutableData()); float scores[RET_CATEGORY_SUM]; for (int i = 0; i < RET_CATEGORY_SUM; ++i) { @@ -202,12 +201,12 @@ bool BitmapToLiteMat(JNIEnv *env, const jobject &srcBitmap, LiteMat *lite_mat) { MS_PRINT("Init From RGBA error"); } } else { - unsigned char *pixels_ptr = new unsigned char[info.width*info.height*4]; + unsigned char *pixels_ptr = new unsigned char[info.width * info.height * 4]; unsigned char *ptr = pixels_ptr; unsigned char *data = reinterpret_cast(pixels); for (int i = 0; i < info.height; i++) { - memcpy(ptr, data, info.width*4); - ptr += info.width*4; + memcpy(ptr, data, info.width * 4); + ptr += info.width * 4; data += info.stride; } ret = InitFromPixel(reinterpret_cast(pixels_ptr), diff --git a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.h b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.h index 08374ac5af4..b28dc372348 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.h +++ b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.h @@ -18,6 +18,4 @@ #define MINDSPORE_JNI_HMS_DEBUG_MINDSPORENETNATIVE_H - - #endif // MINDSPORE_JNI_HMS_DEBUG_MINDSPORENETNATIVE_H diff --git a/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.cpp b/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.cpp index ea1736e6f48..5e71cdaf954 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.cpp +++ b/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.cpp @@ -26,8 +26,7 @@ MSNetWork::MSNetWork(void) : session_(nullptr) {} MSNetWork::~MSNetWork(void) {} -void -MSNetWork::CreateSessionMS(char *modelBuffer, size_t bufferLen, mindspore::lite::Context *ctx) { +void MSNetWork::CreateSessionMS(char *modelBuffer, size_t bufferLen, mindspore::lite::Context *ctx) { session_ = mindspore::session::LiteSession::CreateSession(ctx); if (session_ == nullptr) { MS_PRINT("Create Session failed."); diff --git a/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.h b/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.h index 9ba12e53fc1..a6498b95a66 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.h +++ b/model_zoo/official/lite/object_detection/app/src/main/cpp/MSNetWork.h @@ -52,7 +52,7 @@ class MSNetWork { int ReleaseNets(void); - mindspore::session::LiteSession * session() const { return session_; } + mindspore::session::LiteSession *session() const { return session_; } private: mindspore::session::LiteSession *session_; }; diff --git a/model_zoo/official/lite/object_detection/app/src/main/cpp/MindSporeNetnative.cpp b/model_zoo/official/lite/object_detection/app/src/main/cpp/MindSporeNetnative.cpp index 7eeea33ac61..7224b16ee6b 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/cpp/MindSporeNetnative.cpp +++ b/model_zoo/official/lite/object_detection/app/src/main/cpp/MindSporeNetnative.cpp @@ -45,7 +45,7 @@ bool BitmapToLiteMat(JNIEnv *env, const jobject &srcBitmap, LiteMat *lite_mat) { return false; } AndroidBitmap_lockPixels(env, srcBitmap, &pixels); - if (info.stride == info.width*4) { + if (info.stride == info.width * 4) { ret = InitFromPixel(reinterpret_cast(pixels), LPixelType::RGBA2RGB, LDataType::UINT8, info.width, info.height, lite_mat_bgr); @@ -53,12 +53,12 @@ bool BitmapToLiteMat(JNIEnv *env, const jobject &srcBitmap, LiteMat *lite_mat) { MS_PRINT("Init From RGBA error"); } } else { - unsigned char *pixels_ptr = new unsigned char[info.width*info.height*4]; + unsigned char *pixels_ptr = new unsigned char[info.width * info.height * 4]; unsigned char *ptr = pixels_ptr; unsigned char *data = reinterpret_cast(pixels); for (int i = 0; i < info.height; i++) { - memcpy(ptr, data, info.width*4); - ptr += info.width*4; + memcpy(ptr, data, info.width * 4); + ptr += info.width * 4; data += info.stride; } ret = InitFromPixel(reinterpret_cast(pixels_ptr), @@ -110,8 +110,7 @@ char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { * @param srcImageHeight The height of the original input image. * @return */ -std::string ProcessRunnetResult(std::unordered_map msOutputs, +std::string ProcessRunnetResult(std::unordered_map msOutputs, int srcImageWidth, int srcImageHeight) { std::unordered_map::iterator iter; iter = msOutputs.begin(); @@ -124,8 +123,8 @@ std::string ProcessRunnetResult(std::unordered_map(branch1_tensor->MutableData()); - float *tmpdata = reinterpret_cast(branch2_tensor->MutableData()); + float *tmpscores2 = reinterpret_cast(branch1_tensor->MutableData()); + float *tmpdata = reinterpret_cast(branch2_tensor->MutableData()); // Using ssd model util to process model branch outputs. SSDModelUtil ssdUtil(srcImageWidth, srcImageHeight); diff --git a/model_zoo/official/lite/object_detection/app/src/main/cpp/ssd_util/ssd_util.cpp b/model_zoo/official/lite/object_detection/app/src/main/cpp/ssd_util/ssd_util.cpp index f222bcb70f4..f7c53463c73 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/cpp/ssd_util/ssd_util.cpp +++ b/model_zoo/official/lite/object_detection/app/src/main/cpp/ssd_util/ssd_util.cpp @@ -177,7 +177,6 @@ void SSDModelUtil::getDefaultBoxes() { tempWHBox.boxw = h; tempWHBox.boxh = w; all_sizes.push_back(tempWHBox); - } else { // len(all_sizes) = 6. tempWHBox.boxw = sk1;