diff --git a/mindspore/lite/src/common/log_util.h b/mindspore/lite/src/common/log_util.h index 6321a3da847..0577c4af448 100644 --- a/mindspore/lite/src/common/log_util.h +++ b/mindspore/lite/src/common/log_util.h @@ -61,9 +61,18 @@ } \ } while (0) +#define CHECK_NOT_EQUAL_RETURN(size1, size2) \ + do { \ + if ((size1) != (size2)) { \ + MS_LOG(ERROR) << #size1 << " must be equal to " << #size2; \ + return mindspore::lite::RET_ERROR; \ + } \ + } while (0) + #else #define CHECK_NULL_RETURN(ptr) #define CHECK_NULL_RETURN_VOID(ptr) #define CHECK_LESS_RETURN(size1, size2) +#define CHECK_NOT_EQUAL_RETURN(size1, size2) #endif #endif // MINDSPORE_LITE_SRC_COMMON_LOG_UTIL_H_ diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc index d0f034fe979..fbf66319d0f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self_fp32.cc @@ -60,8 +60,8 @@ ArithmeticSelfBoolFunc ArithmeticSelfCPUKernel::GetArithmeticSelfBoolFun(int pri } int ArithmeticSelfCPUKernel::Prepare() { - CHECK_LESS_RETURN(in_tensors_.size(), 1); - CHECK_LESS_RETURN(out_tensors_.size(), 1); + CHECK_NOT_EQUAL_RETURN(in_tensors_.size(), 1); + CHECK_NOT_EQUAL_RETURN(out_tensors_.size(), 1); if (!InferShapeDone()) { return RET_OK; } diff --git a/mindspore/lite/src/scheduler.cc b/mindspore/lite/src/scheduler.cc index 06f0195726e..de162c76313 100644 --- a/mindspore/lite/src/scheduler.cc +++ b/mindspore/lite/src/scheduler.cc @@ -148,6 +148,10 @@ int CopyConstTensorData(const std::vector &tensors, int op_type) { } for (auto *tensor : tensors) { // only copy non-copied const tensor + if (!tensor->IsConst() && tensor->data() != nullptr) { + MS_LOG(ERROR) << "Illegitimate tensor : " << tensor->tensor_name(); + continue; + } if (!tensor->IsConst() || tensor->own_data()) { continue; }