From e4ce2e34dc163c2f8c4fd8962b2ab13a85c4fa97 Mon Sep 17 00:00:00 2001 From: xulei2020 <“xulei83@huawei.com”> Date: Thu, 29 Oct 2020 21:31:43 +0800 Subject: [PATCH] fix lite_cv bug for codex_c++ warning --- .../dataset/kernels/image/lite_cv/image_process.cc | 11 ++++++----- .../dataset/kernels/image/lite_cv/image_process.h | 4 ++-- .../dataset/kernels/image/lite_cv/lite_mat.cc | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc index 00e670bd91..70067da39c 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc @@ -130,7 +130,7 @@ static void ResizeBilinear3C(const unsigned char *src, int src_width, int src_he for (int k = 0; k < dst_width * 3; k++) { int16_t t0 = (int16_t)((y_weight[0] * (int16_t)(*row0_ptr0++)) >> 16); int16_t t1 = (int16_t)((y_weight[1] * (int16_t)(*row1_ptr1++)) >> 16); - *dst_ptr++ = (unsigned char)((t0 + t1 + 2) >> 2); + *dst_ptr++ = static_cast((t0 + t1 + 2) >> 2); } y_weight += 2; } @@ -202,7 +202,7 @@ static void ResizeBilinear1C(const unsigned char *src, int src_width, int src_he for (int k = 0; k < dst_width; k++) { int16_t t0 = (int16_t)((y_weight[0] * (int16_t)(*row0_ptr0++)) >> 16); int16_t t1 = (int16_t)((y_weight[1] * (int16_t)(*row1_ptr1++)) >> 16); - *dst_ptr++ = (unsigned char)((t0 + t1 + 2) >> 2); + *dst_ptr++ = static_cast((t0 + t1 + 2) >> 2); } y_weight += 2; @@ -873,7 +873,8 @@ std::vector ApplyNms(const std::vector> &all_boxes, std: } template -bool ImplementAffine(LiteMat &src, LiteMat &out_img, double M[6], std::vector &dsize, Pixel_Type borderValue) { +bool ImplementAffine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector &dsize, + Pixel_Type borderValue) { if (dsize.size() != 2 || CheckZero(dsize)) { return false; } @@ -912,11 +913,11 @@ bool ImplementAffine(LiteMat &src, LiteMat &out_img, double M[6], std::vector dsize, UINT8_C1 borderValue) { +bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector dsize, UINT8_C1 borderValue) { return ImplementAffine(src, out_img, M, dsize, borderValue); } -bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector dsize, UINT8_C3 borderValue) { +bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector dsize, UINT8_C3 borderValue) { return ImplementAffine(src, out_img, M, dsize, borderValue); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h index 81e78bacf8..21185c6a88 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h @@ -91,10 +91,10 @@ bool Split(const LiteMat &src, std::vector &mv); bool Merge(const std::vector &mv, LiteMat &dst); /// \brief Apply affine transformation for 1 channel image -bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector dsize, UINT8_C1 borderValue); +bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector dsize, UINT8_C1 borderValue); /// \brief Apply affine transformation for 3 channel image -bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector dsize, UINT8_C3 borderValue); +bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector dsize, UINT8_C3 borderValue); /// \brief Get default anchor boxes for Faster R-CNN, SSD, YOLO etc std::vector> GetDefaultBoxes(const BoxesConfig config); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc index 38fef09aba..cb4ddce123 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc @@ -26,6 +26,7 @@ LiteMat::LiteMat() { channel_ = 0; c_step_ = 0; dims_ = 0; + size_ = 0; data_type_ = LDataType::UINT8; ref_count_ = 0; } @@ -199,7 +200,10 @@ void *LiteMat::AlignMalloc(unsigned int size) { return nullptr; } -void LiteMat::AlignFree(void *ptr) { (void)free(reinterpret_cast(ptr)[-1]); } +void LiteMat::AlignFree(void *ptr) { + (void)free(reinterpret_cast(ptr)[-1]); + ptr = nullptr; +} inline void LiteMat::InitElemSize(LDataType data_type) { elem_size_ = data_type.SizeInBytes(); }