Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed samples compilation against make install #5919

Merged
merged 4 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,28 +366,25 @@ std::map<std::string, InferenceEngine::CDataPtr> InferenceEnginePython::IEExecNe
return pyOutputs;
}

std::shared_ptr<InferenceEngine::ExecutableNetwork> InferenceEnginePython::IEExecNetwork::getPluginLink(){
std::shared_ptr<InferenceEngine::ExecutableNetwork> InferenceEnginePython::IEExecNetwork::getPluginLink() {
return actual;
}

void InferenceEnginePython::InferRequestWrap::setBlob(const std::string& blob_name,
const InferenceEngine::Blob::Ptr& blob_ptr) {
void InferenceEnginePython::InferRequestWrap::setBlob(const std::string& blob_name, const InferenceEngine::Blob::Ptr& blob_ptr) {
request_ptr.SetBlob(blob_name.c_str(), blob_ptr);
}

void InferenceEnginePython::InferRequestWrap::setBlob(const std::string& blob_name,
const InferenceEngine::Blob::Ptr& blob_ptr,
void InferenceEnginePython::InferRequestWrap::setBlob(const std::string& blob_name, const InferenceEngine::Blob::Ptr& blob_ptr,
const InferenceEngine::PreProcessInfo& info) {
request_ptr.SetBlob(blob_name.c_str(), blob_ptr, info);
}

const InferenceEngine::PreProcessInfo&
InferenceEnginePython::InferRequestWrap::getPreProcess(const std::string& blob_name) {
const InferenceEngine::PreProcessInfo& InferenceEnginePython::InferRequestWrap::getPreProcess(const std::string& blob_name) {
return request_ptr.GetPreProcess(blob_name.c_str());
}

InferenceEngine::Blob::Ptr InferenceEnginePython::InferRequestWrap::getBlobPtr(const std::string& blob_name) {
return request_ptr.GetBlob(blob_name.c_str());
return request_ptr.GetBlob(blob_name.c_str());
}

void InferenceEnginePython::InferRequestWrap::setBatch(int size) {
Expand All @@ -405,7 +402,6 @@ std::vector<InferenceEnginePython::CVariableState> InferenceEnginePython::InferR
return memoryStates;
}


void InferenceEnginePython::InferRequestWrap::setCyCallback(cy_callback callback, void* data) {
user_callback = callback;
user_data = data;
Expand Down Expand Up @@ -462,7 +458,6 @@ std::map<std::string, InferenceEnginePython::ProfileInfo> InferenceEnginePython:
return perf_map;
}


std::string InferenceEnginePython::get_version() {
auto version = InferenceEngine::GetInferenceEngineVersion();
return version->buildNumber;
Expand Down Expand Up @@ -527,23 +522,22 @@ void InferenceEnginePython::IEExecNetwork::createInferRequests(int num_requests)
infer_request.request_queue_ptr = request_queue_ptr;
infer_request.request_ptr = actual->CreateInferRequest();

infer_request.request_ptr.SetCompletionCallback<std::function<void(InferenceEngine::InferRequest r,
InferenceEngine::StatusCode)>>(
[&](InferenceEngine::InferRequest request, InferenceEngine::StatusCode code) {
if (code != InferenceEngine::StatusCode::OK) {
IE_EXCEPTION_SWITCH(code, ExceptionType,
InferenceEngine::details::ThrowNow<ExceptionType> {} <<=
std::stringstream {} << IE_LOCATION << InferenceEngine::details::ExceptionTraits<ExceptionType>::string());
}

auto end_time = Time::now();
auto execTime = std::chrono::duration_cast<ns>(end_time - infer_request.start_time);
infer_request.exec_time = static_cast<double>(execTime.count()) * 0.000001;
infer_request.request_queue_ptr->setRequestIdle(infer_request.index);
if (infer_request.user_callback) {
infer_request.user_callback(infer_request.user_data, code);
}
});
infer_request.request_ptr.SetCompletionCallback<std::function<void(InferenceEngine::InferRequest r, InferenceEngine::StatusCode)>>(
[&](InferenceEngine::InferRequest request, InferenceEngine::StatusCode code) {
if (code != InferenceEngine::StatusCode::OK) {
IE_EXCEPTION_SWITCH(code, ExceptionType,
InferenceEngine::details::ThrowNow<ExceptionType> {} <<=
std::stringstream {} << IE_LOCATION << InferenceEngine::details::ExceptionTraits<ExceptionType>::string());
}

auto end_time = Time::now();
auto execTime = std::chrono::duration_cast<ns>(end_time - infer_request.start_time);
infer_request.exec_time = static_cast<double>(execTime.count()) * 0.000001;
infer_request.request_queue_ptr->setRequestIdle(infer_request.index);
if (infer_request.user_callback) {
infer_request.user_callback(infer_request.user_data, code);
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ struct InferRequestWrap {

void setBlob(const std::string& blob_name, const InferenceEngine::Blob::Ptr& blob_ptr);

void setBlob(const std::string& name,
const InferenceEngine::Blob::Ptr& data,
const InferenceEngine::PreProcessInfo& info);
void setBlob(const std::string& name, const InferenceEngine::Blob::Ptr& data, const InferenceEngine::PreProcessInfo& info);

void setBatch(int size);

Expand All @@ -134,7 +132,6 @@ struct InferRequestWrap {
std::vector<InferenceEnginePython::CVariableState> queryState();
};


struct IEExecNetwork {
std::shared_ptr<InferenceEngine::ExecutableNetwork> actual;
std::vector<InferRequestWrap> infer_requests;
Expand All @@ -160,7 +157,7 @@ struct IEExecNetwork {

void createInferRequests(int num_requests);

//binds plugin to InputInfo and Data, so that they can be destroyed before plugin (ussue 28996)
// binds plugin to InputInfo and Data, so that they can be destroyed before plugin (ussue 28996)
std::shared_ptr<InferenceEngine::ExecutableNetwork> getPluginLink();
};

Expand Down
12 changes: 5 additions & 7 deletions inference-engine/samples/common/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ add_library(${TARGET_NAME} STATIC ${SOURCES})
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "src")

target_include_directories(${TARGET_NAME}
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include")
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")

target_link_libraries(${TARGET_NAME}
PUBLIC
IE::inference_engine
gflags)
find_package(InferenceEngine REQUIRED COMPONENTS inference_engine)

target_link_libraries(${TARGET_NAME} PUBLIC ${InferenceEngine_LIBRARIES} gflags)

if(COMMAND add_clang_format_target)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
endif()
endif()
23 changes: 7 additions & 16 deletions inference-engine/samples/common/utils/include/samples/slog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#pragma once

#include <ostream>
#include <string>

namespace slog {
Expand Down Expand Up @@ -42,9 +43,7 @@ class LogStream {
* @brief A constructor. Creates an LogStream object
* @param prefix The prefix to print
*/
LogStream(const std::string& prefix, std::ostream& log_stream): _prefix(prefix), _new_line(true) {
_log_stream = &log_stream;
}
LogStream(const std::string& prefix, std::ostream& log_stream);

/**
* @brief A stream output operator to be used within the logger
Expand All @@ -62,22 +61,14 @@ class LogStream {
}

// Specializing for LogStreamEndLine to support slog::endl
LogStream& operator<<(const LogStreamEndLine& /*arg*/) {
_new_line = true;

(*_log_stream) << std::endl;
return *this;
}
LogStream& operator<<(const LogStreamEndLine&);

// Specializing for LogStreamBoolAlpha to support slog::boolalpha
LogStream& operator<<(const LogStreamBoolAlpha& /*arg*/) {
(*_log_stream) << std::boolalpha;
return *this;
}
LogStream& operator<<(const LogStreamBoolAlpha&);
};

static LogStream info("INFO", std::cout);
static LogStream warn("WARNING", std::cout);
static LogStream err("ERROR", std::cerr);
extern LogStream info;
extern LogStream warn;
extern LogStream err;

} // namespace slog
33 changes: 33 additions & 0 deletions inference-engine/samples/common/utils/src/slog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "samples/slog.hpp"

#include <iostream>

namespace slog {

LogStream info("INFO", std::cout);
LogStream warn("WARNING", std::cout);
LogStream err("ERROR", std::cerr);

LogStream::LogStream(const std::string& prefix, std::ostream& log_stream): _prefix(prefix), _new_line(true) {
_log_stream = &log_stream;
}

// Specializing for LogStreamEndLine to support slog::endl
LogStream& LogStream::operator<<(const LogStreamEndLine& /*arg*/) {
_new_line = true;

(*_log_stream) << std::endl;
return *this;
}

// Specializing for LogStreamBoolAlpha to support slog::boolalpha
LogStream& LogStream::operator<<(const LogStreamBoolAlpha& /*arg*/) {
(*_log_stream) << std::boolalpha;
return *this;
}

} // namespace slog