diff --git a/mindspore/lite/examples/quick_start_cpp/main.cc b/mindspore/lite/examples/quick_start_cpp/main.cc index 449f427f992..820ba604918 100644 --- a/mindspore/lite/examples/quick_start_cpp/main.cc +++ b/mindspore/lite/examples/quick_start_cpp/main.cc @@ -25,7 +25,7 @@ #include "include/lite_session.h" std::string RealPath(const char *path) { - size_t max = 4096; + const size_t max = 4096; if (path == nullptr) { std::cerr << "path is nullptr" << std::endl; return ""; diff --git a/mindspore/lite/examples/runtime_cpp/main.cc b/mindspore/lite/examples/runtime_cpp/main.cc index 5bb35661521..f2cb1112628 100644 --- a/mindspore/lite/examples/runtime_cpp/main.cc +++ b/mindspore/lite/examples/runtime_cpp/main.cc @@ -27,7 +27,7 @@ #include "include/version.h" std::string RealPath(const char *path) { - size_t max = 4096; + const size_t max = 4096; if (path == nullptr) { std::cerr << "path is nullptr" << std::endl; return ""; @@ -553,7 +553,6 @@ int RunWithSharedMemoryPool(const char *model_path) { return -1; } auto session1 = mindspore::session::LiteSession::CreateSession(context1.get()); - if (session1 == nullptr) { delete model; std::cerr << "CreateSession failed while running." << std::endl; diff --git a/mindspore/lite/src/runtime/kernel/opencl/cl/strassen.cl b/mindspore/lite/src/runtime/kernel/opencl/cl/strassen.cl index c3d6d8f3635..744dc480c0c 100644 --- a/mindspore/lite/src/runtime/kernel/opencl/cl/strassen.cl +++ b/mindspore/lite/src/runtime/kernel/opencl/cl/strassen.cl @@ -44,7 +44,7 @@ __kernel void MatMul_BUF_Add_Sub_2(__global FLT4 *input, __global FLT4 *output, return; } int ci_co_4 = shape.w; - int origin_shape = 2 * ci_co_4; + const int origin_shape = 2 * ci_co_4; int index_1 = (gidx + offset.x) * origin_shape + gidy + offset.y; int index_2 = (gidx + offset.z) * origin_shape + gidy + offset.w; FLT4 result1 = input[index_1]; @@ -121,7 +121,7 @@ __kernel void MatMul_BUF_Filled(__global FLT4 *input, __global FLT4 *output, int } int stride_out = shape.z * shape.w; int index_out = gidx * stride_out + gidy; - int stride_origin = 2 * stride_out; + const int stride_origin = 2 * stride_out; int index_in = (gidx + offset.x) * stride_origin + gidy + offset.y; FLT4 result = input[index_in]; output[index_out] = result; diff --git a/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc b/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc index d149a0ad11c..93e4bc0faaa 100644 --- a/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc +++ b/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc @@ -500,7 +500,7 @@ kernel::LiteKernel *OpenCLConv2DCreator(const std::vector &input } // case 3: common conv2d - kernel::OpenCLKernel *kernel; + kernel::OpenCLKernel *kernel = nullptr; bool infer_shape_done = opParameter->infer_flag_; if (infer_shape_done && UseFcReplaceConv(inputs, outputs, conv_param)) { auto *fc_param = CreateFcParam(conv_param, inputs); diff --git a/mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc b/mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc index adf7684efb1..94f78de4708 100644 --- a/mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc +++ b/mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc @@ -226,7 +226,7 @@ int MatMulOpenCLKernel::Run() { kernel::LiteKernel *OpenCLMatMulKernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc) { - kernel::OpenCLKernel *kernel; + kernel::OpenCLKernel *kernel = nullptr; bool infer_shape_done = opParameter->infer_flag_; if (infer_shape_done && IsUseStrassenMatmul(inputs)) { MS_LOG(DEBUG) << "use_matmul_strassen";