diff --git a/build.bat b/build.bat index cc5646aa0d..b8568966aa 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 e381f3ccbe..d7f55ab4d3 100755 --- a/build.sh +++ b/build.sh @@ -237,7 +237,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 7af19e1736..ec45109b74 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 c7c4aefb76..59e22b79d2 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 2f793aba77..b0b3733846 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 c79e3af080..2665b4b40e 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 42f310f5e5..f5be234b10 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 490e783e73..6666d08c3c 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 58e7f23446..4d1595a18a 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 83f00e0fae..d1505ea55e 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 0a3bb3da72..d4046477ab 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/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp b/model_zoo/official/cv/psenet/src/ETSNET/pse/adaptor.cpp index 777d3b45f8..f2305d4085 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 ea1736e6f4..17d0d5373d 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 9ba12e53fc..a6498b95a6 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 75f022461b..4f9542e8fb 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 08374ac5af..b28dc37234 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 ea1736e6f4..5e71cdaf95 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 9ba12e53fc..a6498b95a6 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 7eeea33ac6..7224b16ee6 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 f222bcb70f..f7c53463c7 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;