Fix warning information.

This commit is contained in:
Zhenglong Li 2020-12-24 17:49:32 +08:00
parent 07578ca31e
commit 425c3c6abc
10 changed files with 34 additions and 53 deletions

View File

@ -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) {

View File

@ -14,9 +14,9 @@
*/
#include "AclProcess.h"
#include <sys/stat.h>
#include <sys/time.h>
#include <thread>
#include <sys/stat.h>
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(); }
void AclProcess::device_memory_release() { dvppCommon_->ReleaseDvppBuffer(); }

View File

@ -16,10 +16,15 @@
#ifndef ACLMANAGER_H
#define ACLMANAGER_H
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/types.h>
#include <string>
#include <map>
#include <climits>
#include <string>
#include <string.h>
#include <map>
#include <iostream>
#include <memory>
#include "acl/acl.h"
@ -27,10 +32,6 @@
#include "mindspore/core/utils/log_adapter.h"
#include "ErrorCode.h"
#include "DvppCommon.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
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> 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<void> 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_;

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "acl/acl.h"
#include "acl/ops/acl_dvpp.h"

View File

@ -15,7 +15,6 @@
#include <iostream>
#include <memory>
#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,

View File

@ -16,9 +16,10 @@
#ifndef DVPP_COMMON_H
#define DVPP_COMMON_H
#include <vector>
#include <memory>
#include "CommonDataType.h"
#include "ErrorCode.h"
#include "acl/ops/acl_dvpp.h"
const int MODULUS_NUM_2 = 2;

View File

@ -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;
}

View File

@ -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_
#endif // ERROR_CODE_H_

View File

@ -16,14 +16,16 @@
#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H
#include <sys/stat.h>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <unordered_map>
#include <memory>
#include <mutex>
#include "CommonDataType.h"
#include "ErrorCode.h"
#include <sys/stat.h>
#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<ResourceManager> GetInstance();
@ -87,4 +89,4 @@ class ResourceManager {
std::shared_ptr<mindspore::api::AclEnvGuard> acl_env_;
};
#endif
#endif

View File

@ -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;