forked from mindspore-Ecosystem/mindspore
!41919 [MSLITE][CPU] fuzz problem fix
Merge pull request !41919 from Greatpan/deconv_fuzz1
This commit is contained in:
commit
b1c9ea6925
|
@ -222,6 +222,19 @@ int ConvolutionBaseCPUKernel::CheckResizeValid() {
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
int ConvolutionBaseCPUKernel::CheckDeconvResizeValid() {
|
||||
// ===============check in channel================= //
|
||||
auto filter_tensor = in_tensors_.at(kWeightIndex);
|
||||
CHECK_NULL_RETURN(filter_tensor);
|
||||
auto filter_out_channel = filter_tensor->Batch();
|
||||
int resize_out_channel = in_tensors_.at(kInputIndex)->Channel();
|
||||
if (filter_out_channel != resize_out_channel) {
|
||||
MS_LOG(ERROR) << "Channel of resized input should be equal to in channel of filter.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int ConvolutionBaseCPUKernel::SetIfPerChannel() {
|
||||
if (in_tensors_.size() < kInputSize1) {
|
||||
MS_LOG(ERROR) << "filter tensor not exist.";
|
||||
|
|
|
@ -63,6 +63,7 @@ class ConvolutionBaseCPUKernel : public LiteKernel {
|
|||
int SetQuantMultiplier();
|
||||
void SetRoundingAndMultipilerMode();
|
||||
int CheckResizeValid();
|
||||
int CheckDeconvResizeValid();
|
||||
void FreeQuantParam();
|
||||
void *MallocAlignedData(size_t alignment, size_t size);
|
||||
void FreeAlignedData(void **ptr);
|
||||
|
|
|
@ -96,14 +96,25 @@ int DeconvolutionDepthwiseCPUKernel::Prepare() {
|
|||
}
|
||||
|
||||
int DeconvolutionDepthwiseCPUKernel::ReSize() {
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), 1);
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), C2NUM);
|
||||
CHECK_LESS_RETURN(out_tensors_.size(), 1);
|
||||
CHECK_NULL_RETURN(in_tensors_.front());
|
||||
CHECK_NULL_RETURN(out_tensors_.front());
|
||||
CHECK_NULL_RETURN(conv_param_);
|
||||
CHECK_NULL_RETURN(sliding_);
|
||||
|
||||
auto ret = InitSlideParam();
|
||||
auto ret = ConvolutionBaseCPUKernel::CheckDeconvResizeValid();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Resize is invalid.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto weight_tensor = in_tensors_.at(kWeightIndex);
|
||||
CHECK_NULL_RETURN(weight_tensor);
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_h_, weight_tensor->Height());
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_w_, weight_tensor->Width());
|
||||
|
||||
ret = InitSlideParam();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "InitSlideParam is failed!";
|
||||
return ret;
|
||||
|
|
|
@ -34,12 +34,23 @@ DeConvolutionCPUKernel::~DeConvolutionCPUKernel() {
|
|||
}
|
||||
|
||||
int DeConvolutionCPUKernel::ReSize() {
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), 1);
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), C2NUM);
|
||||
CHECK_LESS_RETURN(out_tensors_.size(), 1);
|
||||
CHECK_NULL_RETURN(conv_param_);
|
||||
CHECK_NULL_RETURN(matmul_param_);
|
||||
|
||||
auto ret = ConvolutionBaseCPUKernel::Prepare();
|
||||
auto ret = ConvolutionBaseCPUKernel::CheckDeconvResizeValid();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Resize is invalid.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto weight_tensor = in_tensors_.at(kWeightIndex);
|
||||
CHECK_NULL_RETURN(weight_tensor);
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_h_, weight_tensor->Height());
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_w_, weight_tensor->Width());
|
||||
|
||||
ret = ConvolutionBaseCPUKernel::Prepare();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "ConvolutionBaseCPUKernel init error!";
|
||||
return ret;
|
||||
|
|
|
@ -334,15 +334,26 @@ int DeConvolutionWinogradCPUKernel::InitDataParam() {
|
|||
}
|
||||
|
||||
int DeConvolutionWinogradCPUKernel::ReSize() {
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), 1);
|
||||
CHECK_LESS_RETURN(in_tensors_.size(), C2NUM);
|
||||
CHECK_LESS_RETURN(out_tensors_.size(), 1);
|
||||
CHECK_NULL_RETURN(in_tensors_.at(kInputIndex));
|
||||
CHECK_NULL_RETURN(out_tensors_.at(kOutputIndex));
|
||||
CHECK_NULL_RETURN(conv_param_);
|
||||
CHECK_NULL_RETURN(deconv_param_);
|
||||
|
||||
auto ret = ConvolutionBaseCPUKernel::CheckDeconvResizeValid();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Resize is invalid.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto weight_tensor = in_tensors_.at(kWeightIndex);
|
||||
CHECK_NULL_RETURN(weight_tensor);
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_h_, weight_tensor->Height());
|
||||
CHECK_NOT_EQUAL_RETURN(conv_param_->kernel_w_, weight_tensor->Width());
|
||||
|
||||
FreeResizeBuf();
|
||||
auto ret = ConvolutionBaseCPUKernel::Prepare();
|
||||
ret = ConvolutionBaseCPUKernel::Prepare();
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "prepare is failed!";
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue