Browse Source

modify static check

tags/v1.1.0
yvette 5 years ago
parent
commit
1cedf86d43
6 changed files with 29 additions and 2 deletions
  1. +13
    -0
      mindspore/lite/src/common/utils.cc
  2. +5
    -0
      mindspore/lite/src/common/utils.h
  3. +1
    -1
      mindspore/lite/src/executor.cc
  4. +1
    -1
      mindspore/lite/src/executor.h
  5. +1
    -0
      mindspore/lite/src/runtime/allocator.cc
  6. +8
    -0
      mindspore/lite/tools/anf_importer/import_from_protobuf.cc

+ 13
- 0
mindspore/lite/src/common/utils.cc View File

@@ -54,6 +54,10 @@ uint64_t GetTimeUs() {

std::string RemoveSubStr(const std::string &from, const std::string &sub_str, RemoveSubStrMode mode) {
std::string result = from;
if (from.empty()) {
MS_LOG(ERROR) << "string is empty";
return "";
}
if (mode == PREFIX) {
if (from.substr(0, sub_str.length()) == sub_str) {
result = from.substr(sub_str.size());
@@ -73,6 +77,10 @@ std::string RemoveSubStr(const std::string &from, const std::string &sub_str, Re
}

std::vector<std::string> StrSplit(const std::string &str, const std::string &pattern) {
if (str.empty()) {
MS_LOG(ERROR) << "string is empty";
return {};
}
std::string::size_type pos;
std::vector<std::string> result;
std::string tmpStr(str + pattern);
@@ -95,6 +103,11 @@ std::vector<std::string> Tokenize(const std::string &src, const std::string &del
return {};
}

if (src.empty()) {
MS_LOG(ERROR) << "string is empty";
return {};
}

std::vector<std::string> tokens;
size_t offset = 0;



+ 5
- 0
mindspore/lite/src/common/utils.h View File

@@ -106,6 +106,11 @@ inline Option<std::string> ToString(bool value) {
// get the file name from a given path
// for example: "/usr/bin", we will get "bin"
inline std::string GetFileName(const std::string &path) {
if (path.empty()) {
MS_LOG(ERROR) << "string is empty";
return "";
}

char delim = '/';

size_t i = path.rfind(delim, path.length());


+ 1
- 1
mindspore/lite/src/executor.cc View File

@@ -19,7 +19,7 @@
#include "include/errorcode.h"

namespace mindspore::lite {
int Executor::CheckInputs(std::vector<Tensor *> &in_tensors) {
int Executor::CheckInputs(const std::vector<Tensor *> &in_tensors) {
for (auto &inTensor : in_tensors) {
if (inTensor == nullptr) {
MS_LOG(ERROR) << "Graph input tensor is nullptr";


+ 1
- 1
mindspore/lite/src/executor.h View File

@@ -35,7 +35,7 @@ class Executor {
const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr);

protected:
static int CheckInputs(std::vector<Tensor *> &in_tensors);
static int CheckInputs(const std::vector<Tensor *> &in_tensors);
};
} // namespace mindspore::lite
#endif

+ 1
- 0
mindspore/lite/src/runtime/allocator.cc View File

@@ -88,6 +88,7 @@ void DefaultAllocator::Free(void *buf) {
}
UnLock();
free(buf);
buf = nullptr;
}

size_t DefaultAllocator::GetTotalSize() {


+ 8
- 0
mindspore/lite/tools/anf_importer/import_from_protobuf.cc View File

@@ -416,6 +416,10 @@ bool AnfImporterFromProtobuf::GetAttrValueForCNode(const PrimitivePtr &prim, con
return false;
}
const std::string &ref_attr_name = attr_proto.ref_attr_name();
if (ref_attr_name.empty()) {
MS_LOG(ERROR) << "ref_attr_name is empty";
return false;
}
string type = "";
std::size_t pos(0);
if ((pos = ref_attr_name.find("scalar:")) != std::string::npos) {
@@ -520,6 +524,10 @@ bool AnfImporterFromProtobuf::GetAttrValueForValueNode(const std::string &value_
return false;
}
const std::string &ref_attr_name = attr_proto.ref_attr_name();
if (ref_attr_name.empty()) {
MS_LOG(ERROR) << "ref_attr_name is empty";
return false;
}
string type = "";
std::size_t pos(0);
if ((pos = ref_attr_name.find("scalar:")) != std::string::npos) {


Loading…
Cancel
Save