diff --git a/mindspore/ccsrc/minddata/dataset/api/vision.cc b/mindspore/ccsrc/minddata/dataset/api/vision.cc index 5297f61c186..8d157e24837 100644 --- a/mindspore/ccsrc/minddata/dataset/api/vision.cc +++ b/mindspore/ccsrc/minddata/dataset/api/vision.cc @@ -692,10 +692,11 @@ Status DvppDecodeResizeCropOperation::ValidateParams() { } if (*min_element(crop_.begin(), crop_.end()) < 32 || *max_element(crop_.begin(), crop_.end()) > 2048) { std::string err_msg = "Dvpp module supports crop image with resolution in range [32, 2048], got Crop Parameters: "; - if (crop_.size() == 2) + if (crop_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[1] << "]"; - else + } else { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[0] << "]"; + } RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(resize_.begin(), resize_.end()) < 32 || *max_element(resize_.begin(), resize_.end()) > 2048) { diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.cc index b793261fbcc..31172e8dd98 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.cc @@ -14,9 +14,9 @@ */ #include "AclProcess.h" +#include #include #include -#include namespace { const int BUFFER_SIZE = 2048; @@ -125,7 +125,7 @@ APP_ERROR AclProcess::InitResource() { * @param: imageFile specifies the image path to be processed * @return: aclError which is error code of ACL API */ -APP_ERROR AclProcess::Preprocess(RawData &ImageInfo) { +APP_ERROR AclProcess::Preprocess(const RawData &ImageInfo) { // Decode process APP_ERROR ret = dvppCommon_->CombineJpegdProcess(ImageInfo, PIXEL_FORMAT_YUV_SEMIPLANAR_420, true); if (ret != APP_ERR_OK) { @@ -179,7 +179,7 @@ APP_ERROR AclProcess::Preprocess(RawData &ImageInfo) { * @param: imageFile specifies the image path to be processed * @return: aclError which is error code of ACL API */ -APP_ERROR AclProcess::Process(RawData &ImageInfo) { +APP_ERROR AclProcess::Process(const RawData &ImageInfo) { struct timeval begin = {0}; struct timeval end = {0}; gettimeofday(&begin, nullptr); @@ -219,28 +219,6 @@ APP_ERROR AclProcess::Process(RawData &ImageInfo) { return APP_ERR_OK; } -/* - * @description: Rename the image for saving - * @Param: primary name of image - * @return: aclError which is error code of ACL API - */ -APP_ERROR AclProcess::RenameFile(std::string &filename) { - std::string delimiter = "/"; - size_t pos = 0; - std::string token; - while ((pos = filename.find(delimiter)) != std::string::npos) { - token = filename.substr(0, pos); - filename.erase(0, pos + delimiter.length()); - } - delimiter = "."; - pos = filename.find(delimiter); - filename = filename.substr(0, pos); - if (filename.length() == 0) { - return APP_ERR_COMM_WRITE_FAIL; - } - return APP_ERR_OK; -} - void AclProcess::CropConfigFilter(CropRoiConfig &cfg, DvppCropInputInfo &cropinfo) { cfg.up = (resizeHeight_ - cropHeight_) / 2; if (cfg.up % 2 != 0) { @@ -274,4 +252,4 @@ void AclProcess::set_mode(bool flag) { repeat_ = flag; } bool AclProcess::get_mode() { return repeat_; } -void AclProcess::device_memory_release() { dvppCommon_->ReleaseDvppBuffer(); } \ No newline at end of file +void AclProcess::device_memory_release() { dvppCommon_->ReleaseDvppBuffer(); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.h b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.h index fc2b6dd531e..25b53eb3850 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/AclProcess.h @@ -16,10 +16,15 @@ #ifndef ACLMANAGER_H #define ACLMANAGER_H +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include #include #include #include "acl/acl.h" @@ -27,10 +32,6 @@ #include "mindspore/core/utils/log_adapter.h" #include "ErrorCode.h" #include "DvppCommon.h" -#include -#include -#include -#include mode_t SetFileDefaultUmask(); @@ -39,14 +40,14 @@ class AclProcess { AclProcess(uint32_t resizeWidth, uint32_t resizeHeight, uint32_t cropWidth, uint32_t cropHeight, aclrtContext context, aclrtStream stream = nullptr, std::shared_ptr dvppCommon = nullptr); - ~AclProcess(){}; + ~AclProcess() {} // Release all the resource APP_ERROR Release(); // Create resource for this sample APP_ERROR InitResource(); // Process the result - APP_ERROR Process(RawData &ImageInfo); + APP_ERROR Process(const RawData &ImageInfo); // API for access memory std::shared_ptr Get_Memory_Data(); // API for access device memory @@ -64,9 +65,7 @@ class AclProcess { // Initialize the modules used by this sample APP_ERROR InitModule(); // Preprocess the input image - APP_ERROR Preprocess(RawData &ImageInfo); - // Filename process - APP_ERROR RenameFile(std::string &filename); + APP_ERROR Preprocess(const RawData &ImageInfo); aclrtContext context_; aclrtStream stream_; diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/CommonDataType.h b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/CommonDataType.h index 2aefe99f792..b767606c95a 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/CommonDataType.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/CommonDataType.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "acl/acl.h" #include "acl/ops/acl_dvpp.h" diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.cc index 93d0e06936a..473a9b9b6b1 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.cc @@ -15,7 +15,6 @@ #include #include - #include "mindspore/core/utils/log_adapter.h" #include "DvppCommon.h" #include "CommonDataType.h" @@ -25,9 +24,9 @@ static auto g_picDescDeleter = [](acldvppPicDesc *picDesc) { acldvppDestroyPicDe static auto g_roiConfigDeleter = [](acldvppRoiConfig *p) { acldvppDestroyRoiConfig(p); }; static auto g_jpegeConfigDeleter = [](acldvppJpegeConfig *p) { acldvppDestroyJpegeConfig(p); }; -DvppCommon::DvppCommon(aclrtStream dvppStream) { dvppStream_ = dvppStream; } +DvppCommon::DvppCommon(aclrtStream dvppStream) : dvppStream_(dvppStream) {} -DvppCommon::DvppCommon(const VdecConfig &vdecConfig) { vdecConfig_ = vdecConfig; } +DvppCommon::DvppCommon(const VdecConfig &vdecConfig) : vdecConfig_(vdecConfig) {} /* * @description: Create a channel for processing image data, diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.h b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.h index 90aff168c8a..4499bf24e36 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/DvppCommon.h @@ -16,9 +16,10 @@ #ifndef DVPP_COMMON_H #define DVPP_COMMON_H +#include +#include #include "CommonDataType.h" #include "ErrorCode.h" - #include "acl/ops/acl_dvpp.h" const int MODULUS_NUM_2 = 2; diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.cpp b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.cpp index fa631410775..d2e104d4dc5 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.cpp +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.cpp @@ -37,14 +37,14 @@ std::string GetAppErrCodeInfo(const APP_ERROR err) { } } -void AssertErrorCode(int code, std::string file, std::string function, int line) { +void AssertErrorCode(const int code, const std::string file, const std::string function, const int line) { if (code != APP_ERR_OK) { MS_LOG(ERROR) << "Failed at " << file << "->" << function << "->" << line << ": error code=" << code; exit(code); } } -void CheckErrorCode(int code, std::string file, std::string function, int line) { +void CheckErrorCode(const int code, const std::string file, const std::string function, const int line) { if (code != APP_ERR_OK) { MS_LOG(ERROR) << "Failed at " << file << "->" << function << "->" << line << ": error code=" << code; } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.h b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.h index a61b0f03041..da297c1b634 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ErrorCode.h @@ -249,10 +249,10 @@ const std::string APP_ERR_FACE_LOG_STRING[] = { }; std::string GetAppErrCodeInfo(APP_ERROR err); -void AssertErrorCode(int code, std::string file, std::string function, int line); -void CheckErrorCode(int code, std::string file, std::string function, int line); +void AssertErrorCode(const int code, const std::string file, const std::string function, const int line); +void CheckErrorCode(const int code, const std::string file, const std::string function, const int line); #define RtAssert(code) AssertErrorCode(code, __FILE__, __FUNCTION__, __LINE__); #define RtCheckError(code) CheckErrorCode(code, __FILE__, __FUNCTION__, __LINE__); -#endif // ERROR_CODE_H_ \ No newline at end of file +#endif // ERROR_CODE_H_ diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ResourceManager.h b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ResourceManager.h index aad31353746..2d1ac7c2e24 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ResourceManager.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/utils/ResourceManager.h @@ -16,14 +16,16 @@ #ifndef RESOURCEMANAGER_H #define RESOURCEMANAGER_H +#include #include #include #include +#include #include +#include #include #include "CommonDataType.h" #include "ErrorCode.h" -#include #include "mindspore/core/utils/log_adapter.h" #include "mindspore/ccsrc/cxx_api/graph/acl/acl_env_guard.h" @@ -62,9 +64,9 @@ APP_ERROR ExistFile(const std::string &filePath); class ResourceManager { public: - ResourceManager(){}; + ResourceManager() {} - ~ResourceManager(){}; + ~ResourceManager() {} // Get the Instance of resource manager static std::shared_ptr GetInstance(); @@ -87,4 +89,4 @@ class ResourceManager { std::shared_ptr acl_env_; }; -#endif \ No newline at end of file +#endif diff --git a/tests/cxx_st/dataset/test_de.cc b/tests/cxx_st/dataset/test_de.cc index 1b0926dbf6f..44170b85dd5 100644 --- a/tests/cxx_st/dataset/test_de.cc +++ b/tests/cxx_st/dataset/test_de.cc @@ -74,7 +74,7 @@ TEST_F(TestDE, TestDvpp) { ASSERT_EQ(img->Shape().size(), 3); int32_t real_h = 0; int32_t real_w = 0; - int remainder = crop_size[crop_size.size() - 1] % 16; + int32_t remainder = crop_size[crop_size.size() - 1] % 16; if (crop_size.size() == 1) { real_h = (crop_size[0] % 2 == 0) ? crop_size[0] : crop_size[0] + 1; real_w = (remainder == 0) ? crop_size[0] : crop_size[0] + 16 - remainder;