-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexey Suhov
committed
Jun 2, 2020
1 parent
acad2e0
commit 85de6ee
Showing
377 changed files
with
11,222 additions
and
1,270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (C) 2018-2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
if(NOT ENABLE_DOCKER) | ||
add_subdirectory(examples) | ||
# Detect nGraph | ||
find_package(ngraph QUIET) | ||
if(NOT ngraph_FOUND) | ||
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph) | ||
endif() | ||
# Detect InferenceEngine | ||
find_package(InferenceEngine QUIET) | ||
if(NOT InferenceEngine_FOUND) | ||
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR}) | ||
endif() | ||
add_subdirectory(template_extension) | ||
endif() | ||
|
||
# OpenVINO docs | ||
|
||
set(OPENVINO_DOCS_PATH "" CACHE PATH "Path to openvino-documentation local repository") | ||
set(args "") | ||
|
||
if(OPENVINO_DOCS_PATH) | ||
set(args "${args} ovinodoc_path:${OPENVINO_DOCS_PATH}") | ||
endif() | ||
|
||
file(GLOB_RECURSE docs_files "${OpenVINO_MAIN_SOURCE_DIR}/docs") | ||
file(GLOB_RECURSE include_files "${OpenVINO_MAIN_SOURCE_DIR}/inference-engine/include") | ||
file(GLOB_RECURSE ovino_files "${OPENVINO_DOCS_PATH}") | ||
|
||
add_custom_target(ie_docs | ||
COMMAND ./build_docs.sh ${args} | ||
WORKING_DIRECTORY "${OpenVINO_MAIN_SOURCE_DIR}/docs/build_documentation" | ||
COMMENT "Generating OpenVINO documentation" | ||
SOURCES ${docs_files} ${include_files} ${ovino_files} | ||
VERBATIM) | ||
|
||
find_program(browser NAMES xdg-open) | ||
if(browser) | ||
add_custom_target(ie_docs_open | ||
COMMAND ${browser} "${OpenVINO_MAIN_SOURCE_DIR}/doc/html/index.html" | ||
DEPENDS ie_docs | ||
COMMENT "Open OpenVINO documentation" | ||
VERBATIM) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2018-2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set(TARGET_NAME ie_docs_examples) | ||
|
||
file(GLOB SOURCES *.cpp) | ||
|
||
add_library(ie_docs_examples STATIC ${SOURCES}) | ||
|
||
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_plugin_api) | ||
|
||
#add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) | ||
#add_clang_format_target(clang_format_${TARGET_NAME} FOR_TARGETS ${TARGET_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <threading/ie_itask_executor.hpp> | ||
#include <cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp> | ||
#include <memory> | ||
|
||
using namespace InferenceEngine; | ||
|
||
class AcceleratorSyncRequest : public InferRequestInternal { | ||
public: | ||
using Ptr = std::shared_ptr<AcceleratorSyncRequest>; | ||
|
||
void Preprocess(); | ||
void WriteToDevice(); | ||
void RunOnDevice(); | ||
void ReadFromDevice(); | ||
void PostProcess(); | ||
}; | ||
|
||
// ! [async_infer_request:define_pipeline] | ||
// Inherits from AsyncInferRequestThreadSafeDefault | ||
class AcceleratorAsyncInferRequest : public AsyncInferRequestThreadSafeDefault { | ||
// Store the pointer to the synchronous request and five executors | ||
AcceleratorAsyncInferRequest(const AcceleratorSyncRequest::Ptr& syncRequest, | ||
const ITaskExecutor::Ptr& preprocessExecutor, | ||
const ITaskExecutor::Ptr& writeToDeviceExecutor, | ||
const ITaskExecutor::Ptr& runOnDeviceExecutor, | ||
const ITaskExecutor::Ptr& readFromDeviceExecutor, | ||
const ITaskExecutor::Ptr& postProcessExecutor) : | ||
AsyncInferRequestThreadSafeDefault(syncRequest, nullptr, nullptr), | ||
_accSyncRequest{syncRequest}, | ||
_preprocessExecutor{preprocessExecutor}, | ||
_writeToDeviceExecutor{writeToDeviceExecutor}, | ||
_runOnDeviceExecutor{runOnDeviceExecutor}, | ||
_readFromDeviceExecutor{readFromDeviceExecutor}, | ||
_postProcessExecutor{postProcessExecutor} | ||
{ | ||
// Five pipeline stages of synchronous infer request are run by different executors | ||
_pipeline = { | ||
{ _preprocessExecutor , [this] { | ||
_accSyncRequest->Preprocess(); | ||
}}, | ||
{ _writeToDeviceExecutor , [this] { | ||
_accSyncRequest->WriteToDevice(); | ||
}}, | ||
{ _runOnDeviceExecutor , [this] { | ||
_accSyncRequest->RunOnDevice(); | ||
}}, | ||
{ _readFromDeviceExecutor , [this] { | ||
_accSyncRequest->ReadFromDevice(); | ||
}}, | ||
{ _postProcessExecutor , [this] { | ||
_accSyncRequest->PostProcess(); | ||
}}, | ||
}; | ||
} | ||
|
||
// As all stages use _accSyncRequest member we should wait for all stages tasks before the destructor destroy this member. | ||
~AcceleratorAsyncInferRequest() { | ||
StopAndWait(); | ||
} | ||
|
||
AcceleratorSyncRequest::Ptr _accSyncRequest; | ||
ITaskExecutor::Ptr _preprocessExecutor, _writeToDeviceExecutor, _runOnDeviceExecutor, _readFromDeviceExecutor, _postProcessExecutor; | ||
}; | ||
// ! [async_infer_request:define_pipeline] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2018-2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <threading/ie_cpu_streams_executor.hpp> | ||
|
||
#include <memory> | ||
#include <future> | ||
#include <iostream> | ||
|
||
void example1() { | ||
// ! [itask_executor:define_pipeline] | ||
// std::promise is move only object so to satisfy copy callable constraint we use std::shared_ptr | ||
auto promise = std::make_shared<std::promise<void>>(); | ||
// When the promise is created we can get std::future to wait the result | ||
auto future = promise->get_future(); | ||
// Rather simple task | ||
InferenceEngine::Task task = [] {std::cout << "Some Output" << std::endl; }; | ||
// Create an executor | ||
InferenceEngine::ITaskExecutor::Ptr taskExecutor = std::make_shared<InferenceEngine::CPUStreamsExecutor>(); | ||
if (taskExecutor == nullptr) { | ||
// ProcessError(e); | ||
return; | ||
} | ||
// We capture the task and the promise. When the task is executed in the task executor context | ||
// we munually call std::promise::set_value() method | ||
taskExecutor->run([task, promise] { | ||
std::exception_ptr currentException; | ||
try { | ||
task(); | ||
} catch(...) { | ||
// If there is some exceptions store the pointer to current exception | ||
currentException = std::current_exception(); | ||
} | ||
|
||
if (nullptr == currentException) { | ||
promise->set_value(); // <-- If there is no problems just call std::promise::set_value() | ||
} else { | ||
promise->set_exception(currentException); // <-- If there is an exception forward it to std::future object | ||
} | ||
}); | ||
// To wait the task completion we call std::future::wait method | ||
future.wait(); // The current thread will be blocked here and wait when std::promise::set_value() | ||
// or std::promise::set_exception() method will be called. | ||
|
||
// If the future store the exception it will be rethrown in std::future::get method | ||
try { | ||
future.get(); | ||
} catch(std::exception& /*e*/) { | ||
// ProcessError(e); | ||
} | ||
// ! [itask_executor:define_pipeline] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# [cmake:extension] | ||
set(TARGET_NAME "template_extension") | ||
|
||
find_package(ngraph REQUIRED) | ||
find_package(InferenceEngine REQUIRED) | ||
|
||
file(GLOB_RECURSE SRC *.cpp) | ||
|
||
add_library(${TARGET_NAME} SHARED ${SRC}) | ||
|
||
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_API) | ||
target_link_libraries(${TARGET_NAME} PRIVATE ${InferenceEngine_LIBRARIES} | ||
${NGRAPH_LIBRARIES}) | ||
# [cmake:extension] |
Oops, something went wrong.