Skip to content

Commit

Permalink
enable "-Wall" build flag; fix "-Wreorder" warnings. (#207)
Browse files Browse the repository at this point in the history
* enable "-Wall" build flag; fix "-Wreorder" warnings.

* fix "-Wsign-compare" warnings

* fix "-Wunused-but-set-variable" and "-Wunused-variable" warnings

* fix "-Wcatch-value=" warnings
  • Loading branch information
djie1 authored and linxie47 committed Dec 11, 2024
1 parent cc8c99a commit 7c968c1
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 35 deletions.
7 changes: 5 additions & 2 deletions ivsr_sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#
cmake_minimum_required(VERSION 3.10)

project(IVSR DESCRIPTION "Intel Video Super Resolution SDK")
project(IVSR DESCRIPTION "Intel IVSR SDK")
include(GNUInstallDirs)
set(OUTPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/lib)

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

set(SDK_PRIVATE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/privates/include)

add_subdirectory(src)
Expand All @@ -28,4 +31,4 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
FILES_MATCHING PATTERN "*.h"
)

install(TARGETS ivsr LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS ivsr LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
1 change: 0 additions & 1 deletion ivsr_sdk/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set (TARGET_NAME "vsr_sample")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

Expand Down
6 changes: 3 additions & 3 deletions ivsr_sdk/src/include/InferTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class InferTask {
using QueueCallbackFunction = std::function<void(InferTask::Ptr)>;
// construct function
InferTask(char* inBuf, char* outBuf, QueueCallbackFunction callbackQueue, InferFlag flag, ivsr_cb_t* ivsr_cb)
: inputPtr_(inBuf),
outputPtr_(outBuf),
_callbackFunction(callbackQueue),
: _callbackFunction(callbackQueue),
flag_(flag),
inputPtr_(inBuf),
outputPtr_(outBuf),
cb(ivsr_cb) {}

InferFlag getInferFlag() {
Expand Down
6 changes: 3 additions & 3 deletions ivsr_sdk/src/include/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class engine {

public:
engine(Derived* derived)
: _derived(derived),
init_func([=]() -> IVSRStatus {
: init_func([=]() -> IVSRStatus {
return _derived->init_impl();
}),
run_func([=](InferTask::Ptr task) -> IVSRStatus {
Expand All @@ -70,7 +69,8 @@ class engine {
}),
get_infer_requests_size_func([=]() -> size_t {
return _derived->get_infer_requests_size_impl();
}) {}
}),
_derived(derived) {}

// Default constructor
engine() = default;
Expand Down
6 changes: 3 additions & 3 deletions ivsr_sdk/src/include/ivsr_smart_patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ struct PatchConfig{
int nif;
int dims;
PatchConfig(int w = 1920, int h = 1080, int pw = 1920, int ph = 1080, int b_w = 1,int b_h = 1,int s = 2,int n = 3,int d = 5)\
:patchWidth(pw),patchHeight(ph),
block_h(b_h),block_w(b_w),scale(s),
nif(n),dims(d){}
:patchWidth(pw), patchHeight(ph),
block_w(b_w), block_h(b_h), scale(s),
nif(n), dims(d){}

friend std::ostream& operator<<(std::ostream& os, const PatchConfig& cfg) {
return os << "PatchConfig [width]:" << cfg.patchWidth << " [height]:" << cfg.patchHeight
Expand Down
14 changes: 8 additions & 6 deletions ivsr_sdk/src/include/ov_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class inferReqWrap final {
public:
using Ptr = std::shared_ptr<inferReqWrap>;
explicit inferReqWrap(ov::CompiledModel& model, size_t id, CallbackFunction callback)
: id_(id),
request_(model.create_infer_request()),
: request_(model.create_infer_request()),
id_(id),
callback_(callback) {}

void start_async() {
Expand Down Expand Up @@ -107,12 +107,12 @@ class ov_engine : public engine<ov_engine> {
const tensor_desc_t output_tensor_desc)
: engine(this),
device_(device),
model_path_(model_path),
custom_lib_(custom_lib),
configs_(configs),
reshape_settings_(reshape_settings),
input_tensor_desc_(input_tensor_desc),
output_tensor_desc_(output_tensor_desc) {
output_tensor_desc_(output_tensor_desc),
custom_lib_(custom_lib),
model_path_(model_path) {
// init();
}

Expand All @@ -127,11 +127,13 @@ class ov_engine : public engine<ov_engine> {
static_assert(std::is_same<T, ov::Shape>::value || std::is_same<T, size_t>::value ||
std::is_same<T, tensor_desc_t>::value,
"get_attr() is only supported for 'ov::Shape' and 'size_t' types");
/*
auto extend_shape = [](ov::Shape& shape, size_t dims) {
if (shape.size() < dims)
for (size_t i = shape.size(); i < dims; i++)
shape.insert(shape.begin(), 1);
};
*/

if constexpr (std::is_same<T, tensor_desc_t>::value) {
ov::Shape shape;
Expand All @@ -152,7 +154,7 @@ class ov_engine : public engine<ov_engine> {
memcpy((char*)value.precision, element_type.c_str(), element_type.size());
memcpy((char*)value.layout, layout.c_str(), layout.size());
value.dimension = shape.size();
for (int i = 0; i < shape.size(); ++i) {
for (auto i = 0u; i < shape.size(); ++i) {
value.shape[i] = shape[i];
}
} else if constexpr (std::is_same<T, size_t>::value) {
Expand Down
12 changes: 6 additions & 6 deletions ivsr_sdk/src/ivsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void parse_engine_config(std::map<std::string, ov::AnyMap>& config,
// remove the hardware devices if MULTI appears in the devices list.
auto hardware_devices = devices;
if (if_multi) {
ivsr_version_t version;
//ivsr_version_t version;
ov::Version ov_version = ov::get_openvino_version();
std::string ov_buildNumber = std::string(ov_version.buildNumber);
// Parse out the currect virtual device as the target device.
Expand Down Expand Up @@ -211,8 +211,8 @@ struct ivsr {
threadExecutor(executor),
vsr_config(config),
patchConfig(patch),
input_data_shape(std::move(shape)),
patchSolution(sol) {}
patchSolution(sol),
input_data_shape(std::move(shape)) {}
};

IVSRStatus ivsr_init(ivsr_config_t *configs, ivsr_handle *handle) {
Expand Down Expand Up @@ -464,7 +464,7 @@ IVSRStatus ivsr_process(ivsr_handle handle, char* input_data, char* output_data,
}

// Get data into infer task
for (int idx = 0; idx < patchList.size(); ++idx) {
for (auto idx = 0u; idx < patchList.size(); ++idx) {
#ifdef ENABLE_LOG
std::cout << "[Trace]: ivsr_process on patch: " << idx << std::endl;
#endif
Expand Down Expand Up @@ -582,7 +582,7 @@ IVSRStatus ivsr_reconfig(ivsr_handle handle, ivsr_config_t* configs){

// reconfig ov_engine ?

}catch(exception e){
} catch (const std::exception& e) {
// std::cout << "Error in ivsr_reconfig" << std::endl;
ivsr_status_log(IVSRStatus::EXCEPTION_ERROR, e.what());
return IVSRStatus::UNKNOWN_ERROR;
Expand Down Expand Up @@ -653,7 +653,7 @@ IVSRStatus ivsr_deinit(ivsr_handle handle) {
delete handle->threadExecutor;
handle->threadExecutor = nullptr;
}
} catch (exception e) {
} catch (const std::exception& e) {
ivsr_status_log(IVSRStatus::EXCEPTION_ERROR, e.what());
return IVSRStatus::UNKNOWN_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions ivsr_sdk/src/ivsr_thread_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ struct IVSRThreadExecutor::Impl {

explicit Impl(const Config& config, engine<ov_engine>* engine)
: _config{config},
_engine(engine),
_streams([this] {
return std::make_shared<Impl::Stream>(this);
}) {
}),
_engine(engine) {
for (auto streamId = 0; streamId < _config._threads; ++streamId) {
_threads.emplace_back([this, streamId] {
for (bool stopped = false; !stopped;) {
Expand Down
6 changes: 3 additions & 3 deletions ivsr_sdk/src/ov_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ IVSRStatus ov_engine::init_impl() {
hidden_tensor_shape[h_index] = input_shape[h_index].get_length() / 4;
hidden_tensor_shape[w_index] = input_shape[w_index].get_length() / 4;

for (int i = 1; i < model->inputs().size(); ++i)
for (auto i = 1u; i < model->inputs().size(); ++i)
model->reshape({{model->inputs()[i].get_any_name(), hidden_tensor_shape}});
}
}
Expand All @@ -150,7 +150,7 @@ IVSRStatus ov_engine::init_impl() {
std::map<std::string, std::string> tensor_names;
const auto& inputs = model->inputs();
const auto& outputs = model->outputs();
for (int i = 1; i < inputs.size(); ++i) {
for (auto i = 1u; i < inputs.size(); ++i) {
std::string hidden_inp_name = inputs[i].get_any_name();
std::string hidden_out_name = outputs[i].get_any_name();
tensor_names[hidden_inp_name] = hidden_out_name;
Expand Down Expand Up @@ -362,7 +362,7 @@ IVSRStatus ov_engine::create_infer_requests_impl(size_t requests_num) {
return GENERAL_ERROR;
}

for (int id = requests_.size(); id < requests_num; ++id) {
for (auto id = requests_.size(); id < requests_num; ++id) {
requests_.push_back(
std::make_shared<inferReqWrap>(compiled_model_,
id,
Expand Down
12 changes: 6 additions & 6 deletions ivsr_sdk/src/smart_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ float* fill_patch(std::vector<int> patchCorners, float* inputBuf, std::vector<in

// 1x3x3x1080x1920
int B = inputDims[0], N = inputDims[1], C = inputDims[2], H = inputDims[3], W = inputDims[4];
int inp_sW = 1;
//int inp_sW = 1;
int inp_sH = W;
int inp_sC = H * W;
int inp_sN = C * H * W;
Expand Down Expand Up @@ -89,13 +89,13 @@ void fill_image(std::vector<std::vector<int>> patchCorners, char* imgBuf, \
std::vector<int> patchDims, std::vector<int> imgDims, std::vector<char*> patchList){
int pB = patchDims[0], pN = patchDims[1], pC = patchDims[2], pH = patchDims[3], pW = patchDims[4];
int iB = imgDims[0], iN = imgDims[1], iC = imgDims[2], iH = imgDims[3], iW = imgDims[4]; // imgDims?
int patch_sW = 1;
//int patch_sW = 1;
int patch_sH = pW;
int patch_sC = pH * pW;
int patch_sN = pC * pH * pW;
int patch_sB = pN * pC * pH * pW;

int img_sW = 1;
//int img_sW = 1;
int img_sH = iW;
int img_sC = iH * iW;
int img_sN = iC * iH * iW;
Expand All @@ -107,7 +107,7 @@ void fill_image(std::vector<std::vector<int>> patchCorners, char* imgBuf, \
float * img_ptr =(float *)imgBuf;

// for each patch
for (int idx = 0; idx < patchCorners.size(); ++idx){
for (auto idx = 0u; idx < patchCorners.size(); ++idx){
float* patchPtr = (float*)patchList[idx];
auto patchCorner = patchCorners[idx];

Expand Down Expand Up @@ -140,7 +140,7 @@ void fill_image(std::vector<std::vector<int>> patchCorners, char* imgBuf, \
}

// average each pixel
for(int id = 0; id < outputpixels; id++){
for(size_t id = 0; id < outputpixels; id++){
*(img_ptr + id) /= *(pixelCounter + id);
}

Expand All @@ -150,8 +150,8 @@ void fill_image(std::vector<std::vector<int>> patchCorners, char* imgBuf, \
SmartPatch::SmartPatch(PatchConfig config, char* inBuf, char* outBuf, std::vector<int> inputShape, bool flag)
:_inputPtr(inBuf),
_outputPtr(outBuf),
_config(config),
_inputShape(inputShape),
_config(config),
flag(flag)
{
if (flag){
Expand Down

0 comments on commit 7c968c1

Please sign in to comment.