publish master branch snapshot, revision cdcab9d7ab48ffb0ee5629fabbfa06cb45debd9b

This commit is contained in:
Alexey Suhov 2020-04-15 19:01:57 +03:00
parent 95a57795dc
commit 127cbac5bc
971 changed files with 30678 additions and 5669 deletions

364
.gitignore vendored
View File

@ -1,342 +1,24 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
bld/
[Bb]in/
[Oo]bj/
# PY.TEST
*.pyc
tests/integration/report.html
tests/integration/report.xml
tests/integration/assets/
tests/integration/__pycache__/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Target VS files:
vsx64
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# LightSwitch generated files
GeneratedArtifacts/
ModelManifest.xml
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
*.filters
/External
/Output
/InferenceEngineMain/models
/Test
/HTTPClient/*.a
/InferenceEngineMain/newModels
.DS_Store
# For IDEA
.idea/
VS/
Xcode/
temp/
report/
.kdev4/
*.kdev4
*.kate-swp
/lin-build
/win-build
/CMakeFiles
*.stamp
*.depend
*.vcxproj
*.sln
/CMakeCache.txt
.vimprj/
build_IA32/
.dir-locals.el
GTAGS
GPATH
GRTAGS
GSYMS
compile_commands.json
service/dot-net-service/Output
**/sublime_build
/.project
.vscode/
/vsx32
/service/dot-net-service/.klocwork/DotNetService
cmake-build-*/
/lin64
.gdb_history
.local_vimrc
.ycm_extra_conf.py
tags
# from Model Optimizer repo
# build/artifact dirs
_*
# but ensure we don't skip __init__.py
!__init__.py
# developer tools
.idea
.project
.cproject
.pydevproject
.settings
/bin/
/gen/
__pycache__
*.swp
/config.xml
# Python-specific
.env3
*.pyc
# Tests-specific
.coverage
htmlcov
pylint_report.txt
pylint_report_comments.txt
# Documentation-generated
docs/build
docs/source/_static
docs/source/_templates
docs/source/generated/
# Artifacts
/*.bin
/*.xml
/*.json
/*.so
/*.txt
/*.mapping
/*.dat
/*.svg
.vscode
cmake-build-debug
cmake-build-release
.DS_Store
**/tags
compile_commands.json
bin/
build/
.local_vimrc
.gdb_history
.vimspector.json
doc/
docs/build_documentation/work_dir/
inference-engine/plugins/
.repo/
docs/template_plugin/html/
CMakeLists.txt.user
docs/IE_PLUGIN_DG/html/

2
.gitmodules vendored
View File

@ -5,4 +5,4 @@
[submodule "ngraph"]
path = ngraph
url = https://github.com/NervanaSystems/ngraph.git
ignore = dirty
ignore = dirty

View File

@ -77,13 +77,13 @@ function(build_ngraph)
if (NOT ANDROID)
ngraph_set(NGRAPH_UNIT_TEST_ENABLE TRUE)
ngraph_set(NGRAPH_UNIT_TEST_OPENVINO_ENABLE TRUE)
ngraph_set(NGRAPH_IE_ENABLE TRUE)
# ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE TRUE)
set(NGRAPH_ONNX_IMPORT_ENABLE TRUE CACHE BOOL "" FORCE)
else()
ngraph_set(NGRAPH_UNIT_TEST_ENABLE FALSE)
ngraph_set(NGRAPH_TEST_UTIL_ENABLE FALSE)
ngraph_set(NGRAPH_UNIT_TEST_OPENVINO_ENABLE FALSE)
ngraph_set(NGRAPH_IE_ENABLE FALSE)
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE FALSE)
endif()

3
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,3 @@
#!groovy
dldtPipelineEntrypoint(this)

View File

@ -37,8 +37,12 @@ function(ie_cpack_set_library_dir)
if(WIN32)
set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${CMAKE_BUILD_TYPE}/${ARCH} PARENT_SCOPE)
set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${CMAKE_BUILD_TYPE}/${ARCH} PARENT_SCOPE)
set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${CMAKE_BUILD_TYPE}/${ARCH} PARENT_SCOPE)
else()
set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
endif()
endfunction()
@ -59,8 +63,10 @@ macro(ie_cpack)
set(CPACK_GENERATOR "TGZ")
if(WIN32)
set(CPACK_PACKAGE_NAME inference-engine_${CMAKE_BUILD_TYPE})
string(REPLACE "\\" "_" CPACK_PACKAGE_VERSION "${CI_BUILD_NUMBER}")
else()
set(CPACK_PACKAGE_NAME inference-engine)
string(REPLACE "/" "_" CPACK_PACKAGE_VERSION "${CI_BUILD_NUMBER}")
endif()
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

View File

@ -118,7 +118,6 @@ function(addIeTarget)
if (ARG_ADD_CPPLINT)
# code style
add_cpplint_target(${ARG_NAME}_cpplint FOR_TARGETS ${ARG_NAME})
add_clang_format_target(${ARG_NAME}_clang_format FOR_TARGETS ${ARG_NAME})
endif()
if (ARG_DEVELOPER_PACKAGE)
# developer package

View File

@ -35,10 +35,6 @@ function(add_clang_format_target TARGET_NAME)
set(multiValueArgs "FOR_TARGETS" "FOR_SOURCES" "EXCLUDE_PATTERNS")
cmake_parse_arguments(CLANG_FORMAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CLANG_FORMAT_ALL)
set(all ALL)
endif()
foreach(target IN LISTS CLANG_FORMAT_FOR_TARGETS)
get_target_property(target_sources "${target}" SOURCES)
list(APPEND CLANG_FORMAT_FOR_SOURCES ${target_sources})
@ -95,7 +91,6 @@ function(add_clang_format_target TARGET_NAME)
"All clang-format output files")
add_custom_target(${TARGET_NAME}
${all}
DEPENDS ${all_output_files}
COMMENT "[clang-format] ${TARGET_NAME}")

View File

@ -4,6 +4,8 @@
cmake_policy(SET CMP0054 NEW)
include(models)
#we have number of dependencies stored on ftp
include(dependency_solver)
@ -13,6 +15,23 @@ endif()
include(ExternalProject)
if (ENABLE_SAME_BRANCH_FOR_MODELS)
branchName(MODELS_BRANCH)
else()
set(MODELS_BRANCH "master")
endif()
if (ENABLE_DATA)
add_models_repo(${ENABLE_DATA} "data:inference-engine/open-source-data.git")
set(MODELS_PATH "${TEMP}/data/src/data")
set(DATA_PATH "${MODELS_PATH}")
endif()
message(STATUS "MODELS_PATH=" ${MODELS_PATH})
fetch_models_and_validation_set()
include(linux_name)
if(COMMAND get_linux_name)
get_linux_name(LINUX_OS_NAME)

View File

@ -11,7 +11,11 @@ file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH")
load_cache("${cache_path}" READ_WITH_PREFIX "" ${ie_options})
foreach(option IN LISTS ie_options)
if(NOT DEFINED "${option}")
load_cache("${cache_path}" READ_WITH_PREFIX "" ${option})
endif()
endforeach()
message(STATUS "The following CMake options are exported from Inference Engine Developer package")
message("")

View File

@ -78,7 +78,9 @@ ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performan
ie_dependent_option (ENABLE_MYRIAD_MVNC_TESTS "functional and behavior tests for mvnc api" OFF "ENABLE_TESTS;ENABLE_MYRIAD" OFF)
ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF)
ie_dependent_option (ENABLE_DATA "fetch models from open-source-data repo" ON "ENABLE_FUNCTIONAL_TESTS;NOT ANDROID" OFF)
ie_dependent_option (ENABLE_SAME_BRANCH_FOR_MODELS "uses same branch for models and for inference engine, if not enabled models are taken from master" OFF "ENABLE_TESTS" OFF)
ie_dependent_option (ENABLE_BEH_TESTS "tests oriented to check inference engine API corecteness" ON "ENABLE_TESTS" OFF)

View File

@ -0,0 +1,80 @@
# Copyright (C) 2018-2020 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
if(ENABLE_DOCKER)
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
else()
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
endif()
cmake_policy(SET CMP0054 NEW)
find_package(Git REQUIRED)
set(MODELS_LST "")
set(MODELS_LST_TO_FETCH "")
function (add_models_repo add_to_fetcher model_name)
list(LENGTH ARGV add_models_args)
if (add_models_args EQUAL 3)
list(GET ARGV 2 branch_name)
else()
set(branch_name ${MODELS_BRANCH})
endif()
if (add_to_fetcher)
set(model_name "${model_name}:${branch_name}")
list(APPEND MODELS_LST_TO_FETCH ${model_name})
endif()
list(APPEND MODELS_LST ${model_name})
set(MODELS_LST_TO_FETCH ${MODELS_LST_TO_FETCH} PARENT_SCOPE)
set(MODELS_LST ${MODELS_LST} PARENT_SCOPE)
endfunction()
function(add_lfs_repo name prefix url tag)
ExternalProject_Add(${name}
PREFIX ${prefix}
GIT_REPOSITORY ${url}
GIT_TAG ${tag}
GIT_CONFIG "http.sslverify=false"
GIT_PROGRESS 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON)
execute_process(
COMMAND ${GIT_EXECUTABLE} lfs install --local --force
WORKING_DIRECTORY ${prefix}/src/${name}
OUTPUT_VARIABLE lfs_output
RESULT_VARIABLE lfs_var)
if(lfs_var)
message(FATAL_ERROR [=[
Failed to setup Git LFS: ${lfs_output}
Git lfs must be installed in order to fetch models
Please install it from https://git-lfs.github.com/
]=])
endif()
endfunction()
function (fetch_models_and_validation_set)
foreach(loop_var ${MODELS_LST_TO_FETCH})
string(REPLACE ":" ";" MODEL_CONFIG_LST ${loop_var})
list(GET MODEL_CONFIG_LST 0 folder_name)
list(GET MODEL_CONFIG_LST 1 repo_name)
list(GET MODEL_CONFIG_LST 2 branch_name)
string(FIND ${folder_name} "model" IS_MODEL)
if(${folder_name} MATCHES "model*")
set(FOLDER_NAME "/models/src")
endif()
add_lfs_repo(
"${folder_name}"
${TEMP}${FOLDER_NAME}/${folder_name}
"git@gitlab-icv.inn.intel.com:${repo_name}"
"${branch_name}")
endforeach(loop_var)
endfunction()

View File

@ -90,8 +90,8 @@ function(ie_add_plugin)
ie_cpack_add_component(${install_component} REQUIRED DEPENDS core)
install(TARGETS ${IE_PLUGIN_NAME}
RUNTIME DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT ${install_component}
ARCHIVE DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT ${install_component}
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT ${install_component}
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT ${install_component}
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT ${install_component})
endif()
endfunction()

View File

@ -104,4 +104,4 @@ if(ANDROID)
set(LIBUSB_LIBRARY "${LIBUSB}/libs/${ANDROID_ABI}/libusb1.0.so")
log_rpath_from_dir(LIBUSB "${LIBUSB}/libs/${ANDROID_ABI}")
endif()
endif()

View File

@ -1,5 +1,5 @@
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier : Apache-2.0
//
#include <stdlib.h>

View File

@ -1,5 +1,5 @@
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier : Apache-2.0
//
#include <stdlib.h>

View File

@ -28,8 +28,8 @@ export(TARGETS ${TARGET_NAME} NAMESPACE IE:: APPEND FILE "${CMAKE_BINARY_DIR}/ta
# install
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)
install(DIRECTORY ${InferenceEngine_C_API_SOURCE_DIR}/include/

View File

@ -29,15 +29,18 @@ def build_argparser():
args = parser.add_argument_group("Options")
args.add_argument('-h', '--help', action='help', default=SUPPRESS, help='Show this help message and exit.')
args.add_argument("-m", "--model", help="Required. Path to an .xml file with a trained model.",
required=True, type=str)
required=True, type=str)
args.add_argument("-i", "--input", help="Required. Path to image file.",
required=True, type=str, nargs="+")
required=True, type=str, nargs="+")
args.add_argument("-l", "--cpu_extension",
help="Optional. Required for CPU custom layers. Absolute path to a shared library with the kernels implementations.",
type=str, default=None)
help="Optional. Required for CPU custom layers. "
"Absolute path to a shared library with the kernels implementations.",
type=str, default=None)
args.add_argument("-d", "--device",
help="Optional. Specify the target device to infer on; CPU, GPU, FPGA or MYRIAD is acceptable. Sample will look for a suitable plugin for device specified (CPU by default)",
default="CPU", type=str)
help="Optional. Specify the target device to infer on; "
"CPU, GPU, FPGA or MYRIAD is acceptable. "
"Sample will look for a suitable plugin for device specified (CPU by default)",
default="CPU", type=str)
args.add_argument("--labels", help="Optional. Labels mapping file", default=None, type=str)
args.add_argument("-nt", "--number_top", help="Optional. Number of top results", default=10, type=int)
@ -59,9 +62,10 @@ def main():
# ------------- 2. Load Plugin for inference engine and extensions library if specified --------------
log.info("Device info:")
versions = ie.get_versions(args.device)
print("{}{}".format(" "*8, args.device))
print("{}MKLDNNPlugin version ......... {}.{}".format(" "*8, versions[args.device].major, versions[args.device].minor))
print("{}Build ........... {}".format(" "*8, versions[args.device].build_number))
print("{}{}".format(" " * 8, args.device))
print("{}MKLDNNPlugin version ......... {}.{}".format(" " * 8, versions[args.device].major,
versions[args.device].minor))
print("{}Build ........... {}".format(" " * 8, versions[args.device].build_number))
if args.cpu_extension and "CPU" in args.device:
ie.add_extension(args.cpu_extension, "CPU")
@ -79,8 +83,15 @@ def main():
# -----------------------------------------------------------------------------------------------------
# --------------------------- 3. Read and preprocess input --------------------------------------------
input_blob = next(iter(net.inputs))
n, c, h, w = net.inputs[input_blob].shape
print("inputs number: " + str(len(net.inputs.keys())))
for input_key in net.inputs:
print("input shape: " + str(net.inputs[input_key].shape))
print("input key: " + input_key)
if len(net.inputs[input_key].layout) == 4:
n, c, h, w = net.inputs[input_key].shape
images = np.ndarray(shape=(n, c, h, w))
images_hw = []
for i in range(n):
@ -94,13 +105,14 @@ def main():
log.warning("Image {} is resized from {} to {}".format(args.input[i], image.shape[:-1], (h, w)))
image = image.transpose((2, 0, 1)) # Change data layout from HWC to CHW
images[i] = image
# -----------------------------------------------------------------------------------------------------
# --------------------------- 4. Configure input & output ---------------------------------------------
# --------------------------- Prepare input blobs -----------------------------------------------------
log.info("Preparing input blobs")
assert (len(net.inputs.keys()) == 1 or len(net.inputs.keys()) == 2), "Sample supports topologies only with 1 or 2 inputs"
input_blob = next(iter(net.inputs))
assert (len(net.inputs.keys()) == 1 or len(
net.inputs.keys()) == 2), "Sample supports topologies only with 1 or 2 inputs"
out_blob = next(iter(net.outputs))
input_name, input_info_name = "", ""
@ -112,9 +124,21 @@ def main():
elif len(net.inputs[input_key].layout) == 2:
input_info_name = input_key
net.inputs[input_key].precision = 'FP32'
if net.inputs[input_key].shape[1] != 3 and net.inputs[input_key].shape[1] != 6 or net.inputs[input_key].shape[0] != 1:
if net.inputs[input_key].shape[1] != 3 and net.inputs[input_key].shape[1] != 6 or \
net.inputs[input_key].shape[0] != 1:
log.error('Invalid input info. Should be 3 or 6 values length.')
data = {}
data[input_name] = images
if input_info_name != "":
infos = np.ndarray(shape=(n, c), dtype=float)
for i in range(n):
infos[i, 0] = h
infos[i, 1] = w
infos[i, 2] = 1.0
data[input_info_name] = infos
# --------------------------- Prepare output blobs ----------------------------------------------------
log.info('Preparing output blobs')
@ -141,7 +165,7 @@ def main():
log.info("Loading model to the device")
exec_net = ie.load_network(network=net, device_name=args.device)
log.info("Creating infer request and starting inference")
res = exec_net.infer(inputs={input_blob: images})
res = exec_net.infer(inputs=data)
# -----------------------------------------------------------------------------------------------------
# --------------------------- Read and postprocess output ---------------------------------------------
@ -159,8 +183,8 @@ def main():
ymin = np.int(ih * proposal[4])
xmax = np.int(iw * proposal[5])
ymax = np.int(ih * proposal[6])
print("[{},{}] element, prob = {:.6} ({},{})-({},{}) batch id : {}"\
.format(number, label, confidence, xmin, ymin, xmax, ymax, imid), end="")
print("[{},{}] element, prob = {:.6} ({},{})-({},{}) batch id : {}" \
.format(number, label, confidence, xmin, ymin, xmax, ymax, imid), end="")
if proposal[2] > 0.5:
print(" WILL BE PRINTED!")
if not imid in boxes.keys():
@ -181,7 +205,8 @@ def main():
# -----------------------------------------------------------------------------------------------------
log.info("Execution successful\n")
log.info("This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool")
log.info(
"This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool")
if __name__ == '__main__':

View File

@ -39,6 +39,16 @@ add_custom_command(TARGET ${TARGET_NAME}
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_BRIDGE_SRC_ROOT}/src/openvino/__init__.py ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../__init__.py
)
# creates a folder in openvino directory and a symlink to benchmark
# inside bin directory for developers for running python benchmark_app
if(UNIX)
add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../tools
)
file(COPY ${OpenVINO_MAIN_SOURCE_DIR}/tools/benchmark DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../tools/)
endif()
# install
install(TARGETS ${TARGET_NAME}

View File

@ -171,9 +171,9 @@ cdef class IECore:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# exec_net = ie.load_network(network=net, device_name="CPU", num_requsts=2)
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie.load_network(network=net, device_name="CPU", num_requests=2)
# ```
cpdef ExecutableNetwork load_network(self, IENetwork network, str device_name, config=None, int num_requests=1):
cdef ExecutableNetwork exec_net = ExecutableNetwork()
@ -197,8 +197,8 @@ cdef class IECore:
# @return An `ExecutableNetwork` object
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie.load_network(network=net, device_name="MYRIAD", num_requsts=2)
# # export executable network
# exec_net.export(path_to_file_to_save)
@ -226,8 +226,8 @@ cdef class IECore:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# layers_map = ie.query_network(network=net, device_name="HETERO:GPU,CPU")
# ```
def query_network(self, IENetwork network, str device_name, config=None):
@ -238,12 +238,19 @@ cdef class IECore:
return c_map_to_dict(res)
## Sets a configuration for a plugin
# NOTE: When specifying a key value of a config, the "KEY_" prefix is omitted.
#
# \note When specifying a key value of a config, the "KEY_" prefix is omitted.
#
# @param config: a dictionary of configuration parameters as keys and their values
# @param device_name: a device name of a target plugin
# @return None
#
# Usage examples: See the `set_affinity` method of the `IENetwork` class
# Usage examples:\n
# ```python
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# ie.set_config({"DYN_BATCH_ENABLED": "YES"})
# ```
def set_config(self, config: dict, device_name: str):
cdef map[string, string] c_config = dict_to_c_map(config)
self.impl.setConfig(c_config, device_name.encode())
@ -316,7 +323,9 @@ cdef class IECore:
## Gets a configuration dedicated to device behavior. The method targets to extract information
# which can be set via set_config method.
# NOTE: When specifying a key value of a config, the "KEY_" prefix is omitted.
#
# \note When specifying a key value of a config, the "KEY_" prefix is omitted.
#
# @param device_name: A name of a device to get a config value.
# @param config_name: A config name to request.
# @return A config value corresponding to a config key.
@ -452,8 +461,8 @@ cdef class ExecutableNetwork:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie_core = IECore()
# net = ie_core.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie_core.load_network(net, device, num_requests=2)
# res = exec_net.infer({'data': img})
# res
@ -531,8 +540,8 @@ cdef class ExecutableNetwork:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie_core = IECore()
# net = ie_core.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie_core.load_network(net, device, num_requsts=2)
# exec_graph = exec_net.get_exec_graph_info()
# ```
@ -549,7 +558,7 @@ cdef class ExecutableNetwork:
# Usage example:\n
# ```python
# ie = IECore()
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie.load_network(net, "CPU")
# exec_net.get_metric("NETWORK_NAME")
# ```
@ -564,7 +573,7 @@ cdef class ExecutableNetwork:
# Usage example:\n
# ```python
# ie = IECore()
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie.load_network(net, "CPU")
# exec_net.get_metric("DEVICE_ID")
# ```
@ -576,8 +585,8 @@ cdef class ExecutableNetwork:
# @return None
#
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# exec_net = ie.load_network(network=net, device_name="MYRIAD", num_requsts=2)
# exec_net.export(path_to_file_to_save)
# ```
@ -632,8 +641,8 @@ cdef class InferRequest:
# Usage example:\n
# ```python
# callback = lambda status, py_data: print("Request with id {} finished with status {}".format(py_data, status))
# net = IENetwork("./model.xml", "./model.bin")
# ie = IECore()
# net = ie.read_network(model="./model.xml", weights="./model.bin")
# exec_net = ie.load_network(net, "CPU", num_requests=4)
# for id, req in enumerate(exec_net.requests):
# req.set_completion_callback(py_callback=callback, py_data=id)
@ -662,7 +671,7 @@ cdef class InferRequest:
#
# Usage example:\n
# ```python
# exec_net = plugin.load(network=net, num_requests=2)
# exec_net = ie_core.load_network(network=net, num_requests=2)
# exec_net.requests[0].infer({input_blob: image})
# res = exec_net.requests[0].outputs['prob']
# np.flip(np.sort(np.squeeze(res)),0)
@ -683,7 +692,7 @@ cdef class InferRequest:
#
# Usage example:\n
# ```python
# exec_net = plugin.load(network=net, num_requests=2)
# exec_net = ie_core.load_network(network=net, num_requests=2)
# exec_net.requests[0].async_infer({input_blob: image})
# request_status = exec_net.requests[0].wait()
# res = exec_net.requests[0].outputs['prob']
@ -697,7 +706,8 @@ cdef class InferRequest:
## Waits for the result to become available. Blocks until specified timeout elapses or the result
# becomes available, whichever comes first.
# NOTE: There are special values of the timeout parameter:
#
# \note There are special values of the timeout parameter:
# * 0 - Immediately returns the inference status. It does not block or interrupt execution.
# To find statuses meaning, please refer to InferenceEngine::StatusCode in Inference Engine C++ documentation
# * -1 - Waits until inference result becomes available (default value)
@ -724,12 +734,14 @@ cdef class InferRequest:
return deref(self.impl).wait(<int64_t> timeout)
## Queries performance measures per layer to get feedback of what is the most time consuming layer.
# NOTE: Performance counters data and format depends on the plugin
#
# \note Performance counters data and format depends on the plugin
#
# @return Dictionary containing per-layer execution information.
#
# Usage example:
# ```python
# exec_net = plugin.load(network=net, num_requests=2)
# exec_net = ie_core.load_network(network=net, num_requests=2)
# exec_net.requests[0].infer({input_blob: image})
# exec_net.requests[0].get_perf_counts()
# {'Conv2D': {'exec_type': 'jit_avx2_1x1',
@ -780,18 +792,20 @@ cdef class InferRequest:
## Sets new batch size for certain infer request when dynamic batching is enabled in executable network
# that created this request.
# NOTE: Support of dynamic batch size depends on the target plugin.
#
# \note Support of dynamic batch size depends on the target plugin.
#
# @param size: New batch size to be used by all the following inference calls for this request
# @return None
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# # Set max batch size
# net.batch = 10
# plugin.set_config({"DYN_BATCH_ENABLED": "YES"})
# exec_net = plugin.load(network=net)
# ie.set_config({"DYN_BATCH_ENABLED": "YES"})
# exec_net = ie.load_network(network=net)
# # Set batch size for certain network.
# # NOTE: Input data shape will not be changed, but will be used partially in inference which increases performance
# exec_net.requests[0].set_batch(2)
@ -855,7 +869,11 @@ cdef class IENetLayer:
def type(self):
return deref(self._ptr).type.decode()
## Layer base operating precision. Provides getter and setter interfaces.
## \note This property is deprecated.
# Please, use out_data property to access DataPtr objects for all output ports, which contains full
# information about layer's output data including precision.
#
# Layer base operating precision. Provides getter and setter interfaces.
@property
def precision(self):
warnings.filterwarnings("always", category=DeprecationWarning)
@ -874,8 +892,8 @@ cdef class IENetLayer:
# The affinity attribute provides getter and setter interfaces, so the layer affinity can be modified directly.
# For example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# layers_map = ie.query_network(network=net, device_name="HETERO:GPU,CPU")
# layers = net.layers
# for layer, device in layers_map.items():
@ -922,8 +940,10 @@ cdef class IENetLayer:
input_to_list.append(deref(layer.second).name.decode())
return input_to_list
## Deprecated: use out_data property to access DataPtr objects for all output ports, which contains full
## \note This property is deprecated.
# Please, use out_data property to access DataPtr objects for all output ports, which contains full
# information about layer's output data including layout
#
# Returns the layout of the layer output data on 1st port
@property
def layout(self):
@ -936,8 +956,10 @@ cdef class IENetLayer:
cdef C.DataPtr c_input = deref(self._ptr).outData[0]
return layout_int_to_str_map[deref(c_input).getLayout()]
## Deprecated: use out_data property to access DataPtr objects for all output ports, which contains full
## \note This property is deprecated.
# Please, use out_data property to access DataPtr objects for all output ports, which contains full
# information about layer's output data including shape
#
# Return the list of dimension of the layer output data on 1st port
@property
def shape(self):
@ -988,7 +1010,10 @@ cdef class IENetLayer:
weights_buffer.reset(blob.second)
blobs_map[blob.first.decode()] = weights_buffer.to_numpy()
return blobs_map
## Dictionary with layer weights, biases or custom blobs if any
## \note This property is deprecated.
# Please use blobs property instead.
#
# Dictionary with layer weights, biases or custom blobs if any
@property
def weights(self):
warnings.filterwarnings("always", category=DeprecationWarning)
@ -1003,6 +1028,9 @@ cdef class IENetLayer:
cdef class IENetwork:
## Class constructor
#
# \note Reading networks using IENetwork constructor is deprecated.
# Please, use IECore.read_network() method instead.
#
# @param model: A `.xml` file of the IR or PyCapsule containing smart pointer to nGraph function.
# In case of passing a `.xml` file attribute value can be a string path or bytes with file content
# depending on `init_from_buffer` attribute value
@ -1100,8 +1128,9 @@ cdef class IENetwork:
## Batch size of the network. Provides getter and setter interfaces to get and modify the
# network batch size. For example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# print(et.batch_size)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# print(net.batch_size)
# net.batch_size = 4
# print(net.batch_size)
# print(net.inputs['data'].shape)
@ -1109,7 +1138,9 @@ cdef class IENetwork:
@property
def batch_size(self):
return self.impl.getBatch()
## Deprecated: network precision does not make sence, use precision on egdes.
## \note This property is deprecated:
# network precision does not make sense, use precision on edges.
#
# Precision of the network
@property
def precision(self):
@ -1139,13 +1170,16 @@ cdef class IENetwork:
layers[deref(l).name.decode()] = net_l
return layers
## Deprecated: new Calibration Tool doesn't generate statistics
## \note This property is deprecated.
# New Calibration Tool doesn't generate statistics
#
# Returns `LayersStatsMap` object containing dictionary that maps network layer names to calibration statistics
# represented by `LayerStats` objects.
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# net.stats.update({"conv1_2d" : LayserStats(min=(-25, -1, 0), max=(63, 124, 70)),
# "conv2_2d" : LayserStats(min=(-5, -1, 0, 1, -7, 2), max=(63, 124, 70, 174, 99, 106))
# })
@ -1163,26 +1197,6 @@ cdef class IENetwork:
max=tuple(it.second["max".encode()]))
return py_stats_map
## NOTE: The function is deprecated. Please use the `IENetwork()` class constructor
# to create valid instance of `IENetwork`.
#
# Reads the model from the `.xml` and `.bin` files of the IR.
#
# @param model: Path to `.xml` file of the IR
# @param weights: Path to `.bin` file of the IR
# @return An instance of the `IENetwork` class
@classmethod
def from_ir(cls, model: str, weights: str):
warnings.filterwarnings("always", category=DeprecationWarning)
warnings.warn("from_ir() method of IENetwork is deprecated. "
"Please use IENetwork class constructor to create valid IENetwork instance",
DeprecationWarning)
if not os.path.isfile(model):
raise Exception("Path to the model {} doesn't exists or it's a directory".format(model))
if not os.path.isfile(weights):
raise Exception("Path to the weights {} doesn't exists or it's a directory".format(weights))
cdef IENetwork net = IENetwork(model, weights)
return net
## Marks any intermediate layer as output layer to retrieve the inference results from the specified layers.
# @param outputs: List of layers to be set as model outputs. The list can contain strings with layer names to be set
@ -1192,7 +1206,8 @@ cdef class IENetwork:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# net.add_outputs(["conv5_1', conv2_1', (split_2, 1)])]
# ```
def add_outputs(self, outputs):
@ -1216,14 +1231,16 @@ cdef class IENetwork:
#
# Usage example:
# ```python
# net = IENetwork(model=path_to_model, weights=path_to_weights)
# ie = IECore()
# net = ie.read_network(model=path_to_xml, weights=path_to_bin)
# net.serialize(path_to_xml, path_to_bin)
# ```
def serialize(self, path_to_xml, path_to_bin: str = ""):
self.impl.serialize(path_to_xml.encode(), path_to_bin.encode())
## Reshapes the network to change spatial dimensions, batch size, or any dimension.
# NOTE: Before using this method, make sure that the target shape is applicable for the network.
#
# \note Before using this method, make sure that the target shape is applicable for the network.
# Changing the network shape to an arbitrary value may lead to unpredictable behaviour.
#
# @param input_shapes: A dictionary that maps input layer names to tuples with the target shape
@ -1231,7 +1248,8 @@ cdef class IENetwork:
#
# Usage example:\n
# ```python
# net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# input_layer = next(iter(net.inputs))
# n, c, h, w = net.inputs[input_layer]
# net.reshape({input_layer: (n, c, h*2, w*2)}]
@ -1255,9 +1273,11 @@ cdef class IENetwork:
# return self.impl.getFunction()
## This class is the main plugin interface and serves to initialize and configure the plugin.
#
#\note This class is deprecated: Use IECore instead
#
cdef class IEPlugin:
## Deprecated: Use IECore instead
# Class constructor
## Class constructor
#
# @param device: Target device name. Supported devices: CPU, GPU, FPGA, MYRIAD, HETERO, MULTI
# @param plugin_dirs: List of paths to plugin directories

View File

@ -40,7 +40,7 @@ public:
/**
* @brief A default constructor
*/
CNNNetReader(): actual(shared_from_irelease(InferenceEngine::CreateCNNNetReader())) {
CNNNetReader(): actual(InferenceEngine::CreateCNNNetReaderPtr()) {
if (actual == nullptr) {
THROW_IE_EXCEPTION << "CNNNetReader was not initialized.";
}
@ -182,7 +182,7 @@ public:
}
private:
std::shared_ptr<ICNNNetReader> actual;
CNNNetReaderPtr actual;
std::shared_ptr<CNNNetwork> network;
};
IE_SUPPRESS_DEPRECATED_END

View File

@ -66,8 +66,11 @@ public:
* @param reader Pointer to the ICNNNetReader object
*/
IE_SUPPRESS_DEPRECATED_START
explicit CNNNetwork(std::shared_ptr<ICNNNetReader> reader): reader(reader), actual(reader->getNetwork(nullptr)) {
if (actual == nullptr) {
explicit CNNNetwork(CNNNetReaderPtr reader_): reader(reader_) {
if (reader == nullptr) {
THROW_IE_EXCEPTION << "ICNNNetReader was not initialized.";
}
if ((actual = reader->getNetwork(nullptr)) == nullptr) {
THROW_IE_EXCEPTION << "CNNNetwork was not initialized.";
}
}
@ -160,6 +163,15 @@ public:
return actual->getBatchSize();
}
/**
* @brief An overloaded operator cast to get pointer on current network
*
* @return A shared pointer of the current network
*/
operator std::shared_ptr<ICNNNetwork>() {
return network;
}
/**
* @brief An overloaded operator & to get current network
*
@ -178,6 +190,15 @@ public:
return *actual;
}
/**
* @brief Returns constant nGraph function
*
* @return constant nGraph function
*/
std::shared_ptr<ngraph::Function> getFunction() noexcept {
return actual->getFunction();
}
/**
* @brief Returns constant nGraph function
*
@ -297,7 +318,7 @@ protected:
* @brief Reader extra reference, might be nullptr
*/
IE_SUPPRESS_DEPRECATED_START
std::shared_ptr<ICNNNetReader> reader;
CNNNetReaderPtr reader;
IE_SUPPRESS_DEPRECATED_END
/**
* @brief Network extra interface, might be nullptr

View File

@ -58,6 +58,7 @@ public:
IE_SUPPRESS_DEPRECATED_END
}
private:
/**
* @brief Loads function from the library and returns a pointer to it
* @param functionName Name of function to load
@ -126,6 +127,15 @@ public:
}
}
/**
* @brief Constructs an object with existing loader
* @param so_loader Existing pointer to a library loader
*/
explicit SOPointer(std::shared_ptr<Loader> so_loader)
: _so_loader(so_loader),
_pointedObj(details::shared_from_irelease(
SymbolLoader<Loader>(_so_loader).template instantiateSymbol<T>(SOCreatorTrait<T>::name))) {}
/**
* @brief The copy-like constructor, can create So Pointer that dereferenced into child type if T is derived of U
* @param that copied SOPointer object
@ -183,6 +193,7 @@ protected:
* @brief Gets a smart pointer to the DLL
*/
std::shared_ptr<Loader> _so_loader;
/**
* @brief Gets a smart pointer to the custom object
*/

View File

@ -11,8 +11,10 @@
#include <map>
#include <string>
#include <vector>
#include "details/ie_no_copy.hpp"
#include "details/ie_so_pointer.hpp"
#include "ie_api.h"
#include "ie_blob.h"
#include "ie_common.h"
@ -118,14 +120,45 @@ public:
* @return IR version number: 1 or 2
*/
virtual int getVersion(ResponseDesc* resp) noexcept = 0;
virtual void addExtensions(const std::vector<InferenceEngine::IExtensionPtr>& ext) = 0;
/**
* @brief A virtual destructor.
*/
~ICNNNetReader() override = default;
};
IE_SUPPRESS_DEPRECATED_START
namespace details {
/**
* @brief This class defines the name of the fabric for creating an IHeteroInferencePlugin object in DLL
*/
template<>
class SOCreatorTrait<ICNNNetReader> {
public:
/**
* @brief A name of the fabric for creating IInferencePlugin object in DLL
*/
static constexpr auto name = "CreateICNNNetReader";
};
} // namespace details
/**
* @brief A C++ helper to work with objects created by the IR readers plugin.
* Implements different interfaces.
*/
using CNNNetReaderPtr = InferenceEngine::details::SOPointer<ICNNNetReader, InferenceEngine::details::SharedObjectLoader>;
/**
* @brief Creates a CNNNetReader instance
*
* @return An object that implements the ICNNNetReader interface
*/
IE_SUPPRESS_DEPRECATED_START
INFERENCE_ENGINE_API(ICNNNetReader*) CreateCNNNetReader() noexcept;
INFERENCE_ENGINE_API_CPP(CNNNetReaderPtr) CreateCNNNetReaderPtr() noexcept;
IE_SUPPRESS_DEPRECATED_END
} // namespace InferenceEngine

View File

@ -47,6 +47,12 @@ public:
*/
using Ptr = std::shared_ptr<ICNNNetwork>;
/**
* @brief Returns nGraph function
* @return nGraph function
*/
virtual std::shared_ptr<ngraph::Function> getFunction() noexcept = 0;
/**
* @brief Returns constant nGraph function
* @return constant nGraph function

View File

@ -2290,23 +2290,20 @@ public:
/**
* @deprecated Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2020.3
* @brief This class represents a standard Scatter layer
* @brief This class represents a standard ScatterUpdate layer
*/
class INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(ScatterLayer): public CNNLayer {
class INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(ScatterUpdateLayer): public CNNLayer {
public:
/**
* @brief The axis in Dictionary to scatter Indexes from
*/
int axis = 0;
/**
* @brief Creates a new ScatterLayer instance.
* @brief Creates a new ScatterUpdateLayer instance.
*/
using CNNLayer::CNNLayer;
~ScatterLayer() override;
~ScatterUpdateLayer() override;
};
/**
* @deprecated Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2020.3
* @brief This class represents an onnx ExperimentalDetectronPriorGridGenerator Layer
*/
class INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(ExperimentalDetectronPriorGridGeneratorLayer): public CNNLayer {
@ -2340,6 +2337,23 @@ public:
virtual ~ExperimentalDetectronPriorGridGeneratorLayer();
};
/**
* @brief This class represents a standard ExperimentalDetectronTopKROIs layer
*/
class INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(ExperimentalDetectronTopKROIs): public CNNLayer {
public:
/**
* @brief The maximum number of output rois
*/
int max_rois = 0;
/**
* @brief Creates a new ExperimentalDetectronTopKROIs instance.
*/
using CNNLayer::CNNLayer;
virtual ~ExperimentalDetectronTopKROIs();
};
/**
* @brief This class represents an onnx ExperimentalDetectronGenerateProposalsSingleImage Layer
*/

View File

@ -21,6 +21,7 @@
#include <vector>
#include "ie_api.h"
#include "ie_blob.h"
namespace ngraph {
@ -325,6 +326,7 @@ private:
};
#ifdef __clang__
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>);
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<int>);
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<bool>);
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<float>);

View File

@ -348,5 +348,17 @@ DECLARE_CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS);
*/
DECLARE_CONFIG_KEY(DUMP_EXEC_GRAPH_AS_DOT);
/**
* @brief The name for setting to execute in bfloat16 precision whenever it is possible
*
* This option let plugin know to downscale the precision where it see performance benefits from
* bfloat16 execution
* Such option do not guarantee accuracy of the network, the accuracy in this mode should be
* verified separately by the user and basing on performance and accuracy results it should be
* user's decision to use this option or not to use
*/
DECLARE_CONFIG_KEY(ENFORCE_BF16);
} // namespace PluginConfigParams
} // namespace InferenceEngine

View File

@ -26,7 +26,8 @@ public:
UNSPECIFIED = 255, /**< Unspecified value. Used by default */
MIXED = 0, /**< Mixed value. Can be received from network. No applicable for tensors */
FP32 = 10, /**< 32bit floating point value */
FP16 = 11, /**< 16bit floating point value */
FP16 = 11, /**< 16bit floating point value, 5 bit for exponent, 10 bit for mantisa */
BF16 = 12, /**< 16bit floating point value, 8 bit for exponent, 7 bit for mantisa*/
Q78 = 20, /**< 16bit specific signed fixed point precision */
I16 = 30, /**< 16bit signed integer value */
U8 = 40, /**< 8bit unsigned integer value */
@ -106,6 +107,7 @@ public:
switch (precisionInfo.value) {
CASE(FP32, float);
CASE2(FP16, int16_t, uint16_t);
CASE2(BF16, int16_t, uint16_t);
CASE(I16, int16_t);
CASE(I32, int32_t);
CASE(I64, int64_t);
@ -181,9 +183,9 @@ public:
static std::unordered_map<std::string, ePrecision> names = {
#define PRECISION_NAME(s) {#s, s}
PRECISION_NAME(Q78), PRECISION_NAME(U8), PRECISION_NAME(I8), PRECISION_NAME(I16),
PRECISION_NAME(I32), PRECISION_NAME(I64), PRECISION_NAME(U64), PRECISION_NAME(U16),
PRECISION_NAME(I32), PRECISION_NAME(I64), PRECISION_NAME(U64), PRECISION_NAME(U16),
PRECISION_NAME(FP32), PRECISION_NAME(FP16), PRECISION_NAME(MIXED), PRECISION_NAME(BIN),
PRECISION_NAME(BOOL),
PRECISION_NAME(BOOL), PRECISION_NAME(BF16),
#undef PRECISION_NAME
};
auto i = names.find(str);
@ -260,6 +262,7 @@ protected:
switch (v) {
CASE(FP32);
CASE(FP16);
CASE(BF16);
CASE(I16);
CASE(I32);
CASE(I64);
@ -295,6 +298,10 @@ struct PrecisionTrait<Precision::FP16> {
using value_type = int16_t;
};
template <>
struct PrecisionTrait<Precision::BF16> {
using value_type = int16_t;
};
template<>
struct PrecisionTrait<Precision::Q78> {
using value_type = uint16_t;
};

View File

@ -92,14 +92,17 @@ Options:
Please note that although the automatic selection usually provides a reasonable performance,
it still may be non-optimal for some cases, especially for very small networks.
-nthreads "<integer>" Optional. Number of threads to use for inference on the CPU (including HETERO and MULTI cases).
-pin "YES"/"NUMA"/"NO" Optional. Enable threads->cores ("YES", default), threads->(NUMA)nodes ("NUMA") or completely disable ("NO")
CPU threads pinning for CPU-involved inference.
-enforcebf16 Optional. Enforcing of floating point operations execution in bfloat16 precision where it is acceptable.
-pin "YES"/"NO"/"NUMA" Optional. Enable threads->cores ("YES", default), threads->(NUMA)nodes ("NUMA") or completely disable ("NO") CPU threads pinning for CPU-involved inference.
Statistics dumping options:
-report_type "<type>" Optional. Enable collecting statistics report. "no_counters" report contains configuration options specified, resulting FPS and latency. "average_counters" report extends "no_counters" report and additionally includes average PM counters values for each layer from the network. "detailed_counters" report extends "average_counters" report and additionally includes per-layer PM counters and latency for each executed infer request.
-report_folder Optional. Path to a folder where statistics report is stored.
-exec_graph_path Optional. Path to a file where to store executable graph information serialized.
-pc Optional. Report performance counters.
-dump_config Optional. Path to XML/YAML/JSON file to dump IE parameters, which were set by application.
-load_config Optional. Path to XML/YAML/JSON file to load custom IE parameters. Please note, command line parameters have higher priority then parameters from configuration file.
```
Running the application with the empty list of options yields the usage message given above and an error message.

View File

@ -48,6 +48,9 @@ static const char infer_num_streams_message[] = "Optional. Number of streams to
"usually provides a reasonable performance, it still may be non - optimal for some cases, especially for "
"very small networks. See sample's README for more details.";
/// @brief message for enforcing of BF16 execution where it is possible
static const char enforce_bf16_message[] = "Optional. Enforcing of floating point operations execution in bfloat16 precision where it is acceptable.";
/// @brief message for user library argument
static const char custom_cpu_library_message[] = "Required for CPU custom layers. Absolute path to a shared library with the kernels implementations.";
@ -85,6 +88,15 @@ static const char progress_message[] = "Optional. Show progress bar (can affect
// @brief message for performance counters option
static const char pc_message[] = "Optional. Report performance counters.";
#ifdef USE_OPENCV
// @brief message for load config option
static const char load_config_message[] = "Optional. Path to XML/YAML/JSON file to load custom IE parameters."
" Please note, command line parameters have higher priority then parameters from configuration file.";
// @brief message for dump config option
static const char dump_config_message[] = "Optional. Path to XML/YAML/JSON file to dump IE parameters, which were set by application.";
#endif
/// @brief Define flag for showing help message <br>
DEFINE_bool(h, false, help_message);
@ -130,6 +142,9 @@ DEFINE_uint32(nthreads, 0, infer_num_threads_message);
/// @brief Number of streams to use for inference on the CPU (also affects Hetero cases)
DEFINE_string(nstreams, "", infer_num_streams_message);
/// @brief Enforces bf16 execution with bfloat16 precision on systems having this capability
DEFINE_bool(enforcebf16, false, enforce_bf16_message);
/// @brief Define parameter for batch size <br>
/// Default is 0 (that means don't specify)
DEFINE_uint32(b, 0, batch_size_message);
@ -155,6 +170,14 @@ DEFINE_bool(progress, false, progress_message);
/// @brief Define flag for showing performance counters <br>
DEFINE_bool(pc, false, pc_message);
#ifdef USE_OPENCV
/// @brief Define flag for loading configuration file <br>
DEFINE_string(load_config, "", load_config_message);
/// @brief Define flag for dumping configuration file <br>
DEFINE_string(dump_config, "", dump_config_message);
#endif
/**
* @brief This function show a help message
*/
@ -180,10 +203,15 @@ static void showUsage() {
std::cout << std::endl << " device-specific performance options:" << std::endl;
std::cout << " -nstreams \"<integer>\" " << infer_num_streams_message << std::endl;
std::cout << " -nthreads \"<integer>\" " << infer_num_threads_message << std::endl;
std::cout << " -pin \"YES\"/\"NO\" " << infer_threads_pinning_message << std::endl;
std::cout << " -enforcebf16 " << enforce_bf16_message << std::endl;
std::cout << " -pin \"YES\"/\"NO\"/\"NUMA\" " << infer_threads_pinning_message << std::endl;
std::cout << std::endl << " Statistics dumping options:" << std::endl;
std::cout << " -report_type \"<type>\" " << report_type_message << std::endl;
std::cout << " -report_folder " << report_folder_message << std::endl;
std::cout << " -exec_graph_path " << exec_graph_path_message << std::endl;
std::cout << " -pc " << pc_message << std::endl;
#ifdef USE_OPENCV
std::cout << " -dump_config " << dump_config_message << std::endl;
std::cout << " -load_config " << load_config_message << std::endl;
#endif
}

View File

@ -55,9 +55,9 @@ bool ParseAndCheckCommandLine(int argc, char *argv[]) {
}
if (!FLAGS_report_type.empty() &&
FLAGS_report_type != noCntReport && FLAGS_report_type != averageCntReport && FLAGS_report_type != detailedCntReport) {
FLAGS_report_type != noCntReport && FLAGS_report_type != averageCntReport && FLAGS_report_type != detailedCntReport) {
std::string err = "only " + std::string(noCntReport) + "/" + std::string(averageCntReport) + "/" + std::string(detailedCntReport) +
" report types are supported (invalid -report_type option value)";
" report types are supported (invalid -report_type option value)";
throw std::logic_error(err);
}
@ -71,17 +71,17 @@ bool ParseAndCheckCommandLine(int argc, char *argv[]) {
static void next_step(const std::string additional_info = "") {
static size_t step_id = 0;
static const std::map<size_t, std::string> step_names = {
{ 1, "Parsing and validating input arguments" },
{ 2, "Loading Inference Engine" },
{ 3, "Setting device configuration" },
{ 4, "Reading the Intermediate Representation network" },
{ 5, "Resizing network to match image sizes and given batch" },
{ 6, "Configuring input of the model" },
{ 7, "Loading the model to the device" },
{ 8, "Setting optimal runtime parameters" },
{ 9, "Creating infer requests and filling input blobs with images" },
{ 10, "Measuring performance" },
{ 11, "Dumping statistics report" }
{ 1, "Parsing and validating input arguments" },
{ 2, "Loading Inference Engine" },
{ 3, "Setting device configuration" },
{ 4, "Reading the Intermediate Representation network" },
{ 5, "Resizing network to match image sizes and given batch" },
{ 6, "Configuring input of the model" },
{ 7, "Loading the model to the device" },
{ 8, "Setting optimal runtime parameters" },
{ 9, "Creating infer requests and filling input blobs with images" },
{ 10, "Measuring performance" },
{ 11, "Dumping statistics report" }
};
step_id++;
@ -121,38 +121,46 @@ int main(int argc, char *argv[]) {
slog::info << "Network is compiled" << slog::endl;
}
if (!FLAGS_report_type.empty()) {
std::vector<gflags::CommandLineFlagInfo> flags;
StatisticsReport::Parameters command_line_arguments;
gflags::GetAllFlags(&flags);
for (auto &flag : flags) {
if (!flag.is_default) {
command_line_arguments.push_back({ flag.name, flag.current_value });
}
std::vector<gflags::CommandLineFlagInfo> flags;
StatisticsReport::Parameters command_line_arguments;
gflags::GetAllFlags(&flags);
for (auto &flag : flags) {
if (!flag.is_default) {
command_line_arguments.push_back({ flag.name, flag.current_value });
}
}
if (!FLAGS_report_type.empty()) {
statistics = std::make_shared<StatisticsReport>(StatisticsReport::Config{FLAGS_report_type, FLAGS_report_folder});
statistics->addParameters(StatisticsReport::Category::COMMAND_LINE_PARAMETERS, command_line_arguments);
}
auto isFlagSetInCommandLine = [&command_line_arguments] (const std::string& name) {
return (std::find_if(command_line_arguments.begin(), command_line_arguments.end(),
[ name ] (const std::pair<std::string, std::string>& p) { return p.first == name;}) != command_line_arguments.end());
};
std::string device_name = FLAGS_d;
// Parse devices
auto devices = parseDevices(device_name);
// Parse nstreams per device
std::map<std::string, std::string> device_nstreams = parseNStreamsValuePerDevice(devices, FLAGS_nstreams);
// Load device config file if specified
std::map<std::string, std::map<std::string, std::string>> config;
#ifdef USE_OPENCV
if (!FLAGS_load_config.empty()) {
load_config(FLAGS_load_config, config);
}
#endif
/** This vector stores paths to the processed images **/
std::vector<std::string> inputFiles;
parseInputFilesArguments(inputFiles);
if (FLAGS_nstreams.empty()) {
slog::warn << "-nstreams default value is determined automatically for a device. "
"Although the automatic selection usually provides a reasonable performance,"
"but it still may be non-optimal for some cases, for more information look at README." << slog::endl<< slog::endl;
}
// ----------------- 2. Loading the Inference Engine -----------------------------------------------------------
next_step();
// Get optimal runtime parameters for device
std::string device_name = FLAGS_d;
Core ie;
if (FLAGS_d.find("CPU") != std::string::npos && !FLAGS_l.empty()) {
// CPU (MKLDNN) extensions is loaded as a shared library and passed as a pointer to base extension
const auto extension_ptr = InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(FLAGS_l);
@ -160,10 +168,17 @@ int main(int argc, char *argv[]) {
slog::info << "CPU (MKLDNN) extensions is loaded " << FLAGS_l << slog::endl;
}
// Load clDNN Extensions
if ((FLAGS_d.find("GPU") != std::string::npos) && !FLAGS_c.empty()) {
// Load clDNN Extensions
ie.SetConfig({ {CONFIG_KEY(CONFIG_FILE), FLAGS_c} });
slog::info << "GPU extensions is loaded " << FLAGS_c << slog::endl;
// Override config if command line parameter is specified
if (!config.count("GPU"))
config["GPU"] = {};
config["GPU"][CONFIG_KEY(CONFIG_FILE)] = FLAGS_c;
}
if (config.count("GPU") && config.at("GPU").count(CONFIG_KEY(CONFIG_FILE))) {
auto ext = config.at("GPU").at(CONFIG_KEY(CONFIG_FILE));
ie.SetConfig({{ CONFIG_KEY(CONFIG_FILE), ext }}, "GPU");
slog::info << "GPU extensions is loaded " << ext << slog::endl;
}
slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << slog::endl;
@ -173,70 +188,108 @@ int main(int argc, char *argv[]) {
// ----------------- 3. Setting device configuration -----------------------------------------------------------
next_step();
bool perf_counts = (FLAGS_report_type == detailedCntReport ||
FLAGS_report_type == averageCntReport ||
FLAGS_pc ||
!FLAGS_exec_graph_path.empty());
auto devices = parseDevices(device_name);
std::map<std::string, uint32_t> device_nstreams = parseNStreamsValuePerDevice(devices, FLAGS_nstreams);
for (auto& pair : device_nstreams) {
auto key = std::string(pair.first + "_THROUGHPUT_STREAMS");
std::vector<std::string> supported_config_keys = ie.GetMetric(pair.first, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
if (std::find(supported_config_keys.begin(), supported_config_keys.end(), key) == supported_config_keys.end()) {
throw std::logic_error("Device " + pair.first + " doesn't support config key '" + key + "'! " +
"Please specify -nstreams for correct devices in format <dev1>:<nstreams1>,<dev2>:<nstreams2>");
}
}
bool perf_counts = false;
// Update config per device according to command line parameters
for (auto& device : devices) {
if (!config.count(device)) config[device] = {};
std::map<std::string, std::string>& device_config = config.at(device);
// Set performance counter
if (isFlagSetInCommandLine("pc")) {
// set to user defined value
device_config[CONFIG_KEY(PERF_COUNT)] = FLAGS_pc ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO);
} else if (device_config.count(CONFIG_KEY(PERF_COUNT)) &&
(device_config.at(CONFIG_KEY(PERF_COUNT)) == "YES")) {
slog::warn << "Performance counters for " << device <<
" device is turned on. To print results use -pc option." << slog::endl;
} else if (FLAGS_report_type == detailedCntReport || FLAGS_report_type == averageCntReport) {
slog::warn << "Turn on performance counters for " << device <<
" device since report type is " << FLAGS_report_type << "." << slog::endl;
device_config[CONFIG_KEY(PERF_COUNT)] = CONFIG_VALUE(YES);
} else if (!FLAGS_exec_graph_path.empty()) {
slog::warn << "Turn on performance counters for " << device <<
" device due to execution graph dumping." << slog::endl;
device_config[CONFIG_KEY(PERF_COUNT)] = CONFIG_VALUE(YES);
} else {
// set to default value
device_config[CONFIG_KEY(PERF_COUNT)] = FLAGS_pc ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO);
}
perf_counts = (device_config.at(CONFIG_KEY(PERF_COUNT)) == CONFIG_VALUE(YES)) ? true : perf_counts;
auto setThroughputStreams = [&] () {
const std::string key = device + "_THROUGHPUT_STREAMS";
if (device_nstreams.count(device)) {
// set to user defined value
std::vector<std::string> supported_config_keys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
if (std::find(supported_config_keys.begin(), supported_config_keys.end(), key) == supported_config_keys.end()) {
throw std::logic_error("Device " + device + " doesn't support config key '" + key + "'! " +
"Please specify -nstreams for correct devices in format <dev1>:<nstreams1>,<dev2>:<nstreams2>" +
" or via configuration file.");
}
device_config[key] = device_nstreams.at(device);
} else if (!device_config.count(key) && (FLAGS_api == "async")) {
slog::warn << "-nstreams default value is determined automatically for " << device << " device. "
"Although the automatic selection usually provides a reasonable performance,"
"but it still may be non-optimal for some cases, for more information look at README." << slog::endl;
device_config[key] = std::string(device + "_THROUGHPUT_AUTO");
}
if (device_config.count(key))
device_nstreams[device] = device_config.at(key);
};
if (device == "CPU") { // CPU supports few special performance-oriented keys
// limit threading for CPU portion of inference
if (FLAGS_nthreads != 0)
ie.SetConfig({{ CONFIG_KEY(CPU_THREADS_NUM), std::to_string(FLAGS_nthreads) }}, device);
if (isFlagSetInCommandLine("nthreads"))
device_config[CONFIG_KEY(CPU_THREADS_NUM)] = std::to_string(FLAGS_nthreads);
if ((device_name.find("MULTI") != std::string::npos) &&
(device_name.find("GPU") != std::string::npos)) {
ie.SetConfig({{ CONFIG_KEY(CPU_BIND_THREAD), CONFIG_VALUE(NO) }}, device);
} else {
// pin threads for CPU portion of inference
ie.SetConfig({{ CONFIG_KEY(CPU_BIND_THREAD), FLAGS_pin }}, device);
if (isFlagSetInCommandLine("enforcebf16"))
device_config[CONFIG_KEY(ENFORCE_BF16)] = FLAGS_enforcebf16 ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO);
if (isFlagSetInCommandLine("pin")) {
// set to user defined value
device_config[CONFIG_KEY(CPU_BIND_THREAD)] = FLAGS_pin;
} else if (!device_config.count(CONFIG_KEY(CPU_BIND_THREAD))) {
if ((device_name.find("MULTI") != std::string::npos) &&
(device_name.find("GPU") != std::string::npos)) {
slog::warn << "Turn off threads pinning for " << device <<
" device since multi-scenario with GPU device is used." << slog::endl;
device_config[CONFIG_KEY(CPU_BIND_THREAD)] = CONFIG_VALUE(NO);
} else {
// set to default value
device_config[CONFIG_KEY(CPU_BIND_THREAD)] = FLAGS_pin;
}
}
// for CPU execution, more throughput-oriented execution via streams
if (FLAGS_api == "async")
ie.SetConfig({{ CONFIG_KEY(CPU_THROUGHPUT_STREAMS),
(device_nstreams.count(device) > 0 ? std::to_string(device_nstreams.at(device)) :
"CPU_THROUGHPUT_AUTO") }}, device);
device_nstreams[device] = std::stoi(ie.GetConfig(device, CONFIG_KEY(CPU_THROUGHPUT_STREAMS)).as<std::string>());
setThroughputStreams();
} else if (device == ("GPU")) {
if (FLAGS_api == "async")
ie.SetConfig({{ CONFIG_KEY(GPU_THROUGHPUT_STREAMS),
(device_nstreams.count(device) > 0 ? std::to_string(device_nstreams.at(device)) :
"GPU_THROUGHPUT_AUTO") }}, device);
device_nstreams[device] = std::stoi(ie.GetConfig(device, CONFIG_KEY(GPU_THROUGHPUT_STREAMS)).as<std::string>());
// for GPU execution, more throughput-oriented execution via streams
setThroughputStreams();
if ((device_name.find("MULTI") != std::string::npos) &&
(device_name.find("CPU") != std::string::npos)) {
// multi-device execution with the CPU + GPU performs best with GPU trottling hint,
// which releases another CPU thread (that is otherwise used by the GPU driver for active polling)
ie.SetConfig({{ CLDNN_CONFIG_KEY(PLUGIN_THROTTLE), "1" }}, "GPU");
slog::warn << "Turn on GPU trottling. Multi-device execution with the CPU + GPU performs best with GPU trottling hint," <<
"which releases another CPU thread (that is otherwise used by the GPU driver for active polling)"<< slog::endl;
device_config[CLDNN_CONFIG_KEY(PLUGIN_THROTTLE)] = "1";
}
} else if (device == "MYRIAD") {
ie.SetConfig({{ CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_WARNING) }}, device);
device_config[CONFIG_KEY(LOG_LEVEL)] = CONFIG_VALUE(LOG_WARNING);
}
}
for (auto&& item : config) {
ie.SetConfig(item.second, item.first);
}
auto double_to_string = [] (const double number) {
std::stringstream ss;
ss << std::fixed << std::setprecision(2) << number;
return ss.str();
};
std::stringstream ss;
ss << std::fixed << std::setprecision(2) << number;
return ss.str();
};
auto get_total_ms_time = [] (Time::time_point& startTime) {
return std::chrono::duration_cast<ns>(Time::now() - startTime).count() * 0.000001;
};
size_t batchSize = FLAGS_b;
Precision precision = Precision::UNSPECIFIED;
std::string topology_name = "";
@ -253,7 +306,7 @@ int main(int argc, char *argv[]) {
if (statistics)
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"read network time (ms)", duration_ms}
{"read network time (ms)", duration_ms}
});
const InputsDataMap inputInfo(cnnNetwork.getInputsInfo());
@ -305,17 +358,14 @@ int main(int argc, char *argv[]) {
}
// ----------------- 7. Loading the model to the device --------------------------------------------------------
next_step();
std::map<std::string, std::string> config = {{ CONFIG_KEY(PERF_COUNT), perf_counts ? CONFIG_VALUE(YES) :
CONFIG_VALUE(NO) }};
startTime = Time::now();
exeNetwork = ie.LoadNetwork(cnnNetwork, device_name, config);
exeNetwork = ie.LoadNetwork(cnnNetwork, device_name);
duration_ms = double_to_string(get_total_ms_time(startTime));
slog::info << "Load network took " << duration_ms << " ms" << slog::endl;
if (statistics)
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"load network time (ms)", duration_ms}
{"load network time (ms)", duration_ms}
});
} else {
next_step();
@ -333,7 +383,7 @@ int main(int argc, char *argv[]) {
if (statistics)
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"import network time (ms)", duration_ms}
{"import network time (ms)", duration_ms}
});
if (batchSize == 0) {
batchSize = 1;
@ -342,6 +392,12 @@ int main(int argc, char *argv[]) {
// ----------------- 8. Setting optimal runtime parameters -----------------------------------------------------
next_step();
// Update number of streams
for (auto&& ds : device_nstreams) {
const std::string key = ds.first + "_THROUGHPUT_STREAMS";
device_nstreams[ds.first] = ie.GetConfig(ds.first, key).as<std::string>();
}
// Number of requests
uint32_t nireq = FLAGS_nireq;
if (nireq == 0) {
@ -384,21 +440,21 @@ int main(int argc, char *argv[]) {
if (statistics) {
statistics->addParameters(StatisticsReport::Category::RUNTIME_CONFIG,
{
{"topology", topology_name},
{"target device", device_name},
{"API", FLAGS_api},
{"precision", std::string(precision.name())},
{"batch size", std::to_string(batchSize)},
{"number of iterations", std::to_string(niter)},
{"number of parallel infer requests", std::to_string(nireq)},
{"duration (ms)", std::to_string(getDurationInMilliseconds(duration_seconds))},
{"topology", topology_name},
{"target device", device_name},
{"API", FLAGS_api},
{"precision", std::string(precision.name())},
{"batch size", std::to_string(batchSize)},
{"number of iterations", std::to_string(niter)},
{"number of parallel infer requests", std::to_string(nireq)},
{"duration (ms)", std::to_string(getDurationInMilliseconds(duration_seconds))},
});
for (auto& nstreams : device_nstreams) {
std::stringstream ss;
ss << "number of " << nstreams.first << " streams";
statistics->addParameters(StatisticsReport::Category::RUNTIME_CONFIG,
{
{ss.str(), std::to_string(nstreams.second)},
{ss.str(), nstreams.second},
});
}
}
@ -511,23 +567,23 @@ int main(int argc, char *argv[]) {
double latency = getMedianValue<double>(inferRequestsQueue.getLatencies());
double totalDuration = inferRequestsQueue.getDurationInMilliseconds();
double fps = (FLAGS_api == "sync") ? batchSize * 1000.0 / latency :
batchSize * 1000.0 * iteration / totalDuration;
batchSize * 1000.0 * iteration / totalDuration;
if (statistics) {
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"total execution time (ms)", double_to_string(totalDuration)},
{"total number of iterations", std::to_string(iteration)},
{"total execution time (ms)", double_to_string(totalDuration)},
{"total number of iterations", std::to_string(iteration)},
});
if (device_name.find("MULTI") == std::string::npos) {
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"latency (ms)", double_to_string(latency)},
{"latency (ms)", double_to_string(latency)},
});
}
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"throughput", double_to_string(fps)}
{"throughput", double_to_string(fps)}
});
}
@ -536,6 +592,13 @@ int main(int argc, char *argv[]) {
// ----------------- 11. Dumping statistics report -------------------------------------------------------------
next_step();
#ifdef USE_OPENCV
if (!FLAGS_dump_config.empty()) {
dump_config(FLAGS_dump_config, config);
slog::info << "Inference Engine configuration settings were dumped to " << FLAGS_dump_config << slog::endl;
}
#endif
if (!FLAGS_exec_graph_path.empty()) {
try {
CNNNetwork execGraphInfo = exeNetwork.GetExecGraphInfo();
@ -575,7 +638,7 @@ int main(int argc, char *argv[]) {
if (statistics) {
statistics->addParameters(StatisticsReport::Category::EXECUTION_RESULTS,
{
{"error", ex.what()},
{"error", ex.what()},
});
statistics->dump();
}

View File

@ -13,6 +13,10 @@
#include "utils.hpp"
#ifdef USE_OPENCV
#include <opencv2/core.hpp>
#endif
uint32_t deviceDefaultDeviceDurationInSeconds(const std::string& device) {
static const std::map<std::string, uint32_t> deviceDefaultDurationInSeconds {
{ "CPU", 60 },
@ -60,32 +64,33 @@ std::vector<std::string> parseDevices(const std::string& device_string) {
if (comma_separated_devices.find(":") != std::string::npos) {
comma_separated_devices = comma_separated_devices.substr(comma_separated_devices.find(":") + 1);
}
if ((comma_separated_devices == "MULTI") || (comma_separated_devices == "HETERO"))
return std::vector<std::string>();
auto devices = split(comma_separated_devices, ',');
for (auto& device : devices)
device = device.substr(0, device.find_first_of(".("));
return devices;
}
std::map<std::string, uint32_t> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
const std::string& values_string) {
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
const std::string& values_string) {
// Format: <device1>:<value1>,<device2>:<value2> or just <value>
auto values_string_upper = values_string;
std::map<std::string, uint32_t> result;
auto device_value_strings = split(values_string_upper, ',');
std::map<std::string, std::string> result;
auto device_value_strings = split(values_string, ',');
for (auto& device_value_string : device_value_strings) {
auto device_value_vec = split(device_value_string, ':');
auto device_value_vec = split(device_value_string, ':');
if (device_value_vec.size() == 2) {
auto device_name = device_value_vec.at(0);
auto nstreams = device_value_vec.at(1);
auto it = std::find(devices.begin(), devices.end(), device_name);
if (it != devices.end()) {
result[device_name] = std::stoi(nstreams);
result[device_name] = nstreams;
} else {
throw std::logic_error("Can't set nstreams value " + std::string(nstreams) +
" for device '" + device_name + "'! Incorrect device name!");
}
} else if (device_value_vec.size() == 1) {
uint32_t value = std::stoi(device_value_vec.at(0));
auto value = device_value_vec.at(0);
for (auto& device : devices) {
result[device] = value;
}
@ -95,3 +100,37 @@ std::map<std::string, uint32_t> parseNStreamsValuePerDevice(const std::vector<st
}
return result;
}
#ifdef USE_OPENCV
void dump_config(const std::string& filename,
const std::map<std::string, std::map<std::string, std::string>>& config) {
cv::FileStorage fs(filename, cv::FileStorage::WRITE);
if (!fs.isOpened())
throw std::runtime_error("Error: Can't open config file : " + filename);
for (auto device_it = config.begin(); device_it != config.end(); ++device_it) {
fs << device_it->first << "{:";
for (auto param_it = device_it->second.begin(); param_it != device_it->second.end(); ++param_it)
fs << param_it->first << param_it->second;
fs << "}";
}
fs.release();
}
void load_config(const std::string& filename,
std::map<std::string, std::map<std::string, std::string>>& config) {
cv::FileStorage fs(filename, cv::FileStorage::READ);
if (!fs.isOpened())
throw std::runtime_error("Error: Can't load config file : " + filename);
cv::FileNode root = fs.root();
for (auto it = root.begin(); it != root.end(); ++it) {
auto device = *it;
if (!device.isMap()) {
throw std::runtime_error("Error: Can't parse config file : " + filename);
}
for (auto iit = device.begin(); iit != device.end(); ++iit) {
auto item = *iit;
config[device.name()][item.name()] = item.string();
}
}
}
#endif

View File

@ -10,5 +10,11 @@
std::vector<std::string> parseDevices(const std::string& device_string);
uint32_t deviceDefaultDeviceDurationInSeconds(const std::string& device);
std::map<std::string, uint32_t> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
const std::string& values_string);
std::map<std::string, std::string> parseNStreamsValuePerDevice(const std::vector<std::string>& devices,
const std::string& values_string);
#ifdef USE_OPENCV
void dump_config(const std::string& filename,
const std::map<std::string, std::map<std::string, std::string>>& config);
void load_config(const std::string& filename,
std::map<std::string, std::map<std::string, std::string>>& config);
#endif

View File

@ -85,30 +85,28 @@ int main(int argc, char *argv[]) {
std::vector<std::string> availableDevices = ie.GetAvailableDevices();
// --------------------------- 3. Query and print supported metrics and config keys--------------------
std::set<std::string> printedDevices;
std::cout << "Available devices: " << std::endl;
for (auto && device : availableDevices) {
std::string deviceFamilyName = device.substr(0, device.find_first_of('.'));
if (printedDevices.find(deviceFamilyName) == printedDevices.end())
printedDevices.insert(deviceFamilyName);
else
continue;
std::cout << "\tDevice: " << deviceFamilyName << std::endl;
std::cout << "\tDevice: " << device << std::endl;
std::cout << "\tMetrics: " << std::endl;
std::vector<std::string> supportedMetrics = ie.GetMetric(deviceFamilyName, METRIC_KEY(SUPPORTED_METRICS));
std::vector<std::string> supportedMetrics = ie.GetMetric(device, METRIC_KEY(SUPPORTED_METRICS));
for (auto && metricName : supportedMetrics) {
std::cout << "\t\t" << metricName << " : " << std::flush;
printParameterValue(ie.GetMetric(device, metricName));
if (metricName != METRIC_KEY(AVAILABLE_DEVICES)) {
std::cout << "\t\t" << metricName << " : " << std::flush;
printParameterValue(ie.GetMetric(device, metricName));
}
}
std::cout << "\tDefault values for device configuration keys: " << std::endl;
std::vector<std::string> supportedConfigKeys = ie.GetMetric(deviceFamilyName, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
for (auto && configKey : supportedConfigKeys) {
std::cout << "\t\t" << configKey << " : " << std::flush;
printParameterValue(ie.GetConfig(deviceFamilyName, configKey));
if (std::find(supportedMetrics.begin(), supportedMetrics.end(),
METRIC_KEY(SUPPORTED_CONFIG_KEYS)) != supportedMetrics.end()) {
std::cout << "\tDefault values for device configuration keys: " << std::endl;
std::vector<std::string> supportedConfigKeys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
for (auto && configKey : supportedConfigKeys) {
std::cout << "\t\t" << configKey << " : " << std::flush;
printParameterValue(ie.GetConfig(device, configKey));
}
}
std::cout << std::endl;

View File

@ -643,12 +643,13 @@ int main(int argc, char *argv[]) {
auto t0 = Time::now();
ExecutableNetwork executableNet;
ie.SetConfig(genericPluginConfig, deviceStr);
if (!FLAGS_m.empty()) {
slog::info << "Loading model to the device" << slog::endl;
executableNet = ie.LoadNetwork(network, deviceStr, genericPluginConfig);
executableNet = ie.LoadNetwork(network, deviceStr);
} else {
slog::info << "Importing model to the device" << slog::endl;
executableNet = ie.ImportNetwork(FLAGS_rg.c_str(), deviceStr, genericPluginConfig);
executableNet = ie.ImportNetwork(FLAGS_rg.c_str(), deviceStr);
}
ms loadTime = std::chrono::duration_cast<ms>(Time::now() - t0);

View File

@ -0,0 +1,83 @@
#!/bin/bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
command -v realpath >/dev/null 2>&1 || { echo >&2 "cpplint require realpath executable but it's not installed. Aborting."; exit 1; }
SOURCE_DIR=$(realpath ${CURRENT_DIR}/..)
REPORT_DIR="${SOURCE_DIR}/report"
CPPLINT_REPORT_DIR="${REPORT_DIR}/cpplint"
PROJECT_NAME="Inference Engine"
function run_cpplint() {
echo "-> CppLint started..."
if [ -d ${CPPLINT_REPORT_DIR} ]; then
rm -Rf ${CPPLINT_REPORT_DIR}
fi
mkdir -p ${CPPLINT_REPORT_DIR}
python ${CURRENT_DIR}/cpplint.py --linelength=160 --counting=detailed --quiet --filter="
-build/header_guard,
-build/include,
-build/include_order,
-build/include_subdir,
-build/include_what_you_use,
-build/namespaces,
-build/c++11,
-whitespace/indent,
-whitespace/comments,
-whitespace/ending_newline,
-runtime/references,
-runtime/int,
-runtime/explicit,
-readability/todo,
-readability/fn_size
" $(find ${SOURCE_DIR} -name '*.h' -or -name '*.cc' -or -name '*.c' -or -name '*.cpp' -or -name '*.hpp' |
grep -v 'inference-engine/bin\|inference-engine/build\|inference-engine/report\|inference-engine/scripts\|inference-engine/temp\|inference-engine/tests_deprecated/\|gtest\|inference-engine/ie_bridges\|pugixml\|inference-engine/tools/vpu_perfcheck\|thirdparty/gflags\|thirdparty/ade\|thirdparty/fluid\|thirdparty/mkl-dnn\|thirdparty/movidius\|thirdparty/ocv\|thirdparty/plugixml\|thirdparty/std_lib\|thirdparty/clDNN/common\|thirdparty/clDNN/tutorial\|thirdparty/clDNN/utils' |
grep 'include\|src\|inference-engine/samples\|thirdparty/clDNN/kernel_selector\|thirdparty/clDNN/api\|thirdparty/clDNN/api_extension\|inference-engine/tests_' ) 2>&1 |
sed 's/"/\&quot;/g' >&1| sed 's/</\&lt;/g' >&1| sed 's/>/\&gt;/g' >&1| sed "s/'/\&apos;/g" >&1|
sed 's/\&/\&amp;/g' >&1| python ${CURRENT_DIR}/cpplint_to_cppcheckxml.py &> ${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml
# Generate html from it
${CURRENT_DIR}/cppcheck-htmlreport.py --file=${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml --report-dir=${CPPLINT_REPORT_DIR} --source-dir=${SOURCE_DIR} --title=${PROJECT_NAME}
# Change Cppcheck things to cpplint
sed -i.bak 's/Cppcheck/cpplint/g' ${CPPLINT_REPORT_DIR}/index.html
sed -i.bak 's/a\ tool\ for\ static\ C\/C++\ code\ analysis/an\ open\ source\ lint\-like\ tool\ from\ Google/g' ${CPPLINT_REPORT_DIR}/index.html
sed -i.bak 's/http:\/\/cppcheck.sourceforge.net/http:\/\/google\-styleguide.googlecode.com\/svn\/trunk\/cpplint\/cpplint.py/g' ${CPPLINT_REPORT_DIR}/index.html
sed -i.bak 's/IRC: <a href=\"irc:\/\/irc.freenode.net\/cppcheck\">irc:\/\/irc.freenode.net\/cppcheck<\/a>/\ /g' ${CPPLINT_REPORT_DIR}/index.html
echo "-> CppLint finished..."
}
function run_cpp_check() {
echo "-> Cppcheck started..."
CPPCHECK_REPORT_DIR="${REPORT_DIR}/cppcheck"
if [ -d ${CPPCHECK_REPORT_DIR} ]; then
rm -Rf ${CPPCHECK_REPORT_DIR}
fi
mkdir -p ${CPPCHECK_REPORT_DIR}
# Generate cppcheck xml
cppcheck -v --enable=all --suppress=missingIncludeSystem --std=c++11 ${SOURCE_DIR} -i${SOURCE_DIR}/thirdparty -i${SOURCE_DIR}/tests/libs -i${SOURCE_DIR}/temp -i${SOURCE_DIR}/build \
-i${SOURCE_DIR}/bin -i${SOURCE_DIR}/report -I${SOURCE_DIR}/include -I${SOURCE_DIR}/src -I${SOURCE_DIR}/thirdparty/pugixml/src -I${SOURCE_DIR}/thirdparty/gflags/src -I${SOURCE_DIR}/samples/scoring_agent/HTTPClient -I${SOURCE_DIR}/src/inference_engine --xml-version=2 2> ${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml
# Generate html from it
python ${CURRENT_DIR}/cppcheck-htmlreport.py\
--file=${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml\
--report-dir=${CPPCHECK_REPORT_DIR}\
--source-dir=${SOURCE_DIR}\
--title=${PROJECT_NAME}
echo "-> Cppcheck finished..."
}
if [ ! -d ${REPORT_DIR} ]; then
mkdir -p ${REPORT_DIR}
fi
run_cpplint
out_cpp_lint=`cat ${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml`
if [[ ${out_cpp_lint} == *"error"* ]]; then
exit 1
fi
#run_cpp_check

View File

@ -4,6 +4,8 @@
add_subdirectory(preprocessing)
add_subdirectory(ir_readers)
add_subdirectory(legacy_api)
if(ENABLE_MKL_DNN)

View File

@ -269,5 +269,6 @@ void Config::adjustKeyMapValues() {
key_config_map[PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS] = std::to_string(throughput_streams);
key_config_map[PluginConfigParams::KEY_DEVICE_ID] = device_id;
key_config_map[PluginConfigParams::KEY_CONFIG_FILE] = "";
}
} // namespace CLDNNPlugin

View File

@ -2704,7 +2704,7 @@ void Program::CreatePoolingPrimitive(cldnn::topology& topology, InferenceEngine:
} else {
size = (cldnn::tensor) cldnn::spatial(TensorValue(poolLayer->_kernel[X_AXIS]), TensorValue(poolLayer->_kernel[Y_AXIS]));
stride = (cldnn::tensor) cldnn::spatial(TensorValue(poolLayer->_stride[X_AXIS]), TensorValue(poolLayer->_stride[Y_AXIS]));
input_offset = { 0, 0, -TensorValue(allPads.begin[X_AXIS]), -TensorValue(allPads.begin[Y_AXIS]) };
input_offset = { 0, 0, -TensorValue(allPads.begin[X_AXIS]), -TensorValue(allPads.begin[Y_AXIS]), 0 };
}
auto dt = DataTypeFromPrecision(poolLayer->outData[0]->getPrecision());

View File

@ -8,6 +8,7 @@
#include <set>
#include <string>
#include <algorithm>
#include <map>
#if defined __INTEL_COMPILER || defined _MSC_VER
#include <malloc.h>
@ -28,6 +29,7 @@
#include "gna2_model_debug_log.hpp"
#else
#include <gna-api-types-xnn.h>
#include <map>
#endif
@ -373,6 +375,13 @@ float GNAPluginNS::backend::AMIntelDNN::OutputScaleFactor(intel_dnn_component_t
return comp.output_scale_factor;
}
struct InputEndPoint {
int idx = 0;
size_t size = 0;
size_t num_bytes_per_output = 1;
InputEndPoint() = default;
InputEndPoint(int nidx, size_t sz, size_t esize) : idx(nidx), size(sz), num_bytes_per_output(esize) {}
};
void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename) {
auto & components = component;
@ -414,11 +423,21 @@ void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename)
return ptra >= ptrb && ptra < reinterpret_cast<char*>(ptrb) + bsize;
};
auto startPtr = [](void* ptr, size_t size) {
return reinterpret_cast<int8_t*>(ptr);
};
auto endPtr = [](void* ptr, size_t size) {
return reinterpret_cast<int8_t*>(ptr) + size;
};
auto sizeofTensor = [](void* ptr, size_t size) {
return size;
};
std::fstream graph(filename, std::ios::out);
graph << "strict digraph {";
std::set<void*> weights;
std::set<void*> biases;
std::set<void*> outputs;
std::map<void*, InputEndPoint> outputs;
std::set<std::string> layersNames;
auto generate_layer_name = [&](int k) {
@ -565,11 +584,25 @@ void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename)
}
}
if (!inputConnected) {
// drawing tmp connection
outputs.insert(components[k].ptr_inputs);
auto tidx = std::distance(outputs.begin(), outputs.find(components[k].ptr_inputs));
graph << tidx << " -> " << l
<< " [label=\"FROM_TMP\", fontcolor=darkgreen,color=orange, style=dashed];";
// searching for TMP connection
size_t tidx = -1;
for (auto && en : outputs) {
if (intersected(en.first, en.second.size, INPUTS(k))) {
tidx = en.second.idx;
auto updated_ptr = std::min(startPtr(en.first, en.second.size), startPtr(INPUTS(k)));
auto updated_size = std::max(endPtr(en.first, en.second.size), endPtr(INPUTS(k))) - updated_ptr;
outputs.erase(en.first);
outputs[updated_ptr] = InputEndPoint(tidx, updated_size, components[k].num_bytes_per_input);
break;
}
}
if (tidx == -1) {
outputs[components[k].ptr_inputs] = InputEndPoint(outputs.size(), sizeofTensor(INPUTS(k)), components[k].num_bytes_per_input);
}
tidx = outputs[components[k].ptr_inputs].idx;
graph << "parameter_" << tidx << " -> " << l
<< " [fontcolor=darkgreen,color=orange, style=dashed];";
}
}
@ -578,13 +611,25 @@ void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename)
int tidx = 0;
for (auto tmpOutPtrs : outputs) {
if (components[k].ptr_outputs == tmpOutPtrs) {
if (components[k].ptr_outputs == tmpOutPtrs.first) {
graph << l << " -> " << tidx << " [label=\"TO_TMP\", fontcolor=darkgreen,color=orange, style=dashed];";
}
tidx++;
}
}
// writing inputs info
for (auto && en : outputs) {
std::string l = "parameter_" + std::to_string(en.second.idx);
graph << l << " [shape=box, style=filled, fillcolor=\"#85C1E9\"";
graph << ", label=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n"
" <TR><TD colspan=\"2\">" << l << "</TD></TR>\n";
graph << " <TR><TD> dims</TD><TD>" << 1 << "x" << en.second.size / en.second.num_bytes_per_output << "</TD></TR>\n";
graph << " <TR><TD> obit</TD><TD>" << en.second.num_bytes_per_output << "</TD></TR>\n";
graph << " <TR><TD> ptr</TD><TD>" << en.first << "</TD></TR>\n";
graph << "</TABLE>>];\n";
}
graph << "}";
}

View File

@ -21,20 +21,28 @@ class GNAExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSafe
std::shared_ptr<GNAPlugin> plg;
public:
GNAExecutableNetwork(const std::string &aotFileName, const std::map<std::string, std::string> &config) :
plg(std::make_shared<GNAPlugin>(config)) {
GNAExecutableNetwork(const std::string &aotFileName, std::shared_ptr<GNAPlugin> plg)
: plg(plg) {
plg->ImportNetwork(aotFileName);
_networkInputs = plg->GetInputs();
_networkOutputs = plg->GetOutputs();
}
GNAExecutableNetwork(InferenceEngine::ICNNNetwork &network, const std::map<std::string, std::string> &config)
: plg(std::make_shared<GNAPlugin>(config)) {
GNAExecutableNetwork(InferenceEngine::ICNNNetwork &network, std::shared_ptr<GNAPlugin> plg)
: plg(plg) {
InferenceEngine::NetPass::ConvertPrecision(network, InferenceEngine::Precision::I64, InferenceEngine::Precision::I32);
InferenceEngine::NetPass::ConvertPrecision(network, InferenceEngine::Precision::U64, InferenceEngine::Precision::I32);
plg->LoadNetwork(network);
}
GNAExecutableNetwork(const std::string &aotFileName, const std::map<std::string, std::string> &config)
: GNAExecutableNetwork(aotFileName, std::make_shared<GNAPlugin>(config)) {
}
GNAExecutableNetwork(InferenceEngine::ICNNNetwork &network, const std::map<std::string, std::string> &config)
: GNAExecutableNetwork(network, std::make_shared<GNAPlugin>(config)) {
}
InferenceEngine::AsyncInferRequestInternal::Ptr
CreateAsyncInferRequestImpl(InferenceEngine::InputsDataMap networkInputs,
InferenceEngine::OutputsDataMap networkOutputs) override {
@ -58,5 +66,18 @@ class GNAExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSafe
void ExportImpl(std::ostream&) override {
THROW_IE_EXCEPTION << NOT_IMPLEMENTED_str;
}
void GetConfig(const std::string &name,
InferenceEngine::Parameter &result,
InferenceEngine::ResponseDesc* /*resp*/) const override {
result = plg->GetConfig(name, {});
}
void GetMetric(const std::string& name,
InferenceEngine::Parameter& result,
InferenceEngine::ResponseDesc* /* resp */) const override {
result = plg->GetMetric(name, {});
}
};
} // namespace GNAPluginNS

View File

@ -34,6 +34,7 @@
#include "layers/gna_concat_layer.hpp"
#include "layers/gna_crop_layer.hpp"
#include "round_float_define.hpp"
#include "gna_plugin_policy.hpp"
using namespace InferenceEngine;
using namespace std;
@ -58,6 +59,10 @@ void GNAGraphCompiler::setGNAFlagsPtr(std::shared_ptr<GNAPluginNS::GNAFlags> gna
this->gnaFlags = std::move(gnaFlagsPtr);
}
void GNAGraphCompiler::setPolicy(GNAPluginNS::Policy policyToSet) {
this->policy = policyToSet;
}
intel_dnn_component_t * GNAGraphCompiler::find_first_unused_input(InferenceEngine::CNNLayerPtr current) {
if (current->insData.empty())
return nullptr;
@ -987,13 +992,57 @@ void GNAGraphCompiler::ConcatAlignFilterPrimitive(InferenceEngine::CNNLayerPtr l
auto outputs = *layer->outData.begin();
auto inputs = layer->insData.begin()->lock();
// auto offset = filterLayer->GetParamAsInt("output_offset");
uint32_t num_columns_in = FROM_IR_DIM(inputs, 2);
uint32_t num_rows_out = FROM_IR_DIM(outputs, 1);
uint32_t num_rows_in = filterLayer->_weights->size() / num_rows_out;
uint32_t num_padding = ALIGN(num_rows_in, 8) - num_rows_in;
auto numRowsPadded = filterLayer->GetParamAsInt("num_rows_padded");
// number of rows we handled by inserting copy layer
uint32_t num_rows_copied = 0;
// in case of left alignment succeed, but due to number of elements not multiple of 8 we need to insert align_filter
// we are improving it by inserting copy layer of size that covers most of elements - remained max of 32x31 affine filter
if (policy.ConcatAlignmentPolicy == Policy::ConcatAlignment::FAST && 0 == numRowsPadded && ALIGN(num_rows_in, 32) > 32) {
// can we use copy at all
num_rows_copied = ALIGN(num_rows_in, 32) - 32;
auto orientation = kDnnInterleavedOrientation;
auto& copyComponent = dnnComponents.addComponent(layer->name + "_synthetic_copy", "copy");
dnn->InitCopyComponent(copyComponent,
orientation,
num_rows_copied,
num_columns_in,
num_rows_copied,
num_columns_in,
inputs->getPrecision().size(),
inputs->getPrecision().size(),
quantized == nullptr ? 1 : quantized->_dst_quant.scale,
num_rows_copied,
num_columns_in,
ptr_inputs,
ptr_outputs);
size_t num_data_bytes_in = num_rows_copied * num_rows_copied * num_columns_in
* inputs->getPrecision().size();
// need to reserve full tensor so using original size with assumption of identity activation attached to filter lateron
size_t num_data_bytes_out = num_rows_out * num_columns_in * inputs->getPrecision().size();
connectInput(layer, ptr_inputs, num_data_bytes_in);
auto isNonFunctional = [](CNNLayerPtr l) {
return LayerInfo(l).isNonFunctional();
};
auto identity = CNNNetGetNextLayerSkipCertain(layer, 0, 0, isNonFunctional);
connectOutput(identity.first, ptr_outputs, num_data_bytes_out);
num_rows_in -= num_rows_copied;
num_rows_out -= num_rows_copied;
}
filterLayer->params["rows_copied_offset"] = std::to_string(num_rows_copied * inputs->getPrecision().size());
auto biasPrecision = filterLayer->_biases ? filterLayer->_biases->getTensorDesc().getPrecision() : outputs->getPrecision();
auto& currentComponent = dnnComponents.addComponent(layer->name, "affine");
@ -1013,35 +1062,36 @@ void GNAGraphCompiler::ConcatAlignFilterPrimitive(InferenceEngine::CNNLayerPtr l
ptr_biases,
false);
size_t num_data_bytes_out =
InferenceEngine::details::product(
begin(outputs->getDims()), end(outputs->getDims())) * 4;
size_t num_data_bytes_out = num_rows_out * num_columns_in * outputs->getPrecision().size();
size_t num_data_bytes_in = num_columns_in *
ALIGN(num_rows_in, 8) * inputs->getPrecision().size();
connectInput(layer, ptr_inputs, num_data_bytes_in, 0, 0);
connectInput(layer, ptr_inputs, num_data_bytes_in, num_rows_copied * inputs->getPrecision().size(), 0);
connectOutput(layer, ptr_outputs, num_data_bytes_out);
if (num_padding == 0) {
gnamem->readonly().push_ptr(ptr_weights,
filterLayer->_weights->cbuffer().as<const void*>(),
filterLayer->_weights->byteSize(),
64);
} else {
{
auto weightsElementSize = filterLayer->_weights->getTensorDesc().getPrecision().size();
auto elementsIn = (num_rows_in + num_padding) * num_columns_in;
auto paddedWeights = elementsIn * num_rows_out;
auto paddedWeightsSize = paddedWeights * filterLayer->precision.size();
auto paddedWeightsSize = paddedWeights * weightsElementSize;
// TODO: this can be improved to not generate unneeded weights at all
size_t weights_stride = (num_rows_in + num_rows_copied) * weightsElementSize;
size_t weights_offset = weights_stride * num_rows_copied + num_rows_copied * weightsElementSize;
gnamem->readonly().push_initializer(ptr_weights, paddedWeightsSize, [=](void* data, size_t size) {
size_t offset = 0;
for (int i = 0; i < num_rows_out && size >= offset; i++) {
ie_memcpy(reinterpret_cast<uint8_t*>(data) + offset, size - offset,
filterLayer->_weights->cbuffer().as<const uint8_t*>() + num_rows_in * i * filterLayer->precision.size(),
num_rows_in* filterLayer->precision.size());
offset += (num_rows_in + num_padding) * filterLayer->precision.size();
size_t roffset = weights_offset;
size_t woffset = 0;
for (int i = 0; i < num_rows_out && size >= woffset; i++) {
ie_memcpy(reinterpret_cast<uint8_t*>(data) + woffset,
size - woffset,
filterLayer->_weights->cbuffer().as<const uint8_t*>() + roffset,
num_rows_in * weightsElementSize);
roffset += weights_stride;
woffset += elementsIn * weightsElementSize;
}
}, 64);
}, 64);
}
if (filterLayer->_biases) {
@ -1189,11 +1239,18 @@ void GNAGraphCompiler::PWLPrimitive(InferenceEngine::CNNLayerPtr layer) {
num_rows = FROM_IR_DIM(inputs, 1);
}
size_t num_data_bytes_out = InferenceEngine::details::product(begin(outputs->getDims()), end(outputs->getDims()))
* outputs->getPrecision().size();
// TODO: solve this by layer level transformations
auto concatAlignFilter = CNNNetPrevLayer(layer, 0);
if (LayerInfo(concatAlignFilter).isConcatAlignFilter()) {
auto rowsCopiedOffset = concatAlignFilter->GetParamAsInt("rows_copied_offset");
if (rowsCopiedOffset != 0) {
num_rows -= rowsCopiedOffset / outputs->getPrecision().size();
layer->params["output_offset"] = std::to_string(rowsCopiedOffset);
}
}
size_t num_data_bytes_in = InferenceEngine::details::product(begin(inputs->getDims()), end(inputs->getDims()))
* inputs->getPrecision().size();
size_t num_data_bytes_out = num_columns * num_rows * outputs->getPrecision().size();
size_t num_data_bytes_in = num_columns * num_rows * inputs->getPrecision().size();
static InferenceEngine::details::caseless_unordered_map<std::string, DnnActivationType> supportedActivations = {
{"sigmoid", kActSigmoid},
@ -1626,7 +1683,7 @@ GNAPluginNS::ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer,
if (it != splitLayerInfoItem.splitOutputLayers.end()) {
gnalog() << "Connecting " << splitName << " input \n";
auto res = connectInput(splittingLayer, ptr, splitLayerInfoItem.reserved_size, it->offset, 0);
auto res = connectInput(splittingLayer, ptr, splitLayerInfoItem.reserved_size, it->offset + offset, 0);
gnalog() << "Connected \n";
return res;
}

View File

@ -26,6 +26,7 @@
#include "backend/am_intel_dnn.hpp"
#include "gna_device.hpp"
#include "gna_data_types.hpp"
#include "gna_plugin_policy.hpp"
namespace GNAPluginNS {
class GNAGraphCompiler {
@ -34,6 +35,7 @@ private:
std::shared_ptr<GNAPluginNS::gna_memory_type> gnamem;
std::shared_ptr<GNAPluginNS::InputDesc> inputDesc;
std::shared_ptr<GNAPluginNS::GNAFlags> gnaFlags;
Policy policy;
// layers with extra storage for connections and additional
// non trivial processing
@ -53,6 +55,7 @@ public:
void setDNNPtr(std::shared_ptr<GNAPluginNS::backend::AMIntelDNN> dnnPtr);
void setInputDescPtr(std::shared_ptr<GNAPluginNS::InputDesc> inputDescPtr);
void setGNAFlagsPtr(std::shared_ptr<GNAPluginNS::GNAFlags> gnaFlagsPtr);
void setPolicy(GNAPluginNS::Policy policy);
void fillMemoryConnections(std::unordered_map<std::string,
std::vector<InferenceEngine::CNNLayerPtr>> &memoryPairs);

View File

@ -237,7 +237,6 @@ void GNAModelSerial::Export(void * basePointer, size_t gnaGraphSize, std::ostrea
auto convert_to_serial = [getOffsetFromBase](const GNAModelSerial::RuntimeEndPoint& ep) {
ModelHeader::EndPoint out;
out.elements_count = ep.elements_count;
out.element_size = ep.element_size;
out.descriptor_offset = offsetFromBase(ep.descriptor_ptr);
out.scaleFactor = ep.scaleFactor;
return out;

View File

@ -22,6 +22,7 @@
#include <graph_tools.hpp>
#include <debug.h>
#include <gna/gna_config.hpp>
#include "gna_plugin_config.hpp"
#include <ie_util_internal.hpp>
#include "gna_plugin.hpp"
#include "optimizer/gna_pass_manager.hpp"
@ -302,6 +303,7 @@ void GNAPlugin::ImportFrames(
GNAPlugin::GNAPlugin() {
Init();
UpdateFieldsFromConfig();
}
GNAPlugin::GNAPlugin(const std::map<std::string, std::string>& configMap) {
@ -321,13 +323,13 @@ void GNAPlugin::Init() {
void GNAPlugin::InitGNADevice() {
#if GNA_LIB_VER == 1
gnadevice = std::make_shared<GNADeviceHelper>(gna_proc_type,
gnadevice = std::make_shared<GNADeviceHelper>(config.gna_proc_type,
gnaFlags->gna_lib_async_threads_num,
gnaFlags->gna_openmp_multithreading,
gnaFlags->performance_counting);
#else
gnadevice = std::make_shared<GNADeviceHelper>(pluginGna2AccMode,
pluginGna2DeviceConsistent,
gnadevice = std::make_shared<GNADeviceHelper>(config.pluginGna2AccMode,
config.pluginGna2DeviceConsistent,
gnaFlags->gna_lib_async_threads_num,
gnaFlags->gna_openmp_multithreading,
gnaFlags->performance_counting);
@ -387,7 +389,7 @@ void GNAPlugin::LoadNetwork(ICNNNetwork &network) {
run_passes(newNet, true);
run_passes(newNet, false);
} else {
switch (gnaPrecision) {
switch (config.gnaPrecision) {
case Precision::I16:
ModelQuantizer<QuantI16> q16;
newNet = q16.quantize(network, run_passes, inputsDesc->inputScaleFactors);
@ -421,6 +423,9 @@ void GNAPlugin::LoadNetwork(ICNNNetwork &network) {
auto sortedNet = CNNNetSortTopologicallyEx(*newNet, make_fuzed_order);
// passing policy to compiler
graphCompiler.setPolicy(policy);
if (sortedNet.empty()) {
THROW_GNA_EXCEPTION << "Sorted network is empty";
}
@ -534,10 +539,33 @@ void GNAPlugin::LoadNetwork(ICNNNetwork &network) {
gnalog() << "[UFS] from : "<< outPort.first <<" reached: " << layer->name << "\n";
// probing gna_primitives
if (irLayerAvatar != graphCompiler.dnnComponents.components.end()) {
initOutput(portId, irLayerAvatar->second, layer);
stopSearching = true;
}
// probing concatInfo
if (!stopSearching && LayerInfo(layer).isConcat()) {
auto concatConnection = graphCompiler.concat_connection.find(layer->name);
if (concatConnection != graphCompiler.concat_connection.end()) {
//initOutput(portId, irLayerAvatar->second, layer);
auto &desc = outputsDesc[portId];
auto quantized = InferenceEngine::getInjectedData<QuantizedLayerParams>(layer);
desc.ptrs.resize(gnaFlags->gna_lib_async_threads_num);
// TODO: what is orientation for concat
desc.orientation = kDnnInterleavedOrientation;
desc.num_bytes_per_element = layer->outData.front()->getPrecision().size();
desc.scale_factor = quantized != nullptr ? quantized->_dst_quant.scale : 1.0f;
desc.num_elements = concatConnection->second.reserved_size / desc.num_bytes_per_element;
// binding ptr for first infer request - then others will be setup during relocation
gnamem->bind_ptr(&desc.ptrs.front(), &concatConnection->second.gna_ptr);
stopSearching = true;
}
}
}, true, [&stopSearching](InferenceEngine::CNNLayer* from) {
return make_upstream_order(!stopSearching ? from : nullptr);
});
@ -722,20 +750,20 @@ void GNAPlugin::createRequestConfigsForGnaModels() {
void GNAPlugin::DumpXNNToFile() const {
// TODO: output precision as well as pointer might be incorrect, LSTM for sure
// gna looks automatically set layer 0 as output and adjust it's pointer / precision/ size respectively
if (dumpXNNPath.empty()) {
if (config.dumpXNNPath.empty()) {
return;
}
if (dumpXNNGeneration != "GNA1" &&
dumpXNNGeneration != "GNA3" &&
!dumpXNNGeneration.empty()) {
THROW_GNA_EXCEPTION << "Wrong GNA generation for embedded model dump: " << dumpXNNGeneration;
if (config.dumpXNNGeneration != "GNA1" &&
config.dumpXNNGeneration != "GNA3" &&
!config.dumpXNNGeneration.empty()) {
THROW_GNA_EXCEPTION << "Wrong GNA generation for embedded model dump: " << config.dumpXNNGeneration;
}
if (!gnadevice) {
THROW_GNA_EXCEPTION << "Cannot generate XNNDump for float network";
}
std::ofstream dumpStream(dumpXNNPath, std::ios::out | std::ios::binary);
std::ofstream dumpStream(config.dumpXNNPath, std::ios::out | std::ios::binary);
#if GNA_LIB_VER == 1
auto dump = gnadevice->dumpXnn(&std::get<0>(nnets.front())->obj, ptr_active_indices, num_active_indices);
dump.header.rw_region_size = gnamem->getRWBytes();
@ -745,7 +773,7 @@ void GNAPlugin::DumpXNNToFile() const {
dumpStream.write(reinterpret_cast<char*>(dump.model.get()), dump.header.model_size);
#else
auto const modelId = gnadevice->createModel(std::get<0>(gnaModels.front())->obj);
if (dumpXNNGeneration != "GNA3") {
if (config.dumpXNNGeneration != "GNA3") {
auto dump = gnadevice->dumpXnn(modelId);
dump.header.RwRegionSize = gnamem->getRWBytes();
dump.header.InputScalingFactor = inputsDesc->inputScaleFactors.front();
@ -1204,228 +1232,14 @@ void GNAPlugin::GetPerformanceCounts(std::map<std::string, InferenceEngine::Infe
void GNAPlugin::AddExtension(InferenceEngine::IExtensionPtr extension) {}
void GNAPlugin::SetConfig(const std::map<std::string, std::string> &config) {
Init();
auto supportedConfigOptions = supportedConfigKeys();
void GNAPlugin::SetConfig(const std::map<std::string, std::string> &config_map) {
config.UpdateFromMap(config_map);
UpdateFieldsFromConfig();
}
for (auto& item : config) {
auto keys = std::find_if(supportedConfigOptions.begin(), supportedConfigOptions.end(), [&item](const std::string& supportedConfigOption) {
return item.first == supportedConfigOption ||
item.first.find(GNA_CONFIG_KEY(SCALE_FACTOR)) == 0;
});
if (keys == supportedConfigOptions.end()) {
THROW_GNA_EXCEPTION << as_status << NOT_FOUND << "Incorrect GNA Plugin config. Key " << item.first << " not supported";
}
}
// holds actual value of a found key
std::string key;
std::string value;
auto if_set = [&](const std::string& keyInput, const std::function<void()> & handler) {
auto keyInMap = config.find(keyInput);
if (keyInMap != config.end()) {
value = keyInMap->second;
handler();
}
};
auto if_start = [&](const std::string& keyInput, const std::function<void()> & handler) {
for (auto && c : config) {
if (c.first.find(keyInput) == 0) {
if (c.first.size() > keyInput.size() + 1) {
key = c.first.substr(keyInput.size() + 1);
value = c.second;
handler();
}
}
}
};
auto fp32eq = [](float p1, float p2) -> bool {
return (std::abs(p1 - p2) <= 0.00001f * std::min(std::abs(p1), std::abs(p2)));
};
auto & log = gnalog();
if_start(GNA_CONFIG_KEY(SCALE_FACTOR), [&, this] {
uint64_t scaleForInput = std::stoul(key, NULL, 10);
if (scaleForInput > 10) {
THROW_GNA_EXCEPTION << "input scale factor with index(" << key << ") unsupported";
}
auto scaleFactor = std::stod(value);
if (fp32eq(scaleFactor, 0.0f)) {
THROW_GNA_EXCEPTION << "input scale factor of 0.0f not supported";
}
// not appeared scale factors are to be 1.0f
if (inputsDesc->inputScaleFactors.size() <= scaleForInput) {
inputsDesc->inputScaleFactors.resize(scaleForInput + 1, 1.f);
}
inputsDesc->inputScaleFactors[scaleForInput] = InferenceEngine::CNNLayer::ie_parse_float(value);
});
if (inputsDesc->inputScaleFactors.empty()) {
if_set(GNA_CONFIG_KEY(SCALE_FACTOR), [&] {
auto scaleFactor = InferenceEngine::CNNLayer::ie_parse_float(value);
if (fp32eq(scaleFactor, 0.0f)) {
THROW_GNA_EXCEPTION << "input scale factor of 0.0f not supported";
}
inputsDesc->inputScaleFactors.push_back(scaleFactor);
});
}
if (inputsDesc->inputScaleFactors.empty()) {
inputsDesc->inputScaleFactors.push_back(1.f);
}
if_set(GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE), [&] {
dumpXNNPath = value;
});
if_set(GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION), [&] {
dumpXNNGeneration = value;
});
if_set(GNA_CONFIG_KEY(DEVICE_MODE), [&] {
#if GNA_LIB_VER == 1
static caseless_unordered_map <std::string, uint32_t> supported_values = {
{GNAConfigParams::GNA_AUTO, GNA_AUTO},
{GNAConfigParams::GNA_HW, GNA_HARDWARE},
{GNAConfigParams::GNA_SW, GNA_SOFTWARE},
{GNAConfigParams::GNA_SW_EXACT, GNA_SOFTWARE & GNA_HARDWARE}
};
static std::vector <std::string> supported_values_on_gna2 = {
GNAConfigParams::GNA_GEN,
GNAConfigParams::GNA_GEN_EXACT,
GNAConfigParams::GNA_SSE,
GNAConfigParams::GNA_SSE_EXACT,
GNAConfigParams::GNA_AVX1,
GNAConfigParams::GNA_AVX1_EXACT,
GNAConfigParams::GNA_AVX2,
GNAConfigParams::GNA_AVX2_EXACT
};
#else
static caseless_unordered_map <std::string, std::pair<Gna2AccelerationMode, Gna2DeviceVersion> > supported_values = {
{GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, Gna2DeviceVersion1_0}},
};
#endif
auto procType = supported_values.find(value);
if (procType == supported_values.end()) {
if (value == GNA_CONFIG_VALUE(SW_FP32)) {
gnaFlags->sw_fp32 = true;
} else {
#if GNA_LIB_VER == 1
auto is_gna2_mode = std::find(
supported_values_on_gna2.begin(),
supported_values_on_gna2.end(),
value);
if (is_gna2_mode != supported_values_on_gna2.end()) {
THROW_GNA_EXCEPTION << "This GNA device mode require GNA2 library: " << value;
}
#endif
THROW_GNA_EXCEPTION << "GNA device mode unsupported: " << value;
}
} else {
#if GNA_LIB_VER == 1
gna_proc_type = static_cast<intel_gna_proc_t>(procType->second);
#else
pluginGna2AccMode = procType->second.first;
pluginGna2DeviceConsistent = procType->second.second;
#endif
}
});
if_set(GNA_CONFIG_KEY(COMPACT_MODE), [&] {
if (value == PluginConfigParams::YES) {
gnaFlags->compact_mode = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags->compact_mode = false;
} else {
log << "GNA compact mode should be YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "GNA compact mode should be YES/NO, but not" << value;
}
});
if_set(CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), [&] {
if (value == PluginConfigParams::YES) {
gnaFlags->exclusive_async_requests = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags->exclusive_async_requests = false;
} else {
log << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
}
});
if_set(GNA_CONFIG_KEY(PRECISION), [&] {
auto precision = Precision::FromStr(value);
if (precision != Precision::I8 && precision != Precision::I16) {
log << "Unsupported precision of GNA hardware, should be Int16 or Int8, but was: " << value;
THROW_GNA_EXCEPTION << "Unsupported precision of GNA hardware, should be Int16 or Int8, but was: " << value;
}
gnaPrecision = precision;
});
if_set(GNA_CONFIG_KEY(PWL_UNIFORM_DESIGN), [&] {
if (value == PluginConfigParams::YES) {
gnaFlags->uniformPwlDesign = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags->uniformPwlDesign = false;
} else {
log << "GNA pwl uniform algorithm parameter "
<< "should be equal to YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "GNA pwl uniform algorithm parameter "
<< "should be equal to YES/NO, but not" << value;
}
});
if_set(CONFIG_KEY(PERF_COUNT), [&] {
if (value == PluginConfigParams::YES) {
gnaFlags->performance_counting = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags->performance_counting = false;
} else {
log << "GNA performance counter enabling parameter "
<< "should be equal to YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "GNA performance counter enabling parameter "
<< "should be equal to YES/NO, but not" << value;
}
});
if_set(GNA_CONFIG_KEY(LIB_N_THREADS), [&] {
uint64_t lib_threads = std::stoul(value, NULL, 10);
if (lib_threads == 0 || lib_threads > std::numeric_limits<uint8_t>::max()/2-1) {
log << "Unsupported accelerator lib number of threads: " << value << ", should be greateer than 0 and less than 127";
THROW_GNA_EXCEPTION << "Unsupported accelerator lib number of threads: " << value
<< ", should be greateer than 0 and less than 127";
}
gnaFlags->gna_lib_async_threads_num = lib_threads;
});
if_set(CONFIG_KEY(SINGLE_THREAD), [&] {
if (value == PluginConfigParams::YES) {
gnaFlags->gna_openmp_multithreading = false;
} else if (value == PluginConfigParams::NO) {
gnaFlags->gna_openmp_multithreading = true;
} else {
log << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
}
});
if (gnaFlags->sw_fp32 && gnaFlags->gna_lib_async_threads_num > 1) {
THROW_GNA_EXCEPTION << "GNA plugin not support async mode on GNA_SW_FP32!";
}
void GNAPlugin::UpdateFieldsFromConfig() {
inputsDesc->inputScaleFactors = config.inputScaleFactors;
*gnaFlags = config.gnaFlags;
}
void GNAPlugin::QueryNetwork(const InferenceEngine::ICNNNetwork& network,

View File

@ -22,6 +22,7 @@
#include "gna_graph_compiler.hpp"
#include "gna_plugin_policy.hpp"
#include "gna_plugin_log.hpp"
#include "gna_plugin_config.hpp"
#if GNA_LIB_VER == 2
#include <gna2-model-api.h>
@ -32,6 +33,7 @@ class GNAPlugin : public InferenceEngine::IInferencePluginInternal, public std::
protected:
std::string _pluginName = "GNA";
Config config;
std::shared_ptr<GNAPluginNS::backend::AMIntelDNN> dnn;
std::shared_ptr<GNAPluginNS::GNAFlags> gnaFlags;
std::shared_ptr<GNAPluginNS::gna_memory_type> gnamem;
@ -63,20 +65,12 @@ class GNAPlugin : public InferenceEngine::IInferencePluginInternal, public std::
// index matches iterating order of cnnnetwork outputs info
std::vector<GNAPluginNS::OutputDesc> outputsDesc = std::vector<OutputDesc>();
// precision of GNA hardware model
InferenceEngine::Precision gnaPrecision = InferenceEngine::Precision::I16;
intel_dnn_number_type_t output_type = kDnnInt;
GNAPluginNS::Policy policy;
std::string dumpXNNPath;
std::string dumpXNNGeneration;
#if GNA_LIB_VER == 1
intel_gna_proc_t gna_proc_type = static_cast<intel_gna_proc_t>(GNA_SOFTWARE & GNA_HARDWARE);
#else
Gna2AccelerationMode pluginGna2AccMode = Gna2AccelerationModeSoftware;
Gna2DeviceVersion pluginGna2DeviceConsistent = Gna2DeviceVersion1_0;
void createRequestConfigsForGnaModels();
#if GNA_LIB_VER == 2
void createRequestConfigsForGnaModels();
#endif
std::shared_ptr<GNADeviceHelper> gnadevice;
@ -104,15 +98,12 @@ void createRequestConfigsForGnaModels();
void GetPerformanceCounts(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> &perfMap);
void AddExtension(InferenceEngine::IExtensionPtr extension) override;
std::vector<std::string> supportedConfigKeys() const;
std::map<std::string, std::string> supportedConfigKeysWithDefaults() const;
void SetConfig(const std::map<std::string, std::string> &config) override;
void LoadNetwork(InferenceEngine::IExecutableNetwork::Ptr &executableNetwork,
const InferenceEngine::ICNNNetwork &network,
const std::map<std::string, std::string> &config) override { THROW_GNA_EXCEPTION << "Not implemented"; }
const std::map<std::string, std::string> &config_map) override { THROW_GNA_EXCEPTION << "Not implemented"; }
InferenceEngine::ExecutableNetwork LoadNetwork(const InferenceEngine::ICNNNetwork &network,
const std::map<std::string, std::string> &config,
const std::map<std::string, std::string> &config_map,
InferenceEngine::RemoteContext::Ptr context) override { THROW_GNA_EXCEPTION << "Not implemented"; }
void Infer(const InferenceEngine::Blob &input, InferenceEngine::Blob &result);
void SetCore(InferenceEngine::ICore*) noexcept override {}
@ -221,5 +212,8 @@ void createRequestConfigsForGnaModels();
const GNASplitLayer& splitInfo,
size_t precision_size,
int idx = 0);
void UpdateFieldsFromConfig();
};
} // namespace GNAPluginNS

View File

@ -0,0 +1,278 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gna/gna_config.hpp>
#include "gna_plugin.hpp"
#include "gna_plugin_config.hpp"
#include "ie_common.h"
#include <details/caseless.hpp>
#include <unordered_map>
using namespace InferenceEngine;
using namespace InferenceEngine::details;
namespace GNAPluginNS {
#if GNA_LIB_VER == 1
static caseless_unordered_map<std::string, uint32_t> supported_values = {
{GNAConfigParams::GNA_AUTO, GNA_AUTO},
{GNAConfigParams::GNA_HW, GNA_HARDWARE},
{GNAConfigParams::GNA_SW, GNA_SOFTWARE},
{GNAConfigParams::GNA_SW_EXACT, GNA_SOFTWARE & GNA_HARDWARE}
};
static std::vector<std::string> supported_values_on_gna2 = {
GNAConfigParams::GNA_GEN,
GNAConfigParams::GNA_GEN_EXACT,
GNAConfigParams::GNA_SSE,
GNAConfigParams::GNA_SSE_EXACT,
GNAConfigParams::GNA_AVX1,
GNAConfigParams::GNA_AVX1_EXACT,
GNAConfigParams::GNA_AVX2,
GNAConfigParams::GNA_AVX2_EXACT
};
#else
static caseless_unordered_map <std::string, std::pair<Gna2AccelerationMode, Gna2DeviceVersion>> supported_values = {
{GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, Gna2DeviceVersion1_0}},
{GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, Gna2DeviceVersionSoftwareEmulation}},
{GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, Gna2DeviceVersion1_0}},
};
#endif
void Config::UpdateFromMap(const std::map<std::string, std::string>& config) {
for (auto&& item : config) {
auto key = item.first;
auto value = item.second;
auto fp32eq = [](float p1, float p2) -> bool {
return (std::abs(p1 - p2) <= 0.00001f * std::min(std::abs(p1), std::abs(p2)));
};
auto &log = gnalog();
if (key.find(GNA_CONFIG_KEY(SCALE_FACTOR)) == 0) {
uint64_t input_index;
if (key == GNA_CONFIG_KEY(SCALE_FACTOR)) {
input_index = 0;
} else {
key.erase(0, strlen(GNA_CONFIG_KEY(SCALE_FACTOR)));
if (key[0] != '_') {
THROW_GNA_EXCEPTION << "Invalid format of scale factor configuration key";
}
key.erase(0, 1);
try {
input_index = std::stoi(key);
if (input_index < 0 | input_index > 9) {
throw std::out_of_range("");
}
} catch (std::invalid_argument&) {
THROW_GNA_EXCEPTION << "Invalid value of index of input scale factor";
} catch (std::out_of_range&) {
THROW_GNA_EXCEPTION << "Index of input scale factor must be in the range [0..9], " << value << " provided";
}
}
auto scale_factor = InferenceEngine::CNNLayer::ie_parse_float(value);
if (fp32eq(scale_factor, 0.0f)) {
THROW_GNA_EXCEPTION << "input scale factor of 0.0f not supported";
}
// missing scale factors are set to be 1.0f
if (inputScaleFactors.size() <= input_index) {
inputScaleFactors.resize(input_index + 1, 1.f);
}
inputScaleFactors[input_index] = InferenceEngine::CNNLayer::ie_parse_float(value);
} else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE)) {
dumpXNNPath = value;
} else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)) {
dumpXNNGeneration = value;
} else if (key == GNA_CONFIG_KEY(DEVICE_MODE)) {
auto procType = supported_values.find(value);
if (procType == supported_values.end()) {
if (value == GNA_CONFIG_VALUE(SW_FP32)) {
gnaFlags.sw_fp32 = true;
} else {
#if GNA_LIB_VER == 1
auto is_gna2_mode = std::find(
supported_values_on_gna2.begin(),
supported_values_on_gna2.end(),
value);
if (is_gna2_mode != supported_values_on_gna2.end()) {
THROW_GNA_EXCEPTION << "This GNA device mode requires GNA2 library: " << value;
}
#endif
THROW_GNA_EXCEPTION << "GNA device mode unsupported: " << value;
}
} else {
#if GNA_LIB_VER == 1
gna_proc_type = static_cast<intel_gna_proc_t>(procType->second);
#else
pluginGna2AccMode = procType->second.first;
pluginGna2DeviceConsistent = procType->second.second;
#endif
}
} else if (key == GNA_CONFIG_KEY(COMPACT_MODE)) {
if (value == PluginConfigParams::YES) {
gnaFlags.compact_mode = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags.compact_mode = false;
} else {
log << "GNA compact mode should be YES/NO, but not " << value;
THROW_GNA_EXCEPTION << "GNA compact mode should be YES/NO, but not " << value;
}
} else if (key == CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)) {
if (value == PluginConfigParams::YES) {
gnaFlags.exclusive_async_requests = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags.exclusive_async_requests = false;
} else {
log << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
}
} else if (key == GNA_CONFIG_KEY(PRECISION)) {
auto precision = Precision::FromStr(value);
if (precision != Precision::I8 && precision != Precision::I16) {
log << "Unsupported precision of GNA hardware, should be Int16 or Int8, but was: " << value;
THROW_GNA_EXCEPTION << "Unsupported precision of GNA hardware, should be Int16 or Int8, but was: "
<< value;
}
gnaPrecision = precision;
} else if (key == GNA_CONFIG_KEY(PWL_UNIFORM_DESIGN)) {
if (value == PluginConfigParams::YES) {
gnaFlags.uniformPwlDesign = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags.uniformPwlDesign = false;
} else {
log << "GNA pwl uniform algorithm parameter "
<< "should be equal to YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "GNA pwl uniform algorithm parameter "
<< "should be equal to YES/NO, but not" << value;
}
} else if (key == CONFIG_KEY(PERF_COUNT)) {
if (value == PluginConfigParams::YES) {
gnaFlags.performance_counting = true;
} else if (value == PluginConfigParams::NO) {
gnaFlags.performance_counting = false;
} else {
log << "GNA performance counter enabling parameter "
<< "should be equal to YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "GNA performance counter enabling parameter "
<< "should be equal to YES/NO, but not" << value;
}
} else if (key == GNA_CONFIG_KEY(LIB_N_THREADS)) {
uint64_t lib_threads;
try {
lib_threads = std::stoul(value);
if (lib_threads == 0 || lib_threads > (std::numeric_limits<uint8_t>::max()+1) / 2 - 1) {
throw std::out_of_range("");
}
} catch (std::invalid_argument&) {
THROW_GNA_EXCEPTION << "Invalid value of number of threads";
} catch (std::out_of_range&) {
log << "Unsupported accelerator lib number of threads: " << value
<< ", should be greater than 0 and less than 127";
THROW_GNA_EXCEPTION << "Unsupported accelerator lib number of threads: " << value
<< ", should be greater than 0 and less than 127";
}
gnaFlags.gna_lib_async_threads_num = lib_threads;
} else if (key == CONFIG_KEY(SINGLE_THREAD)) {
if (value == PluginConfigParams::YES) {
gnaFlags.gna_openmp_multithreading = false;
} else if (value == PluginConfigParams::NO) {
gnaFlags.gna_openmp_multithreading = true;
} else {
log << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
THROW_GNA_EXCEPTION << "EXCLUSIVE_ASYNC_REQUESTS should be YES/NO, but not" << value;
}
} else {
THROW_GNA_EXCEPTION << as_status << NOT_FOUND << "Incorrect GNA Plugin config. Key " << item.first
<< " not supported";
}
if (gnaFlags.sw_fp32 && gnaFlags.gna_lib_async_threads_num > 1) {
THROW_GNA_EXCEPTION << "GNA plugin does not support async mode on GNA_SW_FP32!";
}
}
if (inputScaleFactors.empty()) {
inputScaleFactors.push_back(1.0f);
}
AdjustKeyMapValues();
}
void Config::AdjustKeyMapValues() {
key_config_map.clear();
if (inputScaleFactors.empty()) {
inputScaleFactors.push_back(1.0);
}
key_config_map[GNA_CONFIG_KEY(SCALE_FACTOR)] = std::to_string(inputScaleFactors[0]);
for (int n = 0; n < inputScaleFactors.size(); n++) {
key_config_map[GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_") + std::to_string(n)] =
std::to_string(inputScaleFactors[n]);
}
key_config_map[GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE)] = dumpXNNPath;
key_config_map[GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)] = dumpXNNGeneration;
std::string device_mode;
if (gnaFlags.sw_fp32) {
device_mode = GNA_CONFIG_VALUE(SW_FP32);
} else {
for (auto&& value : supported_values) {
#if GNA_LIB_VER == 1
if (value.second == gna_proc_type) {
device_mode = value.first;
break;
}
#else
if (value.second.first == pluginGna2AccMode &&
value.second.second == pluginGna2DeviceConsistent) {
device_mode = value.first;
break;
}
#endif
}
}
IE_ASSERT(!device_mode.empty());
key_config_map[GNA_CONFIG_KEY(DEVICE_MODE)] = device_mode;
key_config_map[GNA_CONFIG_KEY(COMPACT_MODE)] =
gnaFlags.compact_mode ? PluginConfigParams::YES: PluginConfigParams::NO;
key_config_map[CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)] =
gnaFlags.exclusive_async_requests ? PluginConfigParams::YES: PluginConfigParams::NO;
key_config_map[GNA_CONFIG_KEY(PRECISION)] = gnaPrecision.name();
key_config_map[CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)] =
gnaFlags.exclusive_async_requests ? PluginConfigParams::YES: PluginConfigParams::NO;
key_config_map[GNA_CONFIG_KEY(PWL_UNIFORM_DESIGN)] =
gnaFlags.uniformPwlDesign ? PluginConfigParams::YES: PluginConfigParams::NO;
key_config_map[CONFIG_KEY(PERF_COUNT)] =
gnaFlags.performance_counting ? PluginConfigParams::YES: PluginConfigParams::NO;
key_config_map[GNA_CONFIG_KEY(LIB_N_THREADS)] = std::to_string(gnaFlags.gna_lib_async_threads_num);
key_config_map[CONFIG_KEY(SINGLE_THREAD)] =
gnaFlags.gna_openmp_multithreading ? PluginConfigParams::NO: PluginConfigParams::YES;
}
std::string Config::GetParameter(const std::string& name) const {
auto result = key_config_map.find(name);
if (result == key_config_map.end()) {
THROW_GNA_EXCEPTION << "Unsupported config key: " << name;
}
return result->second;
}
std::vector<std::string> Config::GetSupportedKeys() const {
std::vector<std::string> result;
for (auto&& configOption : key_config_map) {
result.push_back(configOption.first);
}
return result;
}
} // namespace GNAPluginNS

View File

@ -0,0 +1,48 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#if GNA_LIB_VER == 1
#include <gna-api.h>
#else
#include <gna2-inference-api.h>
#include <gna2-common-api.h>
#endif
#include "ie_precision.hpp"
#include "descriptions/gna_flags.hpp"
#include <vector>
#include <map>
namespace GNAPluginNS {
struct Config {
Config() {
AdjustKeyMapValues();
}
void UpdateFromMap(const std::map<std::string, std::string>& configMap);
void AdjustKeyMapValues();
std::string GetParameter(const std::string& name) const;
std::vector<std::string> GetSupportedKeys() const;
// precision of GNA hardware model
InferenceEngine::Precision gnaPrecision = InferenceEngine::Precision::I16;
std::string dumpXNNPath;
std::string dumpXNNGeneration;
#if GNA_LIB_VER == 1
intel_gna_proc_t gna_proc_type = static_cast<intel_gna_proc_t>(GNA_SOFTWARE & GNA_HARDWARE);
#else
Gna2AccelerationMode pluginGna2AccMode = Gna2AccelerationModeSoftware;
Gna2DeviceVersion pluginGna2DeviceConsistent = Gna2DeviceVersion1_0;
#endif
std::vector<float> inputScaleFactors;
GNAFlags gnaFlags;
std::map<std::string, std::string> key_config_map;
};
} // namespace GNAPluginNS

View File

@ -10,36 +10,58 @@
#include <cpp_interfaces/impl/ie_plugin_internal.hpp>
#include <cpp_interfaces/impl/ie_executable_network_internal.hpp>
#include "gna_executable_network.hpp"
#include "gna_plugin_config.hpp"
namespace GNAPluginNS {
class GNAPluginInternal : public InferenceEngine::InferencePluginInternal {
public:
private:
Config defaultConfig;
std::weak_ptr <GNAPlugin> plgPtr;
std::shared_ptr<GNAPlugin> GetCurrentPlugin() const {
auto ptr = plgPtr.lock();
if (ptr == nullptr) {
return std::make_shared<GNAPlugin>();
} else {
return ptr;
}
}
public:
InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::ICore * core,
const InferenceEngine::ICNNNetwork &network,
const std::map<std::string, std::string> &config) override {
return std::make_shared<GNAExecutableNetwork>(*cloneNet(network), config);
Config updated_config(defaultConfig);
updated_config.UpdateFromMap(config);
auto plg = std::make_shared<GNAPlugin>(updated_config.key_config_map);
plgPtr = plg;
return std::make_shared<GNAExecutableNetwork>(*cloneNet(network), plg);
}
void SetConfig(const std::map<std::string, std::string> &config) override {
auto plg = std::make_shared<GNAPlugin>();
plg->SetConfig(config);
defaultConfig.UpdateFromMap(config);
}
InferenceEngine::IExecutableNetwork::Ptr ImportNetwork(
const std::string &modelFileName,
const std::map<std::string, std::string> &config) override {
return make_executable_network(std::make_shared<GNAExecutableNetwork>(modelFileName, config));
Config updated_config(defaultConfig);
updated_config.UpdateFromMap(config);
auto plg = std::make_shared<GNAPlugin>(updated_config.key_config_map);
plgPtr = plg;
return make_executable_network(std::make_shared<GNAExecutableNetwork>(modelFileName, plg));
}
using InferenceEngine::InferencePluginInternal::ImportNetwork;
std::string GetName() const noexcept override {
auto plg = std::make_shared<GNAPlugin>();
return plg->GetName();
return GetCurrentPlugin()->GetName();
}
void QueryNetwork(const InferenceEngine::ICNNNetwork& network,
const std::map<std::string, std::string>& config,
InferenceEngine::QueryNetworkResult& res) const override {
auto plg = std::make_shared<GNAPlugin>();
auto plg = GetCurrentPlugin();
try {
plg->SetConfig(config);
} catch (InferenceEngine::details::InferenceEngineException) {}
@ -48,13 +70,11 @@ class GNAPluginInternal : public InferenceEngine::InferencePluginInternal {
InferenceEngine::Parameter GetMetric(const std::string& name,
const std::map<std::string, InferenceEngine::Parameter> & options) const override {
GNAPlugin statelessPlugin;
return statelessPlugin.GetMetric(name, options);
return GetCurrentPlugin()->GetMetric(name, options);
}
InferenceEngine::Parameter GetConfig(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & options) const override {
GNAPlugin statelessPlugin;
return statelessPlugin.GetConfig(name, options);
return defaultConfig.GetParameter(name);
}
};

View File

@ -37,8 +37,9 @@ class Policy {
enum class ConcatAlignment {
DISABLED,
DISABLED_FOR_FP32,
ENABLED
} ConcatAlignmentPolicy = ConcatAlignment::ENABLED;
ENABLED,
FAST
} ConcatAlignmentPolicy = ConcatAlignment::FAST;
};
inline std::ostream& operator<<(std::ostream& os, Policy::ScaleShift policy) {
@ -51,4 +52,16 @@ inline std::ostream& operator<<(std::ostream& os, Policy::ScaleShift policy) {
return os;
}
inline std::ostream& operator<<(std::ostream& os, Policy::ConcatAlignment policy) {
switch (policy) {
case Policy::ConcatAlignment::DISABLED : os << "DISABLED"; break;
case Policy::ConcatAlignment::DISABLED_FOR_FP32 : os << "DISABLED_FOR_FP32"; break;
case Policy::ConcatAlignment::ENABLED : os << "ENABLED"; break;
case Policy::ConcatAlignment::FAST : os << "FAST"; break;
default : os.setstate(std::ios_base::failbit);
}
return os;
}
} // namespace GNAPluginNS

View File

@ -16,19 +16,14 @@ using namespace GNAPluginNS;
using namespace InferenceEngine;
using namespace InferenceEngine::PluginConfigParams;
Parameter GNAPlugin::GetConfig(const std::string& name, const std::map<std::string, Parameter> & options) const {
auto configKeys = supportedConfigKeysWithDefaults();
auto result = configKeys.find(name);
if (result == configKeys.end()) {
THROW_GNA_EXCEPTION << "unsupported config key: " << name;
}
return result->second;
Parameter GNAPlugin::GetConfig(const std::string& name, const std::map<std::string, Parameter> & /*options*/) const {
return config.GetParameter(name);
}
Parameter GNAPlugin::GetMetric(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & options) const {
const std::unordered_map<std::string, std::function<Parameter()>> queryApiSupported = {
{METRIC_KEY(AVAILABLE_DEVICES), [this]() {return GetAvailableDevices();}},
{METRIC_KEY(SUPPORTED_CONFIG_KEYS), [this]() {return supportedConfigKeys();}},
{METRIC_KEY(SUPPORTED_CONFIG_KEYS), [this]() {return config.GetSupportedKeys();}},
{METRIC_KEY(FULL_DEVICE_NAME), [&options, this]() {
auto availableDevices = GetAvailableDevices().as<std::vector<std::string>>();
@ -100,29 +95,3 @@ Parameter GNAPlugin::GetAvailableDevices() const {
return devices;
}
std::map<std::string, std::string> GNAPlugin::supportedConfigKeysWithDefaults() const {
std::map<std::string, std::string> options = {
{GNA_CONFIG_KEY(SCALE_FACTOR), "1.0"},
{GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE), ""},
{GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION), ""},
{GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_AUTO},
{GNA_CONFIG_KEY(COMPACT_MODE), CONFIG_VALUE(NO)},
{CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), CONFIG_VALUE(NO)},
{GNA_CONFIG_KEY(PRECISION), Precision(Precision::I8).name()},
{GNA_CONFIG_KEY(PWL_UNIFORM_DESIGN), CONFIG_VALUE(YES)},
{CONFIG_KEY(PERF_COUNT), CONFIG_VALUE(NO)},
{GNA_CONFIG_KEY(LIB_N_THREADS), "1"},
{CONFIG_KEY(SINGLE_THREAD), CONFIG_VALUE(YES)}
};
return options;
}
std::vector<std::string> GNAPlugin::supportedConfigKeys()const {
std::vector<std::string> result;
for (auto && configOption : supportedConfigKeysWithDefaults()) {
result.push_back(configOption.first);
}
return result;
}

View File

@ -675,6 +675,10 @@ void InsertCopyLayerPass::run() {
void InsertConcatAligningFilterPass::run() {
auto quantized = InferenceEngine::getInjectedData<QuantizedLayerParams>(pLayers->front());
if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED) {
return;
}
// aligning specific not required in fp32 mode
if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED_FOR_FP32 && !quantized) {
return;
@ -740,6 +744,10 @@ void InsertConcatAligningFilterPass::run() {
// encodes offset to beginning of split layer input
concatAligningFilter->params["output_offset"] =
std::to_string((aligned64_offset / bytesPerConcatElement) * (quantized ? bytesPerConcatElement : 4));
// for padded rows we cannot use copy layer - TBD how to implement
concatAligningFilter->params["num_rows_padded"] = std::to_string(num_rows_padded);
// encodes original output size
concatAligningFilter->params["original_num_rows"] = std::to_string(num_rows_in);
@ -1084,7 +1092,7 @@ int PassManager::run(int index) {
saveGraphToDot(*network.get(), out, [](const CNNLayerPtr layer,
ordered_properties &printed_properties,
ordered_properties &node_properties) {});
network->serialize(name + ".xml", "", nullptr);
network->serialize(name + ".xml", name + ".bin", nullptr);
};
#else
auto dumpNetworkAfterPass = [] (std::shared_ptr<Pass> ) {};

View File

@ -48,7 +48,7 @@ HeteroAsyncInferRequest::HeteroAsyncInferRequest(const HeteroInferRequest::Ptr&
void HeteroAsyncInferRequest::StartAsync_ThreadUnsafe() {
_heteroInferRequest->updateInOutIfNeeded();
RunFirstStage();
RunFirstStage(_pipeline.begin(), _pipeline.end());
}
StatusCode HeteroAsyncInferRequest::Wait(int64_t millis_timeout) {

View File

@ -65,6 +65,27 @@ HeteroInferRequest::HeteroInferRequest(InferenceEngine::InputsDataMap networkInp
}
}
void HeteroInferRequest::SetBlob(const char* name, const InferenceEngine::Blob::Ptr& data) {
InferenceEngine::InferRequestInternal::SetBlob(name, data);
assert(!_inferRequests.empty());
for (auto &&desc : _inferRequests) {
auto &r = desc._request;
assert(nullptr != r);
InputInfo::Ptr foundInput;
DataPtr foundOutput;
try {
// if `name` is input blob
if (findInputAndOutputBlobByName(name, foundInput, foundOutput)) {
r->SetBlob(name, data, foundInput->getPreProcess());
}
} catch (const InferenceEngine::details::InferenceEngineException & ex) {
std::string message = ex.what();
if (message.find(NOT_FOUND_str) == std::string::npos)
throw ex;
}
}
}
void HeteroInferRequest::InferImpl() {
updateInOutIfNeeded();
size_t i = 0;

View File

@ -39,6 +39,8 @@ public:
void InferImpl() override;
void SetBlob(const char* name, const InferenceEngine::Blob::Ptr& data) override;
void GetPerformanceCounts(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> &perfMap) const override;
void updateInOutIfNeeded();

View File

@ -17,6 +17,8 @@ set(IE_STATIC_DEPENDENT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/file_utils.cpp)
list(REMOVE_ITEM LIBRARY_SRC ${IE_STATIC_DEPENDENT_FILES})
set(IE_BASE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/cnn_network_ngraph_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generic_ie.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blob_factory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ie_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ie_layouts.cpp
@ -94,7 +96,6 @@ file(GLOB_RECURSE plugin_api_src "${IE_MAIN_SOURCE_DIR}/src/plugin_api/*.hpp"
"${IE_MAIN_SOURCE_DIR}/src/plugin_api/*.h")
add_cpplint_target(${TARGET_NAME}_plugin_api_cpplint FOR_SOURCES ${plugin_api_src})
add_clang_format_target(${TARGET_NAME}_plugin_api_clang_format FOR_SOURCES ${plugin_api_src})
# Create common base object library
@ -103,6 +104,7 @@ add_library(${TARGET_NAME}_common_obj OBJECT
target_compile_definitions(${TARGET_NAME}_common_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API)
target_include_directories(${TARGET_NAME}_common_obj PRIVATE
$<TARGET_PROPERTY:${TARGET_NAME}_transformations,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${TARGET_NAME}_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${TARGET_NAME}_common_obj SYSTEM PRIVATE
@ -121,6 +123,7 @@ target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $<TARGET_PROPERTY:n
$<TARGET_PROPERTY:pugixml,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
$<TARGET_PROPERTY:${TARGET_NAME}_ir_readers,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${TARGET_NAME}_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>)
if(ENABLE_PROFILING_ITT AND INTEL_ITT_LIBS)
@ -146,7 +149,6 @@ if(WIN32)
endif()
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}_obj)
add_clang_format_target(${TARGET_NAME}_clang_format FOR_TARGETS ${TARGET_NAME}_obj)
# Create shared library file from object library
@ -196,7 +198,6 @@ target_include_directories(${TARGET_NAME}_nn_builder PRIVATE "${CMAKE_CURRENT_SO
"${IE_MAIN_SOURCE_DIR}/src/legacy_api/src")
add_cpplint_target(${TARGET_NAME}_nn_builder_cpplint FOR_TARGETS ${TARGET_NAME}_nn_builder)
add_clang_format_target(${TARGET_NAME}_nn_builder_clang_format FOR_TARGETS ${TARGET_NAME}_nn_builder)
# Static library used for unit tests which are always built
@ -272,6 +273,10 @@ if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
install(FILES "${TBB}/LICENSE"
DESTINATION ${IE_CPACK_IE_DIR}/external/tbb
COMPONENT tbb)
install(FILES "${TBB}/cmake/TBBConfig.cmake"
"${TBB}/cmake/TBBConfigVersion.cmake"
DESTINATION ${IE_CPACK_IE_DIR}/external/tbb/cmake
COMPONENT tbb)
endif()
ie_cpack_add_component(core REQUIRED DEPENDS ${core_components})
@ -279,8 +284,8 @@ ie_cpack_add_component(core REQUIRED DEPENDS ${core_components})
install(DIRECTORY "${IE_MAIN_SOURCE_DIR}/include" DESTINATION ${IE_CPACK_IE_DIR}
COMPONENT core)
install(TARGETS ${TARGET_NAME} ${TARGET_NAME}_nn_builder
RUNTIME DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)
install(FILES "${OpenVINO_BINARY_DIR}/share/ie_parallel.cmake"
"${OpenVINO_BINARY_DIR}/share/InferenceEngineConfig.cmake"

View File

@ -46,6 +46,8 @@ InferenceEngine::Blob::Ptr CreateBlobFromData(const InferenceEngine::DataPtr& da
return std::make_shared<InferenceEngine::TBlob<int8_t>>(desc);
case InferenceEngine::Precision::I32:
return std::make_shared<InferenceEngine::TBlob<int32_t>>(desc);
case InferenceEngine::Precision::BF16:
return std::make_shared<InferenceEngine::TBlob<short>>(desc);
default:
THROW_IE_EXCEPTION << "precision is no set";
}

View File

@ -28,7 +28,6 @@
#include "graph_tools.hpp"
#include "graph_transformer.h"
#include "ie_util_internal.hpp"
#include "ie_cnn_layer_builder_ngraph.h"
#include "ie_ngraph_utils.hpp"
#include "ie_profiling.hpp"
#include "network_serializer.h"
@ -97,7 +96,7 @@ void CNNNetworkNGraphImpl::createDataForResult(const ::ngraph::Output<::ngraph::
if (ptr) {
ptr->reshape(dims, ptr->getTensorDesc().getLayout());
} else {
const auto precision = details::ngraph::convertPrecision(output.get_element_type());
const auto precision = details::convertPrecision(output.get_element_type());
const auto layout = TensorDesc::getLayoutByDims(dims);
ptr.reset(new NGraphData(this, outName, {precision, dims, layout}));
}
@ -520,287 +519,3 @@ void CNNNetworkNGraphImpl::convertToCNNNetworkImpl() {
::ngraph::pass::ConvertOpSet1ToLegacy().run_on_function(graph);
cnnNetwork = InferenceEngine::details::convertFunctionToICNNNetwork(graph, *this);
}
std::shared_ptr<CNNNetworkNGraphImpl> CNNNetworkNGraphImpl::cloneNGraphImpl() const {
auto result = std::make_shared<CNNNetworkNGraphImpl>(cloneFunction());
for (const auto& outputInfo : _outputData) {
result->_outputData[outputInfo.first]->setPrecision(outputInfo.second->getPrecision());
result->_outputData[outputInfo.first]->setLayout(outputInfo.second->getLayout());
}
for (const auto& inputInfo : _inputData) {
result->_inputData[inputInfo.first]->setPrecision(inputInfo.second->getPrecision());
result->_inputData[inputInfo.first]->setLayout(inputInfo.second->getLayout());
result->_inputData[inputInfo.first]->getPreProcess() = inputInfo.second->getPreProcess();
}
if (cnnNetwork)
result->cnnNetwork = cloneNet(*cnnNetwork);
return result;
}
void CNNNetworkNGraphImpl::transformConstants() {
if (!cnnNetwork)
convertToCNNNetworkImpl();
// Remove all redundant constant and convert unsupported precisions
ConstTransformer transformator(cnnNetwork.get());
transformator.fullTrim();
}
void InferenceEngine::details::CNNLayerCreator::on_adapter(const std::string& name,
::ngraph::ValueAccessor<void>& adapter) {
if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::element::Type>>(&adapter)) {
auto type = static_cast<::ngraph::element::Type&>(*a);
params[name] = details::ngraph::convertPrecision(type).name();
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::PartialShape>>(&adapter)) {
std::string dims;
auto shape = static_cast<::ngraph::PartialShape&>(*a);
for (size_t i = 0; i < shape.rank().get_length(); i++) {
if (!dims.empty()) dims += ",";
dims += std::to_string(shape[i].get_length());
}
params[name] = dims;
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::Shape>>(&adapter)) {
std::string dims;
auto shape = static_cast<::ngraph::Shape&>(*a);
for (size_t i = 0; i < shape.size(); i++) {
if (!dims.empty()) dims += ",";
dims += std::to_string(shape[i]);
}
params[name] = dims;
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::Strides>>(&adapter)) {
std::string dims;
auto shape = static_cast<::ngraph::Strides&>(*a);
for (size_t i = 0; i < shape.size(); i++) {
if (!dims.empty()) dims += ",";
dims += std::to_string(shape[i]);
}
params[name] = dims;
}
}
InferenceEngine::details::CNNLayerCreator::CNNLayerCreator(const std::shared_ptr<::ngraph::Node>& node): node(node) {
addSpecificCreator({"Parameter"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Input",
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<CNNLayer>(attrs);
return res;
});
// TODO - Remove "GreaterEq" once ngraph transitions to GreaterEqual
addSpecificCreator({"Eltwise", "Subtract", "Power", "Maximum", "Divide", "Greater", "GreaterEqual", "FloorMod", "LogicalOr", "LogicalAnd", "LogicalXor",
"GreaterEq", "Less", "LessEqual", "Equal", "NotEqual", "Multiply", "Add"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<EltwiseLayer>(attrs);
res->params = params;
if (node->description() == "Maximum") {
res->params["operation"] = "max";
} else if (node->description() == "Power") {
res->params["operation"] = "pow";
} else if (node->description() == "Subtract") {
res->params["operation"] = "sub";
} else if (node->description() == "Divide") {
res->params["operation"] = "div";
} else if (node->description() == "LessEqual") {
res->params["operation"] = "less_equal";
} else if (node->description() == "Less") {
res->params["operation"] = "less";
} else if (node->description() == "Equal") {
res->params["operation"] = "equal";
} else if (node->description() == "NotEqual") {
res->params["operation"] = "not_equal";
} else if (node->description() == "FloorMod") {
res->params["operation"] = "floor_mod";
} else if (node->description() == "Multiply") {
res->params["operation"] = "prod";
} else if (node->description() == "Add") {
res->params["operation"] = "sum";
} else if (node->description() == "Greater") {
res->params["operation"] = "greater";
} else if (node->description() == "GreaterEq") {
res->params["operation"] = "greater_equal";
} else if (node->description() == "GreaterEqual") {
res->params["operation"] = "greater_equal";
} else if (node->description() == "LogicalOr") {
res->params["operation"] = "logical_or";
} else if (node->description() == "LogicalAnd") {
res->params["operation"] = "logical_and";
} else if (node->description() == "LogicalXor") {
res->params["operation"] = "logical_xor";
} else if (node->description() == "Eltwise") {
auto castedLayer = std::dynamic_pointer_cast<::ngraph::op::Eltwise>(node);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << attrs.type << " layer " << attrs.name;
std::string type;
switch (castedLayer->eltwise_type) {
case ELTWISE_TYPE::Sum:
type = "sum";
break;
case ELTWISE_TYPE::Prod:
type = "prod";
break;
default:
THROW_IE_EXCEPTION << "Not supported eltwise type!";
}
res->params["operation"] = type;
}
return res;
});
addSpecificCreator({"Concat"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<ConcatLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"AvgPool", "MaxPool"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Pooling",
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<PoolingLayer>(attrs);
res->params = params;
if (res->params.find("auto_pad") != res->params.end() &&
details::CaselessEq<std::string>()(res->params["auto_pad"], "EXPLICIT"))
res->params.erase("auto_pad");
if (res->params.find("exclude_pad") != res->params.end()) {
res->params["exclude-pad"] = res->params["exclude_pad"];
res->params.erase("exclude_pad");
}
if (node->description() == "MaxPool") {
res->params["pool-method"] = "max";
} else if (node->description() == "AvgPool") {
res->params["pool-method"] = "avg";
}
return res;
});
addSpecificCreator({"Select"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<SelectLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"BinaryConvolution"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<BinaryConvolutionLayer>(attrs);
// todo: investigate difference between ngraph parameters for BinConvolution and the implementation above
// this leads to accuracy issue for Precollected_ONNX_ResNet50_88percentinto1bit e2e test
// res->params = params;
auto castedLayer = ::ngraph::as_type_ptr<::ngraph::op::v1::BinaryConvolution>(node);
std::string value;
for (const auto& val : castedLayer->get_pads_begin()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["pads_begin"] = value;
value.clear();
for (const auto& val : castedLayer->get_pads_end()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["pads_end"] = value;
switch (castedLayer->get_auto_pad()) {
case ::ngraph::op::PadType::SAME_UPPER:
res->params["auto_pad"] = "same_upper";
break;
case ::ngraph::op::PadType::SAME_LOWER:
res->params["auto_pad"] = "same_lower";
break;
case ::ngraph::op::PadType::VALID:
res->params["auto_pad"] = "valid";
break;
default:
break;
}
value.clear();
for (const auto& val : castedLayer->get_strides()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["strides"] = value;
value.clear();
for (const auto& val : castedLayer->get_dilations()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["dilations"] = value;
// Restore kernel size and output
const auto& shape = castedLayer->get_input_shape(1);
res->params["output"] = Builder::asString(shape[0]);
value.clear();
for (size_t i = 2; i < shape.size(); i++) {
if (!value.empty()) value += ",";
value += Builder::asString(shape[i]);
}
res->params["kernel"] = value;
switch (castedLayer->get_mode()) {
case ::ngraph::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT:
res->params["mode"] = "xnor-popcount";
}
auto weights_shape = castedLayer->input(1).get_source_output().get_shape();
res->params["input"] = Builder::asString(weights_shape[1]);
res->params["pad_value"] = Builder::asString(castedLayer->get_pad_value());
Builder::NodeConverter<::ngraph::op::Constant> converter;
const auto weightsNode = castedLayer->get_inputs()[1].get_output().get_node();
if (converter.canCreate(weightsNode)) {
const auto& weights = converter.createLayer(weightsNode);
res->blobs["weights"] = weights->blobs["custom"];
res->_weights = weights->blobs["custom"];
}
return res;
});
addSpecificCreator({"SpaceToBatch"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<SpaceToBatchLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"BatchToSpace"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<BatchToSpaceLayer>(attrs);
res->params = params;
return res;
});
}
CNNLayerPtr InferenceEngine::details::CNNLayerCreator::create() {
auto one_from = [](const std::string& desc, const std::vector<std::string>& descs) -> bool {
for (const auto& d : descs) {
if (details::CaselessEq<std::string>()(d, desc)) return true;
}
return false;
};
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::ngraph::convertPrecision(node->get_output_element_type(0))};
if (creators.find(node->description()) != creators.end())
return creators[node->description()](node, params);
auto res = std::make_shared<CNNLayer>(attrs);
res->params = params;
return res;
}

View File

@ -102,7 +102,7 @@ public:
std::shared_ptr<const ::ngraph::Function> getFunction() const noexcept override {
return !cnnNetwork ? _ngraph_function : nullptr;
}
std::shared_ptr<::ngraph::Function> getFunction() noexcept {
std::shared_ptr<::ngraph::Function> getFunction() noexcept override {
return !cnnNetwork ? _ngraph_function : nullptr;
}
@ -118,9 +118,6 @@ public:
noexcept override;
void convertToCNNNetworkImpl();
std::shared_ptr<CNNNetworkNGraphImpl> cloneNGraphImpl() const;
void transformConstants();
protected:
std::shared_ptr<::ngraph::Function> _ngraph_function;
virtual std::shared_ptr<::ngraph::Function> cloneFunction(bool constFolding = false, const std::map<std::string,
@ -142,7 +139,7 @@ private:
friend INFERENCE_ENGINE_API_CPP(std::shared_ptr<CNNNetworkImpl>)
convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function>& graph,
const CNNNetworkNGraphImpl & nGraphImpl);
const ICNNNetwork& nGraphImpl);
/**
* @brief Reshape on the same shape
@ -196,65 +193,6 @@ private:
IE_SUPPRESS_DEPRECATED_END
/**
* @brief Creator for CNNLayer from nGraph op
*/
class CNNLayerCreator : public ::ngraph::AttributeVisitor {
public:
using CreatorFor = std::function<CNNLayerPtr(const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> param)>;
explicit CNNLayerCreator(const std::shared_ptr<::ngraph::Node>& node);
CNNLayerPtr create();
void on_attribute(const std::string& name, std::string& value) override {
params[name] = value;
}
void on_attribute(const std::string& name, bool& value) override {
params[name] = value ? "true" : "false";
}
void addSpecificCreator(const std::vector<std::string>& forTypes, const CreatorFor& creator) {
for (const auto type : forTypes) {
creators[type] = creator;
}
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<std::string>& adapter) override {
std::string data = adapter.get();
std::transform(data.begin(), data.end(), data.begin(), [](unsigned char c) {
return std::tolower(c);
});
params[name] = data;
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<std::vector<int64_t>>& adapter) override {
std::string dims;
auto shape = adapter.get();
for (size_t i = 0; i < shape.size(); i++) {
if (!dims.empty()) dims += ",";
dims += std::to_string(shape[i]);
}
params[name] = dims;
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<double>& adapter) override {
params[name] = std::to_string(adapter.get());
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<int64_t>& adapter) override {
params[name] = std::to_string(adapter.get());
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<void>& adapter) override;
private:
std::shared_ptr<::ngraph::Node> node;
std::map<std::string, std::string> params;
std::map<std::string, CreatorFor> creators;
};
typedef std::shared_ptr<CNNNetworkNGraphImpl> CNNNetworkNGraphImplPtr;
} // namespace details
} // namespace InferenceEngine

View File

@ -96,7 +96,7 @@ void ngraph::op::GenericIE::validate_and_infer_types() {
// Set dynamic output shapes if input shapes are not defined
for (size_t i = 0; i < outputs.size(); i++) {
const auto& port = outputs[i];
auto type = InferenceEngine::details::ngraph::convertPrecision(port.precision);
auto type = InferenceEngine::details::convertPrecision(port.precision);
set_output_type(i, type, PartialShape::dynamic());
}
return;
@ -105,7 +105,7 @@ void ngraph::op::GenericIE::validate_and_infer_types() {
Shape this_ishape = get_input_shape(i);
InferenceEngine::SizeVector dims = this_ishape;
InferenceEngine::Blob::Ptr input = make_blob_with_precision(InferenceEngine::TensorDesc(
InferenceEngine::details::ngraph::convertPrecision(get_input_element_type(i)), dims,
InferenceEngine::details::convertPrecision(get_input_element_type(i)), dims,
InferenceEngine::TensorDesc::getLayoutByDims(dims)));
inputs.emplace_back(input);
}
@ -126,6 +126,11 @@ void ngraph::op::GenericIE::validate_and_infer_types() {
}
}
// WA: Proposal shape infer has to know number of outputs
if (type == "Proposal" && parameters.find("num_outputs") == parameters.end()) {
parameters["num_outputs"] = std::to_string(outputs.size());
}
ret = impl->inferShapes(inputs, parameters, blobs, outShapes, nullptr);
IE_SUPPRESS_DEPRECATED_END
@ -134,7 +139,7 @@ void ngraph::op::GenericIE::validate_and_infer_types() {
for (size_t i = 0; i < outputs.size(); i++) {
const auto& port = outputs[i];
ngraph::Shape outShape(outShapes[i]);
auto type = InferenceEngine::details::ngraph::convertPrecision(port.precision);
auto type = InferenceEngine::details::convertPrecision(port.precision);
set_output_type(i, type, PartialShape(outShape));
}
@ -149,7 +154,7 @@ void ngraph::op::GenericIE::validate_and_infer_types() {
for (size_t i = 0; i < outputs.size(); i++) {
const auto& port = outputs[i];
ngraph::Shape outShape(port.dims);
auto type = InferenceEngine::details::ngraph::convertPrecision(port.precision);
auto type = InferenceEngine::details::convertPrecision(port.precision);
set_output_type(i, type, PartialShape(outShape));
}
initialized++;

View File

@ -16,13 +16,12 @@
#include <vector>
#include <ngraph/opsets/opset.hpp>
#include "cpp/ie_cnn_net_reader.h"
#include "cpp_interfaces/base/ie_plugin_base.hpp"
#include "details/ie_exception_conversion.hpp"
#include "details/ie_so_pointer.hpp"
#include "file_utils.h"
#include "ie_cnn_net_reader_impl.h"
#include "ie_icore.hpp"
#include "ie_ir_reader.hpp"
#include "ie_plugin.hpp"
#include "ie_plugin_config.hpp"
#include "ie_profiling.hpp"
@ -38,6 +37,27 @@ IE_SUPPRESS_DEPRECATED_START
namespace {
std::once_flag flag;
std::shared_ptr<InferenceEngine::details::SharedObjectLoader> cnnReaderLoader;
std::shared_ptr<InferenceEngine::details::SharedObjectLoader>
createCnnReaderLoader() {
std::call_once(flag, [&] () {
FileUtils::FilePath libraryName = FileUtils::toFilePath(std::string("inference_engine_ir_readers") + std::string(IE_BUILD_POSTFIX));
FileUtils::FilePath irReadersLibraryPath = FileUtils::makeSharedLibraryName(getInferenceEngineLibraryPath(), libraryName);
if (!FileUtils::fileExist(irReadersLibraryPath)) {
THROW_IE_EXCEPTION << "Please, make sure that Inference Engine IR readers library "
<< FileUtils::fromFilePath(::FileUtils::makeSharedLibraryName({}, libraryName)) << " is in "
<< getIELibraryPath();
}
cnnReaderLoader = std::shared_ptr<InferenceEngine::details::SharedObjectLoader>(
new InferenceEngine::details::SharedObjectLoader(irReadersLibraryPath.c_str()));
});
return cnnReaderLoader;
}
IInferencePluginAPI* getInferencePluginAPIInterface(IInferencePlugin* iplugin) {
return dynamic_cast<IInferencePluginAPI*>(iplugin);
}
@ -52,6 +72,11 @@ IInferencePluginAPI* getInferencePluginAPIInterface(InferencePlugin plugin) {
} // namespace
CNNNetReaderPtr CreateCNNNetReaderPtr() noexcept {
auto loader = createCnnReaderLoader();
return CNNNetReaderPtr(loader);
}
IE_SUPPRESS_DEPRECATED_END
DeviceIDParser::DeviceIDParser(const std::string& deviceNameWithID) {
@ -112,6 +137,7 @@ std::vector<std::string> DeviceIDParser::getMultiDevices(std::string devicesList
}
class Core::Impl : public ICore {
// Fields are ordered by deletion order
ITaskExecutor::Ptr _taskExecutor = nullptr;
IE_SUPPRESS_DEPRECATED_START
@ -124,10 +150,11 @@ class Core::Impl : public ICore {
std::vector<FileUtils::FilePath> listOfExtentions;
};
std::map<std::string, PluginDescriptor> pluginRegistry;
std::unordered_set<std::string> opsetNames;
std::vector<IExtensionPtr> extensions;
std::map<std::string, PluginDescriptor> pluginRegistry;
public:
Impl();
~Impl() override;
@ -395,12 +422,18 @@ std::map<std::string, Version> Core::GetVersions(const std::string& deviceName)
{
// for compatibility with samples / demo
if (deviceName.find("HETERO:") == 0) {
deviceNames = DeviceIDParser::getHeteroDevices(deviceName.substr(7));
if (deviceName.find("HETERO") == 0) {
auto pos = deviceName.find_first_of(":");
if (pos != std::string::npos) {
deviceNames = DeviceIDParser::getHeteroDevices(deviceName.substr(pos + 1));
}
deviceNames.push_back("HETERO");
} else if (deviceName.find("MULTI") == 0) {
auto pos = deviceName.find_first_of(":");
if (pos != std::string::npos) {
deviceNames = DeviceIDParser::getMultiDevices(deviceName.substr(pos + 1));
}
deviceNames.push_back("MULTI");
deviceNames = DeviceIDParser::getMultiDevices(deviceName.substr(6));
} else {
deviceNames.push_back(deviceName);
}
@ -457,13 +490,12 @@ Parsed<T> parseDeviceNameIntoConfig(const std::string& deviceName, const std::ma
CNNNetwork Core::ReadNetwork(const std::string& modelPath, const std::string& binPath) const {
IE_PROFILING_AUTO_SCOPE(Core::ReadNetwork)
IE_SUPPRESS_DEPRECATED_START
auto cnnReader = std::shared_ptr<ICNNNetReader>(CreateCNNNetReader());
ResponseDesc desc;
CNNNetReaderPtr cnnReader(createCnnReaderLoader());
StatusCode rt = cnnReader->ReadNetwork(modelPath.c_str(), &desc);
if (rt != OK) THROW_IE_EXCEPTION << desc.msg;
auto cnnNetReaderImpl = std::dynamic_pointer_cast<details::CNNNetReaderImpl>(cnnReader);
if (cnnNetReaderImpl && cnnReader->getVersion(&desc) >= 10) {
cnnNetReaderImpl->addExtensions(_impl->getExtensions());
if (cnnReader->getVersion(&desc) >= 10) {
cnnReader->addExtensions(_impl->getExtensions());
}
std::string bPath = binPath;
if (bPath.empty()) {
@ -491,13 +523,12 @@ CNNNetwork Core::ReadNetwork(const std::string& modelPath, const std::string& bi
CNNNetwork Core::ReadNetwork(const std::string& model, const Blob::CPtr& weights) const {
IE_PROFILING_AUTO_SCOPE(Core::ReadNetwork)
IE_SUPPRESS_DEPRECATED_START
auto cnnReader = std::shared_ptr<ICNNNetReader>(CreateCNNNetReader());
ResponseDesc desc;
CNNNetReaderPtr cnnReader(createCnnReaderLoader());
StatusCode rt = cnnReader->ReadNetwork(model.data(), model.length(), &desc);
if (rt != OK) THROW_IE_EXCEPTION << desc.msg;
auto cnnNetReaderImpl = std::dynamic_pointer_cast<details::CNNNetReaderImpl>(cnnReader);
if (cnnNetReaderImpl && cnnReader->getVersion(&desc) >= 10) {
cnnNetReaderImpl->addExtensions(_impl->getExtensions());
if (cnnReader->getVersion(&desc) >= 10) {
cnnReader->addExtensions(_impl->getExtensions());
}
TBlob<uint8_t>::Ptr weights_ptr;
if (weights) {
@ -507,6 +538,7 @@ CNNNetwork Core::ReadNetwork(const std::string& model, const Blob::CPtr& weights
rt = cnnReader->SetWeights(weights_ptr, &desc);
if (rt != OK) THROW_IE_EXCEPTION << desc.msg;
IE_SUPPRESS_DEPRECATED_END
return CNNNetwork(cnnReader);
}
@ -694,11 +726,6 @@ void Core::SetConfig(const std::map<std::string, std::string>& config, const std
THROW_IE_EXCEPTION << "SetConfig is supported only for HETERO itself (without devices). "
"You can configure the devices with SetConfig before creating the HETERO on top.";
}
if (config.find("TARGET_FALLBACK") != config.end()) {
THROW_IE_EXCEPTION << "Please, specify TARGET_FALLBACK to the LoadNetwork directly, "
"as you will need to pass the same TARGET_FALLBACK anyway.";
}
}
// MULTI case
@ -707,11 +734,6 @@ void Core::SetConfig(const std::map<std::string, std::string>& config, const std
THROW_IE_EXCEPTION << "SetConfig is supported only for MULTI itself (without devices). "
"You can configure the devices with SetConfig before creating the MULTI on top.";
}
if (config.find(MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES) != config.end()) {
THROW_IE_EXCEPTION << "Please, specify DEVICE_PRIORITIES to the LoadNetwork directly, "
"as you will need to pass the same DEVICE_PRIORITIES anyway.";
}
}
if (deviceName.empty()) {

View File

@ -13,6 +13,7 @@
#include <ie_parameter.hpp>
#include <ie_iextension.h>
#include <ie_extension.h>
#include <ngraph/opsets/opset.hpp>
using namespace InferenceEngine;
@ -83,6 +84,7 @@ template struct InferenceEngine::Parameter::RealData<std::vector<std::string>>;
template struct InferenceEngine::Parameter::RealData<std::vector<unsigned long>>;
template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>;
template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>;
template struct InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>;
#endif // __clang__
//
// ie_blob.h

View File

@ -71,6 +71,13 @@ bool with_cpu_x86_avx512_core() {
#endif
}
bool with_cpu_x86_bfloat16() {
#ifdef ENABLE_MKL_DNN
return cpu.has(Xbyak::util::Cpu::tAVX512_BF16);
#else
return false;
#endif
}
bool checkOpenMpEnvVars(bool includeOMPNumThreads) {
for (auto&& var : {

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2020 Intel Corporation
// Copyright (C) 2018-2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2020 Intel Corporation
// Copyright (C) 2018-2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

View File

@ -12,6 +12,7 @@
namespace InferenceEngine {
ITaskExecutor::Ptr ExecutorManagerImpl::getExecutor(std::string id) {
std::lock_guard<std::mutex> guard(taskExecutorMutex);
auto foundEntry = executors.find(id);
if (foundEntry == executors.end()) {
auto newExec = std::make_shared<CPUStreamsExecutor>(IStreamsExecutor::Config{id});
@ -22,6 +23,7 @@ ITaskExecutor::Ptr ExecutorManagerImpl::getExecutor(std::string id) {
}
IStreamsExecutor::Ptr ExecutorManagerImpl::getIdleCPUStreamsExecutor(const IStreamsExecutor::Config& config) {
std::lock_guard<std::mutex> guard(streamExecutorMutex);
for (const auto& it : cpuStreamsExecutors) {
const auto& executor = it.second;
if (executor.use_count() != 1)
@ -52,6 +54,8 @@ size_t ExecutorManagerImpl::getIdleCPUStreamsExecutorsNumber() {
}
void ExecutorManagerImpl::clear(const std::string& id) {
std::lock_guard<std::mutex> stream_guard(streamExecutorMutex);
std::lock_guard<std::mutex> task_guard(taskExecutorMutex);
if (id.empty()) {
executors.clear();
cpuStreamsExecutors.clear();
@ -66,8 +70,47 @@ void ExecutorManagerImpl::clear(const std::string& id) {
}
}
std::mutex ExecutorManager::_mutex;
ExecutorManager* ExecutorManager::_instance = nullptr;
ExecutorManager* ExecutorManager::getInstance() {
/*
* 1) We do not use singleton implementation via STATIC LOCAL object like
*
* getInstance() {
* static ExecutorManager _instance;
* return &instance;
* }
*
* Because of problem with destruction order on program exit.
* Some IE classes like MKLDNN::Engine use this singleton in destructor.
* But they has no direct dependency from c++ runtime point of view and
* it's possible that _instance local static variable will be destroyed
* before MKLDNN::~Engine call. Any further manipulation with destroyed
* object will lead to exception or crashes.
*
* 2) We do not use singleton implementation via STATIC object like:
*
* ExecutorManager ExecutorManager::_instance;
* getInstance() {
* return &instance;
* }
*
* Because of problem with double destruction. In some test cases we use
* double link with IE module via static and dynamic version. Both modules
* have static object with same export name and it leads to double construction
* and double destruction of that object. For some c++ compilers (ex gcc 5.4)
* it lead to crash with "double free".
*
* That's why we use manual allocation of singleton instance on heap.
*/
std::lock_guard<std::mutex> guard(_mutex);
if (_instance == nullptr) {
_instance = new ExecutorManager();
}
return _instance;
}
ITaskExecutor::Ptr ExecutorManager::getExecutor(std::string id) {
return _impl.getExecutor(id);
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2020 Intel Corporation
// Copyright (C) 2018-2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

View File

@ -0,0 +1,49 @@
# Copyright (C) 2018-2019 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
set(TARGET_NAME "inference_engine_ir_readers")
if(ENABLE_LTO)
ie_enable_lto()
endif()
set(PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/")
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB_RECURSE PUBLIC_HEADERS ${PUBLIC_HEADERS_DIR}/*.h ${PUBLIC_HEADERS_DIR}/*.hpp)
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj
source_group("src" FILES ${LIBRARY_SRC})
source_group("include" FILES ${PUBLIC_HEADERS})
# Create shared library
add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${PUBLIC_HEADERS})
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_API
IMPLEMENT_INFERENCE_ENGINE_PLUGIN)
target_include_directories(${TARGET_NAME} PUBLIC ${PUBLIC_HEADERS_DIR})
target_include_directories(${TARGET_NAME} PRIVATE "${IE_MAIN_SOURCE_DIR}/src/inference_engine")
target_link_libraries(${TARGET_NAME} PUBLIC inference_engine_plugin_api ${NGRAPH_LIBRARIES} inference_engine)
target_link_libraries(${TARGET_NAME} PRIVATE pugixml)
# code style
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
add_clang_format_target(${TARGET_NAME}_clang_format FOR_TARGETS ${TARGET_NAME})
# developer package
ie_developer_export_targets(${TARGET_NAME})
# install
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)

View File

@ -18,6 +18,7 @@
#include "ie_format_parser.h"
#include "ie_ir_reader.hpp"
#include "ie_profiling.hpp"
#include "ie_plugin.hpp"
#include "parsers.h"
#include "xml_parse_utils.h"
@ -29,21 +30,19 @@ IE_SUPPRESS_DEPRECATED_START
CNNNetReaderImpl::CNNNetReaderImpl(const FormatParserCreator::Ptr& _creator)
: parseSuccess(false), _version(0), parserCreator(_creator) {}
CNNNetReaderImpl::~CNNNetReaderImpl() { }
StatusCode CNNNetReaderImpl::SetWeights(const TBlob<uint8_t>::Ptr& weights, ResponseDesc* desc) noexcept {
if (!_parser && _version < 10) {
return DescriptionBuffer(desc) << "network must be read first";
}
try {
if (_version == 10) {
#if defined(ENABLE_IR_READER)
// It's time to perform actual reading of V10 network and instantiate CNNNetworkNGraphImpl
IRReader v10Reader(extensions);
std::stringstream model;
xmlDoc->save(model);
network = std::make_shared<CNNNetworkNGraphImpl>(v10Reader.read(model.str(), weights));
#else
return DescriptionBuffer(desc) << "Please, recompile Inference Engine with the ENABLE_IR_READER=ON Cmake option";
#endif
} else {
_parser->SetWeights(weights);
}
@ -173,15 +172,13 @@ void CNNNetReaderImpl::addExtensions(const std::vector<InferenceEngine::IExtensi
}
std::shared_ptr<IFormatParser> V2FormatParserCreator::create(size_t version) {
#ifdef ENABLE_IR_READER
return std::make_shared<FormatParser>(version);
#else
THROW_IE_EXCEPTION << "Please, recompile Inference Engine library with the ENABLE_IR_READER=ON Cmake option";
return nullptr;
#endif
}
InferenceEngine::ICNNNetReader* InferenceEngine::CreateCNNNetReader() noexcept {
return new CNNNetReaderImpl(std::make_shared<V2FormatParserCreator>());
INFERENCE_PLUGIN_API(InferenceEngine::StatusCode)
CreateICNNNetReader(ICNNNetReader *& data, ResponseDesc *resp) noexcept {
data = new CNNNetReaderImpl(std::make_shared<V2FormatParserCreator>());
return StatusCode::OK;
}
IE_SUPPRESS_DEPRECATED_END

View File

@ -11,10 +11,10 @@
#include <vector>
#include "cnn_network_impl.hpp"
#include "ie_icnn_net_reader.h"
#include "ie_memcpy.h"
#include "ie_profiling.hpp"
#include "parsers.h"
#include "ie_util_internal.hpp"
namespace pugi {
class xml_node;
@ -31,14 +31,14 @@ struct FormatParserCreator {
virtual ~FormatParserCreator() = default;
};
struct V2FormatParserCreator : public FormatParserCreator {
struct INFERENCE_ENGINE_API_CLASS(V2FormatParserCreator) : public FormatParserCreator {
std::shared_ptr<IFormatParser> create(size_t version) override;
};
IE_SUPPRESS_DEPRECATED_START
class CNNNetReaderImpl : public ICNNNetReader {
class INFERENCE_ENGINE_API_CLASS(CNNNetReaderImpl) : public ICNNNetReader {
public:
explicit CNNNetReaderImpl(const FormatParserCreator::Ptr& _parserCreator);
explicit CNNNetReaderImpl(const FormatParserCreator::Ptr& _creator);
StatusCode ReadNetwork(const char* filepath, ResponseDesc* resp) noexcept override;
@ -78,7 +78,9 @@ public:
delete this;
}
void addExtensions(const std::vector<InferenceEngine::IExtensionPtr>& ext);
void addExtensions(const std::vector<InferenceEngine::IExtensionPtr>& ext) override;
~CNNNetReaderImpl() override;
private:
std::shared_ptr<InferenceEngine::details::IFormatParser> _parser;
@ -96,6 +98,7 @@ private:
std::shared_ptr<pugi::xml_document> xmlDoc;
std::vector<InferenceEngine::IExtensionPtr> extensions;
};
IE_SUPPRESS_DEPRECATED_END
} // namespace details

View File

@ -267,9 +267,10 @@ FormatParser::FormatParser(size_t version): _version(version) {
std::make_shared<LayerCreator<TopKLayer>>("TopK"),
std::make_shared<LayerCreator<UniqueLayer>>("Unique"),
std::make_shared<LayerCreator<NonMaxSuppressionLayer>>("NonMaxSuppression"),
std::make_shared<LayerCreator<ScatterLayer>>("ScatterUpdate"),
std::make_shared<LayerCreator<ScatterUpdateLayer>>("ScatterUpdate"),
std::make_shared<LayerCreator<ExperimentalDetectronPriorGridGeneratorLayer>>("ExperimentalDetectronPriorGridGenerator"),
std::make_shared<LayerCreator<ExperimentalDetectronGenerateProposalsSingleImageLayer>>("ExperimentalDetectronGenerateProposalsSingleImage")};
std::make_shared<LayerCreator<ExperimentalDetectronGenerateProposalsSingleImageLayer>>("ExperimentalDetectronGenerateProposalsSingleImage"),
std::make_shared<LayerCreator<ExperimentalDetectronTopKROIs>>("ExperimentalDetectronTopKROIs")};
creators.emplace_back(_version < 6 ? std::make_shared<LayerCreator<QuantizeLayer>>("Quantize")
: std::make_shared<LayerCreator<QuantizeLayer>>("FakeQuantize"));
}

View File

@ -71,11 +71,7 @@ public:
}
};
#ifdef ENABLE_IR_READER
class INFERENCE_ENGINE_API_CLASS(FormatParser): public IFormatParser {
#else
class FormatParser : public IFormatParser {
#endif
public:
explicit FormatParser(size_t version);

View File

@ -187,7 +187,7 @@ V10Parser::GenericLayerParams V10Parser::parseGenericParams(const pugi::xml_node
// Input port hasn't precision
if (!input) {
const std::string& preStr = GetStrAttr(parentNode, "precision");
type = InferenceEngine::details::ngraph::convertPrecision(preStr);
type = InferenceEngine::details::convertPrecision(preStr);
}
port.precision = type;
return port;
@ -413,7 +413,7 @@ std::shared_ptr<ngraph::Node> V10Parser::createNode(const std::vector<ngraph::Ou
for (const auto& port : params.outputPorts) {
ngraph::op::GenericIE::PortIE iePort;
iePort.dims = port.dims;
iePort.precision = InferenceEngine::details::ngraph::convertPrecision(port.precision);
iePort.precision = InferenceEngine::details::convertPrecision(port.precision);
outputs.emplace_back(iePort);
}
@ -767,7 +767,7 @@ std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::Convert>::crea
THROW_IE_EXCEPTION << "Cannot read parameter for " << getType() << " layer with name: " << layerParsePrms.name;
return std::make_shared<ngraph::op::Convert>(inputs[0],
details::ngraph::convertPrecision(GetStrAttr(dn, "destination_type")));
details::convertPrecision(GetStrAttr(dn, "destination_type")));
}
// LSTMCell layer

View File

@ -192,7 +192,7 @@ private:
std::string val;
if (!getStrAttribute(node.child("data"), name, val)) return;
if (auto a = ngraph::as_type<ngraph::AttributeAdapter<ngraph::element::Type>>(&adapter)) {
static_cast<ngraph::element::Type&>(*a) = details::ngraph::convertPrecision(val);
static_cast<ngraph::element::Type&>(*a) = details::convertPrecision(val);
} else if (auto a = ngraph::as_type<ngraph::AttributeAdapter<ngraph::PartialShape>>(&adapter)) {
std::vector<int64_t> shape;
std::vector<ngraph::Dimension> dims;

View File

@ -36,11 +36,7 @@ namespace InferenceEngine {
* All methods here do not throw exceptions and return a StatusCode and ResponseDesc object.
* Alternatively, to use methods that throw exceptions, refer to the CNNNetReader wrapper class.
*/
#ifdef ENABLE_IR_READER
class INFERENCE_ENGINE_API_CLASS(IRReader) {
#else
class IRReader {
#endif
public:
IRReader() = default;
explicit IRReader(const std::vector<IExtensionPtr>& exts): extensions(exts) {}

View File

@ -32,6 +32,8 @@ set_ie_threading_interface_for(${TARGET_NAME}_obj)
target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API)
target_include_directories(${TARGET_NAME}_obj PRIVATE ${PUBLIC_HEADERS_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src
${IE_MAIN_SOURCE_DIR}/src/inference_engine # For CNNNetworkNGraphImpl
$<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:pugixml,INTERFACE_INCLUDE_DIRECTORIES>)
@ -51,10 +53,9 @@ add_library(${TARGET_NAME} SHARED
set_ie_threading_interface_for(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES} pugixml)
target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES} inference_engine_transformations pugixml)
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
add_clang_format_target(${TARGET_NAME}_clang_format FOR_TARGETS ${TARGET_NAME})
# export targets
@ -67,6 +68,6 @@ ie_developer_export_targets(${TARGET_NAME})
# install
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)

View File

@ -40,6 +40,10 @@ public:
precision = prec;
}
std::shared_ptr<::ngraph::Function> getFunction() noexcept override {
return nullptr;
}
std::shared_ptr<const ::ngraph::Function> getFunction() const noexcept override {
return nullptr;
}

View File

@ -4,13 +4,18 @@
#pragma once
#include "cnn_network_ngraph_impl.hpp"
#include "cnn_network_impl.hpp"
#include <ngraph/attribute_visitor.hpp>
#include <memory>
#include <string>
#include <vector>
namespace InferenceEngine {
namespace details {
INFERENCE_ENGINE_API_CPP(std::shared_ptr<CNNNetworkImpl>)
convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function>& graph, const CNNNetworkNGraphImpl &nGraphImpl);
convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function>& graph, const ICNNNetwork &network);
} // namespace details
} // namespace InferenceEngine

View File

@ -24,6 +24,7 @@ namespace InferenceEngine {
*/
class INFERENCE_ENGINE_API_CLASS(ConstTransformer) {
public:
explicit ConstTransformer(ICNNNetwork* _network);
explicit ConstTransformer(details::CNNNetworkImpl* _network);
explicit ConstTransformer(std::vector<DataPtr> &_inputs, std::vector<DataPtr> &_outputs);

View File

@ -11,7 +11,6 @@
namespace InferenceEngine {
namespace details {
namespace ngraph {
inline ::ngraph::element::Type convertPrecision(const Precision& precision) {
Precision::ePrecision pType = precision;
@ -22,6 +21,8 @@ inline ::ngraph::element::Type convertPrecision(const Precision& precision) {
return ::ngraph::element::Type(::ngraph::element::Type_t::f32);
case Precision::FP16:
return ::ngraph::element::Type(::ngraph::element::Type_t::f16);
case Precision::BF16:
return ::ngraph::element::Type(::ngraph::element::Type_t::bf16);
case Precision::U8:
return ::ngraph::element::Type(::ngraph::element::Type_t::u8);
case Precision::I8:
@ -53,6 +54,8 @@ inline ::ngraph::element::Type convertPrecision(const std::string& precision) {
return ::ngraph::element::Type(::ngraph::element::Type_t::f16);
} else if (precision == "f32" || precision == "FP32") {
return ::ngraph::element::Type(::ngraph::element::Type_t::f32);
} else if (precision == "bf16" || precision == "BF16") {
return ::ngraph::element::Type(::ngraph::element::Type_t::bf16);
} else if (precision == "f64" || precision == "FP64") {
return ::ngraph::element::Type(::ngraph::element::Type_t::f64);
} else if (precision == "i8" || precision == "I8") {
@ -90,6 +93,8 @@ inline Precision convertPrecision(const ::ngraph::element::Type& precision) {
return Precision(Precision::FP16);
case ::ngraph::element::Type_t::f32:
return Precision(Precision::FP32);
case ::ngraph::element::Type_t::bf16:
return Precision(Precision::BF16);
case ::ngraph::element::Type_t::i8:
return Precision(Precision::I8);
case ::ngraph::element::Type_t::i16:
@ -113,6 +118,5 @@ inline Precision convertPrecision(const ::ngraph::element::Type& precision) {
}
}
} // namespace ngraph
} // namespace details
} // namespace InferenceEngine

View File

@ -6,6 +6,7 @@
#include <cpp/ie_cnn_network.h>
#include <ie_icnn_network.hpp>
#include <cnn_network_impl.hpp>
#include <file_utils.h>
#include <deque>
@ -49,6 +50,15 @@ cloneNet(const std::vector<InferenceEngine::CNNLayerPtr>& layers, const ICNNNetw
IE_SUPPRESS_DEPRECATED_END
/**
* @brief Clones the whole network without conversion to CNNNetworkImpl. All layers and data objects will be cloned
* @note Blobs inside layers are reused
* @param network A network to clone
* @return A cloned object
*/
INFERENCE_ENGINE_API_CPP(std::shared_ptr<InferenceEngine::ICNNNetwork>)
cloneNetwork(const InferenceEngine::ICNNNetwork& network);
/**
* @brief Clones the whole network. All layers and data objects will be cloned
* @note Blobs inside layers are reused

View File

@ -33,8 +33,8 @@ using AllLayers =
ReshapeLayer*, TileLayer*, ScaleShiftLayer*, PReLULayer*, PowerLayer*, BatchNormalizationLayer*,
ClampLayer*, TensorIterator*, LSTMCell*, GRUCell*, RNNCell*, RNNSequenceLayer*, QuantizeLayer*,
BinaryConvolutionLayer*, WeightableLayer*, OneHotLayer*, MathLayer*, ReduceLayer*, UniqueLayer*,
NonMaxSuppressionLayer*, ScatterLayer*, ExperimentalDetectronPriorGridGeneratorLayer*,
ExperimentalDetectronGenerateProposalsSingleImageLayer*, CNNLayer*>;
NonMaxSuppressionLayer*, ScatterUpdateLayer*, ExperimentalDetectronPriorGridGeneratorLayer*,
ExperimentalDetectronGenerateProposalsSingleImageLayer*, ExperimentalDetectronTopKROIs*, CNNLayer*>;
template <class Visitor, std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type visitActualLayer(std::tuple<Tp...>&& t,

View File

@ -1000,7 +1000,9 @@ void CNNNetworkInt8Normalizer::QuantizeConvolutionOrFullyConnected(CNNLayer::Ptr
}
prev = *it;
}
symQuant = *(intervals.begin());
if (!intervals.empty()) {
symQuant = *(intervals.begin());
}
std::set<double> divs;
prev = 0.f;
for (auto it = individualsG.begin(); it != individualsG.end(); it++) {

View File

@ -9,6 +9,7 @@
#include <vector>
#include <unordered_set>
#include <cnn_network_ngraph_impl.hpp>
#include "ngraph_ops/convolution_ie.hpp"
#include "ngraph_ops/deconvolution_ie.hpp"
#include "ngraph_ops/eltwise.hpp"
@ -39,12 +40,318 @@
#include "ie_profiling.hpp"
#include "ie_cnn_layer_builder_ngraph.h"
#include <debug.h>
#include "transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.hpp"
#include "transformations/utils/utils.hpp"
namespace InferenceEngine {
namespace details {
std::shared_ptr<CNNNetworkImpl> convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function>& graph, const CNNNetworkNGraphImpl &nGraphImpl) {
/**
* @brief Creator for CNNLayer from nGraph op
*/
class CNNLayerCreator : public ::ngraph::AttributeVisitor {
public:
using CreatorFor = std::function<CNNLayerPtr(const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> param)>;
explicit CNNLayerCreator(const std::shared_ptr<::ngraph::Node>& node);
CNNLayerPtr create();
void on_attribute(const std::string& name, std::string& value) override {
params[name] = value;
}
void on_attribute(const std::string& name, bool& value) override {
params[name] = value ? "true" : "false";
}
void addSpecificCreator(const std::vector<std::string>& forTypes, const CreatorFor& creator) {
for (const auto type : forTypes) {
creators[type] = creator;
}
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<std::string>& adapter) override {
std::string data = adapter.get();
std::transform(data.begin(), data.end(), data.begin(), [](unsigned char c) {
return std::tolower(c);
});
params[name] = data;
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<std::vector<int64_t>>& adapter) override {
auto shape = adapter.get();
params[name] = joinVec(shape);
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<double>& adapter) override {
params[name] = std::to_string(adapter.get());
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<int64_t>& adapter) override {
params[name] = std::to_string(adapter.get());
}
void on_adapter(const std::string& name, ::ngraph::ValueAccessor<void>& adapter) override;
private:
std::shared_ptr<::ngraph::Node> node;
std::map<std::string, std::string> params;
std::map<std::string, CreatorFor> creators;
};
void InferenceEngine::details::CNNLayerCreator::on_adapter(const std::string& name,
::ngraph::ValueAccessor<void>& adapter) {
if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::element::Type>>(&adapter)) {
auto type = static_cast<::ngraph::element::Type&>(*a);
params[name] = details::convertPrecision(type).name();
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::PartialShape>>(&adapter)) {
std::string dims;
auto shape = static_cast<::ngraph::PartialShape&>(*a);
for (size_t i = 0; i < shape.rank().get_length(); i++) {
if (!dims.empty()) dims += ",";
dims += std::to_string(shape[i].get_length());
}
params[name] = dims;
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::Shape>>(&adapter)) {
auto shape = static_cast<::ngraph::Shape&>(*a);
params[name] = joinVec(shape);
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<::ngraph::Strides>>(&adapter)) {
auto shape = static_cast<::ngraph::Strides&>(*a);
params[name] = joinVec(shape);
}
}
InferenceEngine::details::CNNLayerCreator::CNNLayerCreator(const std::shared_ptr<::ngraph::Node>& node): node(node) {
addSpecificCreator({"Parameter"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Input",
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<CNNLayer>(attrs);
return res;
});
// TODO - Remove "GreaterEq" once ngraph transitions to GreaterEqual
addSpecificCreator({"Eltwise", "Subtract", "Power", "Maximum", "Divide", "Greater", "GreaterEqual", "FloorMod", "LogicalOr", "LogicalAnd", "LogicalXor",
"GreaterEq", "Less", "LessEqual", "Equal", "NotEqual", "Multiply", "Add"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Eltwise",
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<EltwiseLayer>(attrs);
res->params = params;
if (node->description() == "Maximum") {
res->params["operation"] = "max";
} else if (node->description() == "Power") {
res->params["operation"] = "pow";
} else if (node->description() == "Subtract") {
res->params["operation"] = "sub";
} else if (node->description() == "Divide") {
res->params["operation"] = "div";
} else if (node->description() == "LessEqual") {
res->params["operation"] = "less_equal";
} else if (node->description() == "Less") {
res->params["operation"] = "less";
} else if (node->description() == "Equal") {
res->params["operation"] = "equal";
} else if (node->description() == "NotEqual") {
res->params["operation"] = "not_equal";
} else if (node->description() == "FloorMod") {
res->params["operation"] = "floor_mod";
} else if (node->description() == "Multiply") {
res->params["operation"] = "prod";
} else if (node->description() == "Add") {
res->params["operation"] = "sum";
} else if (node->description() == "Greater") {
res->params["operation"] = "greater";
} else if (node->description() == "GreaterEq") {
res->params["operation"] = "greater_equal";
} else if (node->description() == "GreaterEqual") {
res->params["operation"] = "greater_equal";
} else if (node->description() == "LogicalOr") {
res->params["operation"] = "logical_or";
} else if (node->description() == "LogicalAnd") {
res->params["operation"] = "logical_and";
} else if (node->description() == "LogicalXor") {
res->params["operation"] = "logical_xor";
} else if (node->description() == "Eltwise") {
auto castedLayer = std::dynamic_pointer_cast<::ngraph::op::Eltwise>(node);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << attrs.type << " layer " << attrs.name;
std::string type;
switch (castedLayer->eltwise_type) {
case ELTWISE_TYPE::Sum:
type = "sum";
break;
case ELTWISE_TYPE::Prod:
type = "prod";
break;
default:
THROW_IE_EXCEPTION << "Not supported eltwise type!";
}
res->params["operation"] = type;
}
return res;
});
addSpecificCreator({"Concat"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<ConcatLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"AvgPool", "MaxPool"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), "Pooling",
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<PoolingLayer>(attrs);
res->params = params;
if (res->params.find("auto_pad") != res->params.end() &&
details::CaselessEq<std::string>()(res->params["auto_pad"], "EXPLICIT"))
res->params.erase("auto_pad");
if (res->params.find("exclude_pad") != res->params.end()) {
res->params["exclude-pad"] = res->params["exclude_pad"];
res->params.erase("exclude_pad");
}
if (node->description() == "MaxPool") {
res->params["pool-method"] = "max";
} else if (node->description() == "AvgPool") {
res->params["pool-method"] = "avg";
}
return res;
});
addSpecificCreator({"Select"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<SelectLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"BinaryConvolution"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<BinaryConvolutionLayer>(attrs);
// todo: investigate difference between ngraph parameters for BinConvolution and the implementation above
// this leads to accuracy issue for Precollected_ONNX_ResNet50_88percentinto1bit e2e test
// res->params = params;
auto castedLayer = ::ngraph::as_type_ptr<::ngraph::op::v1::BinaryConvolution>(node);
std::string value;
for (const auto& val : castedLayer->get_pads_begin()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["pads_begin"] = value;
value.clear();
for (const auto& val : castedLayer->get_pads_end()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["pads_end"] = value;
switch (castedLayer->get_auto_pad()) {
case ::ngraph::op::PadType::SAME_UPPER:
res->params["auto_pad"] = "same_upper";
break;
case ::ngraph::op::PadType::SAME_LOWER:
res->params["auto_pad"] = "same_lower";
break;
case ::ngraph::op::PadType::VALID:
res->params["auto_pad"] = "valid";
break;
default:
break;
}
value.clear();
for (const auto& val : castedLayer->get_strides()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["strides"] = value;
value.clear();
for (const auto& val : castedLayer->get_dilations()) {
if (!value.empty()) value += ",";
value += Builder::asString(val);
}
res->params["dilations"] = value;
// Restore kernel size and output
const auto& shape = castedLayer->get_input_shape(1);
res->params["output"] = Builder::asString(shape[0]);
value.clear();
for (size_t i = 2; i < shape.size(); i++) {
if (!value.empty()) value += ",";
value += Builder::asString(shape[i]);
}
res->params["kernel"] = value;
switch (castedLayer->get_mode()) {
case ::ngraph::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT:
res->params["mode"] = "xnor-popcount";
}
auto weights_shape = castedLayer->input(1).get_source_output().get_shape();
res->params["input"] = Builder::asString(weights_shape[1]);
res->params["pad_value"] = Builder::asString(castedLayer->get_pad_value());
Builder::NodeConverter<::ngraph::op::Constant> converter;
const auto weightsNode = castedLayer->get_inputs()[1].get_output().get_node();
if (converter.canCreate(weightsNode)) {
const auto& weights = converter.createLayer(weightsNode);
res->blobs["weights"] = weights->blobs["custom"];
res->_weights = weights->blobs["custom"];
}
return res;
});
addSpecificCreator({"SpaceToBatch"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<SpaceToBatchLayer>(attrs);
res->params = params;
return res;
});
addSpecificCreator({"BatchToSpace"}, [](const std::shared_ptr<::ngraph::Node>& node,
const std::map<std::string, std::string> params) -> CNNLayerPtr {
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
auto res = std::make_shared<BatchToSpaceLayer>(attrs);
res->params = params;
return res;
});
}
CNNLayerPtr InferenceEngine::details::CNNLayerCreator::create() {
auto one_from = [](const std::string& desc, const std::vector<std::string>& descs) -> bool {
for (const auto& d : descs) {
if (details::CaselessEq<std::string>()(d, desc)) return true;
}
return false;
};
LayerParams attrs = {node->get_friendly_name(), node->description(),
details::convertPrecision(node->get_output_element_type(0))};
if (creators.find(node->description()) != creators.end())
return creators[node->description()](node, params);
auto res = std::make_shared<CNNLayer>(attrs);
res->params = params;
return res;
}
std::shared_ptr<CNNNetworkImpl> convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function>& graph, const ICNNNetwork &network) {
IE_PROFILING_AUTO_SCOPE(convertFunctionToICNNNetwork)
const auto createCNNLayer = [](const std::shared_ptr<::ngraph::Node> &node) -> CNNLayerPtr {
class NGraphCNNLayer: public CNNLayer {
@ -240,8 +547,10 @@ std::shared_ptr<CNNNetworkImpl> convertFunctionToICNNNetwork(const std::shared_p
network->setInputInfo(info);
};
const CNNNetworkNGraphImpl* nGraphImpl = dynamic_cast<const CNNNetworkNGraphImpl*>(&network);
InputsDataMap thisInputDataMap;
nGraphImpl.getInputsInfo(thisInputDataMap);
network.getInputsInfo(thisInputDataMap);
// Create network
auto cnnNetworkImpl = std::make_shared<details::CNNNetworkImpl>();
@ -295,25 +604,25 @@ std::shared_ptr<CNNNetworkImpl> convertFunctionToICNNNetwork(const std::shared_p
for (const auto &dim : dims) {
if (!dim)
THROW_IE_EXCEPTION << cnnLayer->type << " layer " << cnnLayer->name
<< " has incorrect dimensions in the output data " << i;
<< " has incorrect dimensions in the output data " << i;
}
if (!ptr && nGraphImpl._data.find(outName) != nGraphImpl._data.end()) {
ptr = nGraphImpl._data.at(outName);
if (!ptr && nGraphImpl && nGraphImpl->_data.find(outName) != nGraphImpl->_data.end()) {
ptr = nGraphImpl->_data.at(outName);
if (auto nData = std::dynamic_pointer_cast<InferenceEngine::details::NGraphData>(ptr)) {
const auto layout =
dims.size() == nData->getTensorDesc().getDims().size() ?
nData->getTensorDesc().getLayout() :
TensorDesc::getLayoutByDims(dims);
dims.size() == nData->getTensorDesc().getDims().size() ?
nData->getTensorDesc().getLayout() :
TensorDesc::getLayoutByDims(dims);
nData->reset();
nData->reshape(dims, layout);
}
cnnNetworkImpl->addData(outName.c_str(), ptr);
}
if (!ptr) {
ptr.reset(new Data(outName,
{details::ngraph::convertPrecision(layer->get_output_element_type(i)), dims,
{details::convertPrecision(layer->get_output_element_type(i)), dims,
TensorDesc::getLayoutByDims(dims)}));
}

View File

@ -17,6 +17,7 @@
#include <vector>
#include <mutex>
#include <cnn_network_ngraph_impl.hpp>
#include "blob_factory.hpp"
#include "cnn_network_impl.hpp"
#include "graph_tools.hpp"
@ -70,6 +71,19 @@ ConstTransformer::ConstTransformer(details::CNNNetworkImpl* _network)
THROW_IE_EXCEPTION << "[ERROR]: Failed to init ConstTransformer with null pointer of network";
}
ConstTransformer::ConstTransformer(ICNNNetwork* _network) {
if (auto cnnNet = dynamic_cast<InferenceEngine::details::CNNNetworkImpl *>(_network)) {
network = cnnNet;
} else if (auto nGraphNet = dynamic_cast<InferenceEngine::details::CNNNetworkNGraphImpl *>(_network)) {
if (auto cnnNet = dynamic_cast<InferenceEngine::details::CNNNetworkImpl *>(nGraphNet->getCNNNetwork().get()))
network = cnnNet;
}
if (!network)
THROW_IE_EXCEPTION << "[ERROR]: Failed to init ConstTransformer with unsupported network type";
inputs = get_inputs(network);
outputs = get_outputs(network);
}
ConstTransformer::ConstTransformer(std::vector<DataPtr> &_inputs, std::vector<DataPtr> &_outputs)
: inputs(_inputs), outputs(_outputs), network(nullptr) {
if (inputs.empty() || outputs.empty())

View File

@ -3,7 +3,7 @@
//
#include <ie_cnn_layer_builder_ngraph.h>
#include "cnn_network_ngraph_impl.hpp"
#include <cnn_network_ngraph_impl.hpp>
#include <precision_utils.h>
#include <cpp/ie_cnn_network.h>
@ -72,7 +72,7 @@ std::string asString<float>(const float& value) {
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Abs>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Abs",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -83,7 +83,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::GenericIE>::createLayer(const std::share
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get layer " << layer->get_friendly_name();
LayerParams params = {layer->get_friendly_name(), castedLayer->getType(),
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
if (castedLayer->getType() == "RNNCell")
res = std::make_shared<InferenceEngine::RNNCell>(params);
@ -232,7 +232,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::TensorIterator>::createLayer(const std::
// Create Inference Engine representation of TensorIterator
LayerParams params = {layer->get_friendly_name(), "TensorIterator",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::TensorIterator>(params);
// Body: inputs
@ -365,7 +365,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::TensorIterator>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Constant>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Const",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Constant>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -377,9 +377,9 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Constant>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Convert>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Convert",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto p = details::ngraph::convertPrecision(layer->get_output_element_type(0));
auto p = details::convertPrecision(layer->get_output_element_type(0));
std::string precision_str;
switch (p) {
case Precision::FP16:
@ -423,7 +423,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Convert>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Ceiling>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Ceiling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -431,7 +431,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Ceiling>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Floor>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Floor",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -439,7 +439,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Floor>::createLayer(const std::shared_pt
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Sigmoid>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Sigmoid",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -447,7 +447,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Sigmoid>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Tanh>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "TanH",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -455,7 +455,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Tanh>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Relu>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReLU",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReLULayer>(params);
return res;
}
@ -463,7 +463,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Relu>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::SeluIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Selu",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::SeluIE>(layer);
@ -477,7 +477,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::SeluIE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ReLUIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReLU",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReLULayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ReLUIE>(layer);
@ -490,7 +490,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ReLUIE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Range>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Range",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -498,7 +498,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Range>::createLayer(const std::shared_pt
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Exp>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Exp",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -506,7 +506,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Exp>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::MVN>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "MVN",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::MVNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::MVN>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -529,7 +529,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::LRN>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::LRN_IE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Norm",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::NormLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::LRN_IE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -545,7 +545,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::LRN_IE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::CropIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Crop",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CropLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::CropIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -577,7 +577,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::CropIE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Clamp>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Clamp",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ClampLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Clamp>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -590,7 +590,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Clamp>::createLayer(const std::shared_pt
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Softmax>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "SoftMax",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::SoftMaxLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::Softmax>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -602,7 +602,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Softmax>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Subtract>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "sub";
return res;
@ -611,7 +611,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Subtract>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Power>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "pow";
return res;
@ -620,7 +620,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Power>::createLayer(const std::share
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Maximum>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "max";
return res;
@ -634,7 +634,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Minimum>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Divide>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "div";
return res;
@ -643,7 +643,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Divide>::createLayer(const std::shar
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Multiply>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "prod";
return res;
@ -652,7 +652,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Multiply>::createLayer(const std::sh
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Add>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "sum";
return res;
@ -673,7 +673,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::BatchNormInference>::createLayer(
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Squeeze>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Squeeze",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Squeeze>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -684,7 +684,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Squeeze>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Unsqueeze>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Unsqueeze",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Unsqueeze>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -695,7 +695,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Unsqueeze>::createLayer(const std::share
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::FakeQuantize>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "FakeQuantize",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::QuantizeLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::FakeQuantize>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -707,7 +707,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ConvolutionIE>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Convolution",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ConvolutionLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ConvolutionIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -793,7 +793,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::DeconvolutionIE>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Deconvolution",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::DeconvolutionLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::DeconvolutionIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -861,7 +861,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::DeformableConvolution>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "DeformableConvolution",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::DeformableConvolutionLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::DeformableConvolution>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -935,7 +935,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::DeformableConvolution>::createLayer(
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::AvgPool>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Pooling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::PoolingLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::AvgPool>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1001,7 +1001,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::AvgPool>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::MaxPool>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Pooling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::PoolingLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::MaxPool>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1066,7 +1066,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::MaxPool>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ROIPooling>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ROIPooling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ROIPooling>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1082,7 +1082,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ROIPooling>::createLayer(const std::shar
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PSROIPooling>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "PSROIPooling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PSROIPooling>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1101,7 +1101,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::DeformablePSROIPooling>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "PSROIPooling",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::DeformablePSROIPooling>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1125,7 +1125,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::DeformablePSROIPooling>::createLayer
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PRelu>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "PReLU",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::PReLULayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PRelu>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1154,7 +1154,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::PRelu>::createLayer(const std::shared_pt
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Split>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Split",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::SplitLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::Split>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1175,7 +1175,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Split>::createLayer(const std::share
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::VariadicSplit>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Split",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::SplitLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::VariadicSplit>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1196,7 +1196,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::VariadicSplit>::createLayer(const std::s
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Concat>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Concat",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ConcatLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Concat>(layer);
@ -1210,7 +1210,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Concat>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::GatherIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Gather",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::GatherLayer>(params);
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::GatherIE>(layer);
@ -1229,14 +1229,14 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::GatherTree>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::GatherTreeIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "GatherTree",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ReverseSequence>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReverseSequence", details::ngraph::convertPrecision(layer->get_output_element_type(0))};
LayerParams params = {layer->get_friendly_name(), "ReverseSequence", details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReverseSequenceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ReverseSequence>(layer);
@ -1252,7 +1252,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ReverseSequence>::createLayer(const std:
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Reshape>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Reshape",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReshapeLayer>(params);
return res;
}
@ -1260,7 +1260,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Reshape>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ShapeOf>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ShapeOf",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -1268,7 +1268,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ShapeOf>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::Reshape>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Reshape",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::Reshape>(layer);
if (castedLayer == nullptr)
@ -1293,7 +1293,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::Reshape>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PadIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Pad",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::PadLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PadIE>(layer);
@ -1333,7 +1333,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::PadIE>::createLayer(const std::shared_pt
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ScaleShiftIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ScaleShift",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ScaleShiftLayer>(params);
NodeConverter<ngraph::op::Constant> converter;
@ -1357,7 +1357,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ScaleShiftIE>::createLayer(const std::sh
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Elu>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "elu",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Elu>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1370,7 +1370,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Elu>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::SquaredDifference>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->params["operation"] = "squared_diff";
return res;
@ -1380,7 +1380,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::DetectionOutput>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "DetectionOutput",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::DetectionOutput>(layer);
@ -1416,7 +1416,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::DetectionOutput>::createLayer(
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Transpose>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Permute",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
NodeConverter<ngraph::op::Constant> converter;
@ -1444,7 +1444,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Proposal>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ProposalIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Proposal",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ProposalIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1484,7 +1484,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PriorBoxClusteredIE>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "PriorBoxClustered",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PriorBoxClusteredIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1533,7 +1533,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::PriorBoxClustered>::createLayer(
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PriorBoxIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "PriorBox",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PriorBoxIE>(layer);
auto layer_info = params.type + " layer " + params.name;
@ -1613,7 +1613,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::PriorBox>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::PowerIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Power",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::PowerLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::PowerIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1628,7 +1628,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::PowerIE>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::TopK>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "TopK",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::TopKLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::TopK>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1672,7 +1672,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::TopK>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::TopKIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "TopK",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::TopKLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::TopKIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1687,7 +1687,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::TopKIE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Eltwise>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Eltwise",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Eltwise>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1712,7 +1712,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Eltwise>::createLayer(const std::shared_
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::TileIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Tile",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::TileLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::TileIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1725,7 +1725,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::TileIE>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ResampleV2>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Resample", details::ngraph::convertPrecision(layer->get_output_element_type(0))};
LayerParams params = {layer->get_friendly_name(), "Resample", details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ResampleV2>(layer);
if (castedLayer == nullptr)
@ -1752,7 +1752,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ResampleV2>::createLayer(const std::shar
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Interp>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Resample",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = ngraph::as_type_ptr<ngraph::op::Interp>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1766,7 +1766,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Interp>::createLayer(const std::shared_p
}
params = {layer->get_friendly_name(), "Interp",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
res->params["height"] = asString(attrs.height);
@ -1786,7 +1786,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Interpolate>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::FullyConnected>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "FullyConnected",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = ngraph::as_type_ptr<ngraph::op::FullyConnected>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1824,7 +1824,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::LSTMCell>::createLayer(const std::shared
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::LSTMCellIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "LSTMCell",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = ngraph::as_type_ptr<ngraph::op::LSTMCellIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1872,7 +1872,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::LSTMCellIE>::createLayer(const std::shar
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::MatMul>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Gemm",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = ngraph::as_type_ptr<ngraph::op::MatMul>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1887,7 +1887,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::MatMul>::createLayer(const std::shared_p
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::RegionYolo>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "RegionYolo",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::RegionYolo>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1920,7 +1920,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::RegionYolo>::createLayer(const std::shar
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::ReorgYolo>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReorgYolo",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::ReorgYolo>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1938,7 +1938,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ReorgYolo>::createLayer(const std::share
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMin>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceMin",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::ReduceMin>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1950,7 +1950,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMin>::createLayer(const std::s
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMax>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceMax",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::ReduceMax>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1962,7 +1962,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMax>::createLayer(const std::s
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMean>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceMean",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::ReduceMean>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1974,7 +1974,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceMean>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceProd>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceProd",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::ReduceProd>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -1986,7 +1986,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceProd>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceSum>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceSum",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::v1::ReduceSum>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -2003,7 +2003,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::NormalizeL2>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Log>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Log",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2011,7 +2011,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Log>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::NormalizeIE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Normalize",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::NormLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::NormalizeIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -2025,6 +2025,8 @@ CNNLayer::Ptr NodeConverter<ngraph::op::NormalizeIE>::createLayer(const std::sha
if (converter.canCreate(weightsNode)) {
const auto& weights = converter.createLayer(weightsNode);
res->blobs["weights"] = weights->blobs["custom"];
} else {
THROW_IE_EXCEPTION << "Cannot convert weight node for NormalizeIE op";
}
return res;
@ -2034,7 +2036,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::CTCGreedyDecoder>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "CTCGreedyDecoder",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = ngraph::as_type_ptr<ngraph::op::CTCGreedyDecoder>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -2046,7 +2048,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::CTCGreedyDecoder>::createLayer(
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Erf>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Erf",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2054,7 +2056,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Erf>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Sign>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Sign",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2062,7 +2064,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Sign>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Sin>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Sin",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2070,7 +2072,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Sin>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Sinh>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Sinh",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2078,7 +2080,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Sinh>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Asin>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Asin",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2086,7 +2088,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Asin>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Cos>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Cos",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2094,7 +2096,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Cos>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Cosh>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Cosh",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2102,7 +2104,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Cosh>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Acos>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Acos",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2110,7 +2112,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Acos>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Tan>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Tan",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2118,7 +2120,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Tan>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Atan>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Atan",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2126,7 +2128,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::Atan>::createLayer(const std::shared_ptr
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::Sqrt>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Sqrt",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
return res;
}
@ -2142,7 +2144,7 @@ template <>
CNNLayer::Ptr NodeConverter<ngraph::op::StridedSliceIE>::createLayer(
const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "StridedSlice",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::StridedSliceLayer>(params);
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::StridedSliceIE>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -2209,7 +2211,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::HardSigmoid>::createLayer(const std::sha
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::HardSigmoid_IE>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = { layer->get_friendly_name(), "HardSigmoid", details::ngraph::convertPrecision(layer->get_output_element_type(0)) };
LayerParams params = { layer->get_friendly_name(), "HardSigmoid", details::convertPrecision(layer->get_output_element_type(0)) };
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::HardSigmoid_IE>(layer);
if (castedLayer == nullptr)
@ -2223,7 +2225,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::HardSigmoid_IE>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::GRN>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "GRN",
details::ngraph::convertPrecision(layer->get_output_element_type(0))};
details::convertPrecision(layer->get_output_element_type(0))};
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::GRN>(layer);
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
@ -2234,7 +2236,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::GRN>::createLayer(const std::shared_ptr<
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::LogicalNot>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "Activation", details::ngraph::convertPrecision(layer->get_output_element_type(0))};
LayerParams params = {layer->get_friendly_name(), "Activation", details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
res->params["type"] = "not";
return res;
@ -2242,7 +2244,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::LogicalNot>::createLayer(const std::
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceLogicalAnd>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceAnd", details::ngraph::convertPrecision(layer->get_output_element_type(0))};
LayerParams params = {layer->get_friendly_name(), "ReduceAnd", details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::v1::ReduceLogicalAnd>(layer);
@ -2254,7 +2256,7 @@ CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceLogicalAnd>::createLayer(const
template <>
CNNLayer::Ptr NodeConverter<ngraph::op::v1::ReduceLogicalOr>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
LayerParams params = {layer->get_friendly_name(), "ReduceOr", details::ngraph::convertPrecision(layer->get_output_element_type(0))};
LayerParams params = {layer->get_friendly_name(), "ReduceOr", details::convertPrecision(layer->get_output_element_type(0))};
auto res = std::make_shared<InferenceEngine::ReduceLayer>(params);
auto castedLayer = std::dynamic_pointer_cast<ngraph::op::v1::ReduceLogicalOr>(layer);

View File

@ -93,7 +93,7 @@ private:
Blob::Ptr shareWeights(const std::shared_ptr<ngraph::op::Constant>& constLayer) const {
if (!constLayer) THROW_IE_EXCEPTION << "Cannot share weights! Constant operation is empty!";
auto dataPrecision = details::ngraph::convertPrecision(constLayer->get_element_type());
auto dataPrecision = details::convertPrecision(constLayer->get_element_type());
size_t shapeSize = ngraph::shape_size(constLayer->get_shape());
if (dataPrecision == Precision::BIN) {

View File

@ -2447,7 +2447,9 @@ void PriorBoxClusteredValidator::checkShapes(const CNNLayer* layer, const std::v
PriorBoxClusteredValidator::PriorBoxClusteredValidator(const std::string& _type): LayerValidator(_type) {}
void ProposalValidator::parseParams(CNNLayer* layer) {
layer->params["num_outputs"] = std::to_string(layer->outData.size());
if (layer->params.find("num_outputs") == layer->params.end()) {
layer->params["num_outputs"] = std::to_string(layer->outData.size());
}
}
void ProposalValidator::checkParams(const CNNLayer* layer) {
@ -3074,52 +3076,55 @@ void NMSValidator::checkShapes(const CNNLayer* layer, const vector<SizeVector>&
THROW_IE_EXCEPTION << layer->name << " 'score_threshold' should be scalar";
}
ScatterValidator::ScatterValidator(const std::string& _type): LayerValidator(_type) {}
ScatterUpdateValidator::ScatterUpdateValidator(const std::string& _type): LayerValidator(_type) {}
void ScatterValidator::parseParams(CNNLayer* layer) {
auto casted = dynamic_cast<ScatterLayer*>(layer);
void ScatterUpdateValidator::parseParams(CNNLayer* layer) {
auto casted = dynamic_cast<ScatterUpdateLayer*>(layer);
if (!casted) {
THROW_IE_EXCEPTION << layer->name << " Layer is not instance of ScatterLayer class";
THROW_IE_EXCEPTION << layer->name << " Layer is not instance of ScatterUpdateLayer class";
}
casted->axis = casted->GetParamAsInt("axis", 0);
}
void ScatterValidator::checkShapes(const CNNLayer* layer, const vector<SizeVector>& inShapes) const {
auto casted = dynamic_cast<const ScatterLayer*>(layer);
void ScatterUpdateValidator::checkShapes(const CNNLayer* layer, const vector<SizeVector>& inShapes) const {
auto casted = dynamic_cast<const ScatterUpdateLayer*>(layer);
if (!casted) {
THROW_IE_EXCEPTION << layer->name << " Layer is not instance of ScatterLayer class";
THROW_IE_EXCEPTION << layer->name << " Layer is not instance of ScatterUpdateLayer class";
}
size_t numInputs = inShapes.size();
if (numInputs != 3)
THROW_IE_EXCEPTION << layer->name << " Scatter can take only 3 inputs, but actually it has: " << numInputs;
if (numInputs != 4)
THROW_IE_EXCEPTION << layer->name << " Scatter can take only 4 inputs, but actually it has: " << numInputs;
if (!(-static_cast<int>(inShapes[0].size()) <= casted->axis && casted->axis < static_cast<int>(inShapes[0].size())))
THROW_IE_EXCEPTION << layer->name << " Incorrect input parameters dimensions and axis number!";
static constexpr int DATA = 0;
static constexpr int INDICES = 1;
static constexpr int UPDATES = 2;
static constexpr int AXIS = 3;
if (inShapes[0].size() == 0 || (inShapes[0].size() == 1 && inShapes[0][0] == 1))
THROW_IE_EXCEPTION << layer->name << " 'Data' tensor rank should be >= 1";
if (inShapes[DATA].size() < 1)
THROW_IE_EXCEPTION << layer->name << " 'Data' tensor rank must be >= 1";
if (inShapes[1].size() == 0 || (inShapes[1].size() == 1 && inShapes[1][0] == 1))
THROW_IE_EXCEPTION << layer->name << " 'Indexes' tensor rank should be >= 1";
if (inShapes[INDICES].size() < 1)
THROW_IE_EXCEPTION << layer->name << " 'Indices' tensor rank must be >= 1";
if (inShapes[1].size() == 0 || (inShapes[1].size() == 1 && inShapes[1][0] == 1))
THROW_IE_EXCEPTION << layer->name << " 'Updates' tensor rank should be >= 1";
if (inShapes[UPDATES].size() < 1)
THROW_IE_EXCEPTION << layer->name << " 'Updates' tensor rank must be >= 1";
if (inShapes[1] != inShapes[2])
if (!(inShapes[AXIS].size() == 1 && inShapes[AXIS][0] == 1))
THROW_IE_EXCEPTION << layer->name << " 'Axis' tensor must be 1D array of 1 element";
if (inShapes[UPDATES].size() != inShapes[INDICES].size() + inShapes[DATA].size() - 1)
THROW_IE_EXCEPTION << layer->name << " Incorrect number of 'indexes' and 'updates' tensors dimension";
const size_t SCATTER_DATA = 0;
const size_t SCATTER_INDEXES = 1;
const size_t SCATTER_UPDATES = 2;
Precision inIdxPrecision = layer->insData[SCATTER_INDEXES].lock()->getTensorDesc().getPrecision();
Precision inIdxPrecision = layer->insData[INDICES].lock()->getTensorDesc().getPrecision();
if (inIdxPrecision != Precision::FP32 && inIdxPrecision != Precision::I32)
THROW_IE_EXCEPTION << layer->name << " Incorrect input 'Indexes' precision. Only FP32 or I32 are supported!";
THROW_IE_EXCEPTION << layer->name << " Incorrect input 'Indices' precision. Only FP32 or I32 are supported!";
if (layer->insData[SCATTER_DATA].lock()->getTensorDesc().getPrecision() !=
layer->insData[SCATTER_UPDATES].lock()->getTensorDesc().getPrecision())
Precision inAxisPrecision = layer->insData[AXIS].lock()->getTensorDesc().getPrecision();
if (inAxisPrecision != Precision::FP32 && inAxisPrecision != Precision::I32)
THROW_IE_EXCEPTION << layer->name << " Incorrect input 'Axis' precision. Only FP32 or I32 are supported!";
if (layer->insData[DATA].lock()->getTensorDesc().getPrecision() !=
layer->insData[UPDATES].lock()->getTensorDesc().getPrecision())
THROW_IE_EXCEPTION << layer->name << " Precision should be equal for input tensors 'Data' and 'Updates'";
}
@ -3248,7 +3253,7 @@ LayerValidators::LayerValidators() {
REG_LAYER_VALIDATOR_FOR_TYPE(TopKValidator, TopK);
REG_LAYER_VALIDATOR_FOR_TYPE(UniqueValidator, Unique);
REG_LAYER_VALIDATOR_FOR_TYPE(NMSValidator, NonMaxSuppression);
REG_LAYER_VALIDATOR_FOR_TYPE(ScatterValidator, ScatterUpdate);
REG_LAYER_VALIDATOR_FOR_TYPE(ScatterUpdateValidator, ScatterUpdate);
}
} // namespace InferenceEngine

View File

@ -969,9 +969,9 @@ public:
void checkShapes(const CNNLayer* layer, const std::vector<SizeVector>& inShapes) const override;
};
class ScatterValidator : public LayerValidator {
class ScatterUpdateValidator : public LayerValidator {
public:
explicit ScatterValidator(const std::string& _type);
explicit ScatterUpdateValidator(const std::string& _type);
void parseParams(CNNLayer* layer) override;

View File

@ -67,6 +67,7 @@ ReduceLayer::~ReduceLayer() {}
TopKLayer::~TopKLayer() {}
UniqueLayer::~UniqueLayer() {}
NonMaxSuppressionLayer::~NonMaxSuppressionLayer() {}
ScatterLayer::~ScatterLayer() {}
ScatterUpdateLayer::~ScatterUpdateLayer() {}
ExperimentalDetectronPriorGridGeneratorLayer::~ExperimentalDetectronPriorGridGeneratorLayer() {}
ExperimentalDetectronGenerateProposalsSingleImageLayer::~ExperimentalDetectronGenerateProposalsSingleImageLayer() {}
ExperimentalDetectronTopKROIs::~ExperimentalDetectronTopKROIs() {}

View File

@ -77,9 +77,10 @@ CNNLayerPtr layerCloneImpl<TensorIterator>(const CNNLayer* source) {
CNNLayerPtr clonelayer(const CNNLayer& source) {
using fptr = CNNLayerPtr (*)(const CNNLayer*);
// Most derived layers must go first in this list
static const fptr cloners[] = {&layerCloneImpl<ExperimentalDetectronGenerateProposalsSingleImageLayer>,
static const fptr cloners[] = {&layerCloneImpl<ExperimentalDetectronTopKROIs>,
&layerCloneImpl<ExperimentalDetectronGenerateProposalsSingleImageLayer>,
&layerCloneImpl<ExperimentalDetectronPriorGridGeneratorLayer>,
&layerCloneImpl<ScatterLayer>,
&layerCloneImpl<ScatterUpdateLayer>,
&layerCloneImpl<NonMaxSuppressionLayer>,
&layerCloneImpl<SelectLayer>,
&layerCloneImpl<BatchNormalizationLayer>,
@ -145,6 +146,35 @@ CNNLayerPtr clonelayer(const CNNLayer& source) {
return nullptr; // Silence "control may reach end of non-void function" warning
}
std::shared_ptr<ICNNNetwork> cloneNetwork(const ICNNNetwork& network) {
if (auto func = network.getFunction()) {
CNNNetwork net(func);
InputsDataMap originInputs;
OutputsDataMap originOutputs;
network.getInputsInfo(originInputs);
network.getOutputsInfo(originOutputs);
InputsDataMap clonedInputs = net.getInputsInfo();
OutputsDataMap clonedOutputs = net.getOutputsInfo();
for (const auto& outputInfo : originOutputs) {
if (clonedOutputs.find(outputInfo.first) == clonedOutputs.end())
THROW_IE_EXCEPTION << "Cannot clone network! Cloned network doesn't contain all outputs";
clonedOutputs[outputInfo.first]->setPrecision(outputInfo.second->getPrecision());
clonedOutputs[outputInfo.first]->setLayout(outputInfo.second->getLayout());
}
for (const auto& inputInfo : originInputs) {
if (clonedInputs.find(inputInfo.first) == clonedInputs.end())
THROW_IE_EXCEPTION << "Cannot clone network! Cloned network doesn't contain all inputs";
clonedInputs[inputInfo.first]->setPrecision(inputInfo.second->getPrecision());
clonedInputs[inputInfo.first]->setLayout(inputInfo.second->getLayout());
clonedInputs[inputInfo.first]->getPreProcess() = inputInfo.second->getPreProcess();
}
return net;
}
return cloneNet(network);
}
details::CNNNetworkImplPtr cloneNet(const ICNNNetwork& network) {
std::vector<CNNLayerPtr> layers;
details::CNNNetworkIterator i(&network);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2020 Intel Corporation
// Copyright (C) 2018-2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

View File

@ -487,6 +487,7 @@ std::size_t FillXmlDoc(const InferenceEngine::ICNNNetwork& network, pugi::xml_do
if (dumpWeights && !node->blobs.empty()) {
auto blobsNode = layer.append_child("blobs");
for (const auto& dataIt : node->blobs) {
if (!dataIt.second) continue;
size_t dataSize = dataIt.second->byteSize();
pugi::xml_node data = blobsNode.append_child(dataIt.first.c_str());
data.append_attribute("offset").set_value(dataOffset);
@ -546,11 +547,12 @@ void SerializeBlobs(std::ostream& stream, const InferenceEngine::ICNNNetwork& ne
for (auto&& node : ordered) {
if (!node->blobs.empty()) {
for (const auto& dataIt : node->blobs) {
if (!dataIt.second) continue;
const char* dataPtr = dataIt.second->buffer().as<char*>();
size_t dataSize = dataIt.second->byteSize();
stream.write(dataPtr, dataSize);
if (!stream.good()) {
THROW_IE_EXCEPTION << "Error during writing blob waights";
THROW_IE_EXCEPTION << "Error during writing blob weights";
}
}
}

View File

@ -248,7 +248,7 @@ REG_SHAPE_INFER_FOR_TYPE(GatherTreeShapeProp, GatherTree);
REG_SHAPE_INFER_FOR_TYPE(TopKShapeProp, TopK);
REG_SHAPE_INFER_FOR_TYPE(UniqueShapeProp, Unique);
REG_SHAPE_INFER_FOR_TYPE(NMSShapeProp, NonMaxSuppression);
REG_SHAPE_INFER_FOR_TYPE(ScatterShapeProp, Scatter);
REG_SHAPE_INFER_FOR_TYPE(ScatterUpdateShapeProp, ScatterUpdate);
} // namespace ShapeInfer
} // namespace InferenceEngine

View File

@ -15,19 +15,19 @@ namespace InferenceEngine {
namespace ShapeInfer {
/**
*@brief Implementation of Shape inference for Scatter layer
*@brief Implementation of Shape inference for ScatterUpdate layer
*/
class ScatterShapeProp : public BuiltInShapeInferImpl {
class ScatterUpdateShapeProp : public BuiltInShapeInferImpl {
public:
explicit ScatterShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {}
explicit ScatterUpdateShapeProp(const std::string& type): BuiltInShapeInferImpl(type) {}
void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs, const std::map<std::string, std::string>& params,
const std::map<std::string, Blob::Ptr>& blobs, std::vector<SizeVector>& outShapes) override {
LayerParams lp {};
ScatterLayer scatterLayer(lp);
scatterLayer.params = params;
scatterLayer.type = _type;
validate(&scatterLayer, inBlobs, params, blobs);
ScatterUpdateLayer scatterUpdateLayer(lp);
scatterUpdateLayer.params = params;
scatterUpdateLayer.type = _type;
validate(&scatterUpdateLayer, inBlobs, params, blobs);
outShapes = {inShapes[0]};
}

Some files were not shown because too many files have changed in this diff Show More