forked from mindspore-Ecosystem/mindspore
!28457 code review & fix lite catch exception
Merge pull request !28457 from luoyang/fix_lite
This commit is contained in:
commit
705a2210c1
|
@ -431,7 +431,7 @@ APP_ERROR MDAclProcess::JPEG_R_(const DvppDataInfo &ImageInfo) {
|
|||
}
|
||||
|
||||
APP_ERROR MDAclProcess::JPEG_R_(std::string &last_step) {
|
||||
std::shared_ptr<DvppDataInfo> input_image = std::make_shared<DvppDataInfo>();
|
||||
std::shared_ptr<DvppDataInfo> input_image;
|
||||
if (last_step == "Decode") {
|
||||
input_image = dvppCommon_->GetDecodedImage();
|
||||
} else {
|
||||
|
@ -530,7 +530,7 @@ APP_ERROR MDAclProcess::JPEG_C_(const DvppDataInfo &ImageInfo) {
|
|||
MS_LOG(ERROR) << "Failed to copy data from host to device, ret = " << ret << ".";
|
||||
return ret;
|
||||
}
|
||||
// Unneccessary to be image after resize, maybe after decode, we store both of them in DecodedImage()
|
||||
// Unnecessary to be image after resize, maybe after decode, we store both of them in DecodedImage()
|
||||
std::shared_ptr<DvppDataInfo> resized_image = dvppCommon_->GetDecodedImage();
|
||||
uint32_t pri_h = resized_image->heightStride;
|
||||
uint32_t pri_w = resized_image->widthStride;
|
||||
|
@ -557,7 +557,7 @@ APP_ERROR MDAclProcess::JPEG_C_(const DvppDataInfo &ImageInfo) {
|
|||
}
|
||||
|
||||
APP_ERROR MDAclProcess::JPEG_C_(std::string &last_step) {
|
||||
std::shared_ptr<DvppDataInfo> input_image = std::make_shared<DvppDataInfo>();
|
||||
std::shared_ptr<DvppDataInfo> input_image;
|
||||
if (last_step == "Resize") {
|
||||
input_image = dvppCommon_->GetResizedImage();
|
||||
} else {
|
||||
|
@ -701,8 +701,6 @@ APP_ERROR MDAclProcess::JPEG_DRC(const RawData &ImageInfo) {
|
|||
const double fps = 1 * SEC2MS / costMs;
|
||||
MS_LOG(INFO) << "[dvpp Delay] cost: " << costMs << "ms\tfps: " << fps;
|
||||
// Get output of resize module
|
||||
/* 测试Device内存
|
||||
*/
|
||||
std::shared_ptr<DvppDataInfo> CropOutData = dvppCommon_->GetCropedImage();
|
||||
if (CropOutData->dataSize == 0) {
|
||||
MS_LOG(ERROR) << "CropOutData return NULL";
|
||||
|
@ -970,14 +968,14 @@ void MDAclProcess::CropConfigFilter(CropRoiConfig &cfg, DvppCropInputInfo &cropi
|
|||
|
||||
APP_ERROR MDAclProcess::ResizeConfigFilter(DvppDataInfo &resizeinfo, const uint32_t pri_w_,
|
||||
const uint32_t pri_h_) const {
|
||||
if (resizeWidth_ != 0) { // 如果输入参数个数为2,按指定参数缩放
|
||||
if (resizeWidth_ != 0) {
|
||||
resizeinfo.width = resizeWidth_;
|
||||
resizeinfo.widthStride = DVPP_ALIGN_UP(resizeWidth_, VPC_STRIDE_WIDTH);
|
||||
resizeinfo.height = resizeHeight_;
|
||||
resizeinfo.heightStride = DVPP_ALIGN_UP(resizeHeight_, VPC_STRIDE_HEIGHT);
|
||||
} else { // 如果输入参数个数为1,保持原图片比例缩放
|
||||
} else {
|
||||
if (pri_h_ >= pri_w_) {
|
||||
resizeinfo.width = resizeHeight_; // 若输入参数个数为1,则只有resizeHeight_有值
|
||||
resizeinfo.width = resizeHeight_;
|
||||
resizeinfo.widthStride = DVPP_ALIGN_UP(resizeinfo.width, VPC_STRIDE_WIDTH);
|
||||
resizeinfo.height = uint32_t(resizeHeight_ * pri_h_ / pri_w_);
|
||||
resizeinfo.heightStride = DVPP_ALIGN_UP(resizeinfo.height, VPC_STRIDE_HEIGHT);
|
||||
|
|
|
@ -44,7 +44,7 @@ static boolean JpegFillInputBuffer(j_decompress_ptr cinfo) {
|
|||
// so we catch runtime_error and just return FALSE.
|
||||
try {
|
||||
ERREXIT(cinfo, JERR_INPUT_EMPTY);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -95,7 +95,7 @@ static Status JpegReadScanlines(jpeg_decompress_struct *const cinfo, int max_sca
|
|||
int num_lines_read = 0;
|
||||
try {
|
||||
num_lines_read = jpeg_read_scanlines(cinfo, &scanline_ptr, 1);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Decode: jpeg_read_scanlines error.");
|
||||
}
|
||||
if (cinfo->out_color_space == JCS_CMYK && num_lines_read > 0) {
|
||||
|
@ -182,7 +182,7 @@ Status JpegCropAndDecode(const std::shared_ptr<Tensor> &input, std::shared_ptr<T
|
|||
(void)jpeg_read_header(&cinfo, TRUE);
|
||||
RETURN_IF_NOT_OK(JpegSetColorSpace(&cinfo));
|
||||
jpeg_calc_output_dimensions(&cinfo);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
return DestroyDecompressAndReturnError(e.what());
|
||||
}
|
||||
CHECK_FAIL_RETURN_UNEXPECTED((std::numeric_limits<int32_t>::max() - crop_w) > crop_x, "invalid crop width");
|
||||
|
@ -201,7 +201,7 @@ Status JpegCropAndDecode(const std::shared_ptr<Tensor> &input, std::shared_ptr<T
|
|||
try {
|
||||
(void)jpeg_start_decompress(&cinfo);
|
||||
jpeg_crop_scanline(&cinfo, &crop_x_aligned, &crop_w_aligned);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
return DestroyDecompressAndReturnError(e.what());
|
||||
}
|
||||
JDIMENSION skipped_scanlines = jpeg_skip_scanlines(&cinfo, crop_y);
|
||||
|
@ -300,7 +300,7 @@ Status Crop(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *outpu
|
|||
|
||||
*output = output_tensor;
|
||||
return Status::OK();
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Crop: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -316,7 +316,7 @@ Status GetJpegImageInfo(const std::shared_ptr<Tensor> &input, int *img_width, in
|
|||
JpegSetSource(&cinfo, input->GetBuffer(), input->SizeInBytes());
|
||||
(void)jpeg_read_header(&cinfo, TRUE);
|
||||
jpeg_calc_output_dimensions(&cinfo);
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
RETURN_STATUS_UNEXPECTED(e.what());
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ Status Normalize(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *
|
|||
static_cast<uchar *>(lite_mat_norm.data_ptr_), &output_tensor));
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Normalize: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -410,7 +410,7 @@ Status Resize(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *out
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "Resize: bilinear resize failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Resize: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -484,7 +484,7 @@ Status RgbToBgr(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *o
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "RgbToBgr: RGBToBGR failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("RgbToBgr: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -518,7 +518,7 @@ Status RgbToGray(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "RgbToGray: RGBToGRAY failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("RgbToGray: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -572,7 +572,7 @@ Status Pad(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "Pad: pad failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Pad: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -634,7 +634,7 @@ static Status RotateAngleWithOutMirror(const std::shared_ptr<Tensor> &input, std
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "Rotate: rotate failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Rotate: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -704,7 +704,7 @@ static Status RotateAngleWithMirror(const std::shared_ptr<Tensor> &input, std::s
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "Rotate: rotate failed.");
|
||||
|
||||
*output = output_tensor;
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Rotate: " + std::string(e.what()));
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -770,7 +770,7 @@ Status Affine(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *out
|
|||
|
||||
*output = output_tensor;
|
||||
return Status::OK();
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("Affine: " + std::string(e.what()));
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ Status GaussianBlur(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor
|
|||
CHECK_FAIL_RETURN_UNEXPECTED(ret, "GaussianBlur: GaussianBlur failed.");
|
||||
*output = output_tensor;
|
||||
return Status::OK();
|
||||
} catch (std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
RETURN_STATUS_UNEXPECTED("GaussianBlur: " + std::string(e.what()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,13 @@ std::string RotateOperation::Name() const { return kRotateOperation; }
|
|||
|
||||
Status RotateOperation::ValidateParams() {
|
||||
#ifndef ENABLE_ANDROID
|
||||
// interpolation
|
||||
if (interpolation_mode_ != InterpolationMode::kLinear &&
|
||||
interpolation_mode_ != InterpolationMode::kNearestNeighbour && interpolation_mode_ != InterpolationMode::kCubic &&
|
||||
interpolation_mode_ != InterpolationMode::kArea) {
|
||||
std::string err_msg = "Rotate: Invalid InterpolationMode, check input value of enum.";
|
||||
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);
|
||||
}
|
||||
// center
|
||||
if (center_.size() != 0 && center_.size() != 2) {
|
||||
std::string err_msg =
|
||||
|
|
|
@ -41,13 +41,13 @@ std::string UniformAugOperation::Name() const { return kUniformAugOperation; }
|
|||
Status UniformAugOperation::ValidateParams() {
|
||||
// transforms
|
||||
RETURN_IF_NOT_OK(ValidateVectorTransforms("UniformAug", transforms_));
|
||||
// num_ops
|
||||
RETURN_IF_NOT_OK(ValidateIntScalarPositive("UniformAug", "num_ops", num_ops_));
|
||||
if (num_ops_ > transforms_.size()) {
|
||||
std::string err_msg =
|
||||
"UniformAug: num_ops must be less than or equal to transforms size, but got: " + std::to_string(num_ops_);
|
||||
LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg);
|
||||
}
|
||||
// num_ops
|
||||
RETURN_IF_NOT_OK(ValidateIntScalarPositive("UniformAug", "num_ops", num_ops_));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue