Merge remote-tracking branch 'upstream/master' into add_mxnet_operations
This commit is contained in:
commit
74df3b3970
@ -83,7 +83,7 @@ jobs:
|
||||
displayName: 'Make dir'
|
||||
|
||||
- script: |
|
||||
certutil -urlcache -split -f https://openvinoweb.z5.web.core.windows.net/incredibuild/install_ib_console.bat install_ib_console.bat
|
||||
curl -O https://openvinoweb.z5.web.core.windows.net/incredibuild/install_ib_console.bat
|
||||
call install_ib_console.bat
|
||||
workingDirectory: $(WORK_DIR)
|
||||
displayName: 'Install IncrediBuild'
|
||||
@ -117,9 +117,9 @@ jobs:
|
||||
python -m pip install -r $(REPO_DIR)\tools\mo\requirements.txt
|
||||
python -m pip install -r $(REPO_DIR)\tools\mo\requirements_dev.txt
|
||||
rem Speed up build
|
||||
certutil -urlcache -split -f https://github.com/Kitware/CMake/releases/download/v$(CMAKE_VERSION)/cmake-$(CMAKE_VERSION)-windows-x86_64.zip cmake-$(CMAKE_VERSION)-windows-x86_64.zip
|
||||
powershell -command "Invoke-WebRequest https://github.com/Kitware/CMake/releases/download/v$(CMAKE_VERSION)/cmake-$(CMAKE_VERSION)-windows-x86_64.zip -OutFile cmake-$(CMAKE_VERSION)-windows-x86_64.zip"
|
||||
powershell -command "Expand-Archive -Force cmake-$(CMAKE_VERSION)-windows-x86_64.zip"
|
||||
certutil -urlcache -split -f https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip ninja-win.zip
|
||||
powershell -command "Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip -OutFile ninja-win.zip"
|
||||
powershell -command "Expand-Archive -Force ninja-win.zip"
|
||||
git clone https://github.com/google/gtest-parallel.git
|
||||
workingDirectory: $(WORK_DIR)
|
||||
|
@ -59,7 +59,7 @@ jobs:
|
||||
|
||||
- script: |
|
||||
rem Speed up build
|
||||
certutil -urlcache -split -f https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip ninja-win.zip
|
||||
powershell -command "Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip -OutFile ninja-win.zip"
|
||||
powershell -command "Expand-Archive -Force ninja-win.zip"
|
||||
workingDirectory: $(WORK_DIR)
|
||||
displayName: 'Install dependencies'
|
||||
|
@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(FRONTEND_INSTALL_INCLUDE "runtime/include/ngraph/frontend")
|
||||
set(FRONTEND_INSTALL_INCLUDE "runtime/include/")
|
||||
set(FRONTEND_NAME_SUFFIX "_ov_frontend")
|
||||
|
||||
set(FRONTEND_NAMES "" CACHE INTERNAL "")
|
||||
@ -225,7 +225,7 @@ macro(ov_add_frontend)
|
||||
|
||||
if(OV_FRONTEND_LINKABLE_FRONTEND)
|
||||
# install -dev part
|
||||
install(DIRECTORY ${${TARGET_NAME}_INCLUDE_DIR}/${OV_FRONTEND_NAME}_frontend
|
||||
install(DIRECTORY ${${TARGET_NAME}_INCLUDE_DIR}/
|
||||
DESTINATION ${FRONTEND_INSTALL_INCLUDE}
|
||||
COMPONENT core_dev
|
||||
FILES_MATCHING PATTERN "*.hpp")
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/frontend.hpp"
|
||||
#include "openvino/frontend/frontend.hpp"
|
||||
|
||||
@OV_FRONTEND_DECLARATIONS@
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
WHEEL_PACKAGE_NAME=@WHEEL_PACKAGE_NAME@
|
||||
WHEEL_VERSION=@WHEEL_VERSION@
|
||||
WHEEL_BUILD=@WHEEL_BUILD@
|
||||
WHEEL_LICENCE_TYPE=@WHEEL_LICENCE_TYPE@
|
||||
WHEEL_AUTHOR=@WHEEL_AUTHOR@
|
||||
WHEEL_AUTHOR_EMAIL=@WHEEL_AUTHOR_EMAIL@
|
||||
WHEEL_DESC=@WHEEL_DESC@
|
||||
WHEEL_LICENSE=@WHEEL_LICENSE@
|
||||
WHEEL_REQUIREMENTS=@WHEEL_REQUIREMENTS@
|
||||
WHEEL_OVERVIEW=@WHEEL_OVERVIEW@
|
||||
|
||||
CMAKE_BUILD_DIR=@CMAKE_BINARY_DIR@
|
||||
OV_RUNTIME_LIBS_DIR=@IE_CPACK_RUNTIME_PATH@
|
||||
TBB_LIBS_DIR=@TBB_LIBS_DIR@
|
||||
PY_PACKAGES_DIR=@PY_PACKAGES_DIR@
|
@ -1,40 +1,14 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(WHEEL_PACKAGE_NAME "openvino" CACHE STRING "Name of the package")
|
||||
set(WHEEL_LICENCE_TYPE "OSI Approved :: Apache Software License" CACHE STRING "License type for the package")
|
||||
set(WHEEL_AUTHOR "Intel Corporation" CACHE STRING "Package author’s name")
|
||||
set(WHEEL_AUTHOR_EMAIL "openvino_pushbot@intel.com" CACHE STRING "Email address of the package author")
|
||||
set(WHEEL_DESC "Inference Engine Python* API" CACHE STRING "Short, summary description of the package")
|
||||
set(WHEEL_URL "https://docs.openvinotoolkit.org/latest/index.html" CACHE STRING "Home page url")
|
||||
set(WHEEL_DOWNLOAD_URL "https://github.com/openvinotoolkit/openvino/tags" CACHE STRING "Download page url")
|
||||
set(WHEEL_VERSION "${IE_VERSION}" CACHE STRING "Version of this release" FORCE)
|
||||
set(WHEEL_BUILD "${IE_VERSION_BUILD}" CACHE STRING "Build number of this release" FORCE)
|
||||
set(WHEEL_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" CACHE STRING "Wheel license file")
|
||||
set(WHEEL_REQUIREMENTS "${CMAKE_CURRENT_SOURCE_DIR}/meta/openvino.requirements.txt" CACHE STRING "Wheel requirements.txt file")
|
||||
set(WHEEL_OVERVIEW "${CMAKE_CURRENT_SOURCE_DIR}/meta/pypi_overview.md" CACHE STRING "Detailed description")
|
||||
|
||||
set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
||||
set(SETUP_ENV "${CMAKE_CURRENT_SOURCE_DIR}/.env.in")
|
||||
set(SETUP_ENV_OUT "${CMAKE_CURRENT_SOURCE_DIR}/.env")
|
||||
|
||||
set(PY_PACKAGES_DIR ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION})
|
||||
set(TBB_LIBS_DIR runtime/3rdparty/tbb/lib)
|
||||
|
||||
if(APPLE)
|
||||
set(WHEEL_PLATFORM macosx_10_15_x86_64)
|
||||
elseif(UNIX)
|
||||
set(WHEEL_PLATFORM manylinux2014_x86_64)
|
||||
elseif(WIN32)
|
||||
set(WHEEL_PLATFORM win_amd64)
|
||||
if(WIN32)
|
||||
set(TBB_LIBS_DIR runtime/3rdparty/tbb/bin)
|
||||
else()
|
||||
message(FATAL_ERROR "This platform is not supported")
|
||||
endif()
|
||||
|
||||
configure_file(${SETUP_ENV} ${SETUP_ENV_OUT} @ONLY)
|
||||
|
||||
if(LINUX)
|
||||
find_host_program(patchelf_program
|
||||
NAMES patchelf
|
||||
@ -55,21 +29,30 @@ endforeach()
|
||||
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import wheel.bdist_wheel ; print(f'{wheel.bdist_wheel.get_abi_tag()}')" OUTPUT_VARIABLE PYTHON_ABI)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import wheel.vendored.packaging.tags as tags ; print(f'{tags.interpreter_name()}{tags.interpreter_version()}')" OUTPUT_VARIABLE INTERPRETER)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import wheel.vendored.packaging.tags as tags ; print(f'{next(tags._platform_tags())}')" OUTPUT_VARIABLE WHEEL_PLATFORM)
|
||||
string(STRIP ${PYTHON_ABI} PYTHON_ABI)
|
||||
string(STRIP ${INTERPRETER} INTERPRETER)
|
||||
string(STRIP ${WHEEL_PLATFORM} WHEEL_PLATFORM)
|
||||
|
||||
set(openvino_wheel_name "openvino-${WHEEL_VERSION}-${WHEEL_BUILD}-${INTERPRETER}-${PYTHON_ABI}-${WHEEL_PLATFORM}.whl")
|
||||
set(openvino_wheels_output_dir "${CMAKE_BINARY_DIR}/wheels")
|
||||
set(openvino_wheel_path "${openvino_wheels_output_dir}/${openvino_wheel_name}")
|
||||
|
||||
add_custom_command(OUTPUT ${openvino_wheel_path}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/licensing" "${CMAKE_BINARY_DIR}/licensing"
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/site-packages"
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} clean bdist_wheel
|
||||
COMMAND ${CMAKE_COMMAND} -E env WHEEL_VERSION=${WHEEL_VERSION}
|
||||
WHEEL_BUILD=${WHEEL_BUILD}
|
||||
CMAKE_BUILD_DIR=${CMAKE_BINARY_DIR}
|
||||
OV_RUNTIME_LIBS_DIR=${IE_CPACK_RUNTIME_PATH}
|
||||
TBB_LIBS_DIR=${TBB_LIBS_DIR}
|
||||
PY_PACKAGES_DIR=${PY_PACKAGES_DIR}
|
||||
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/setup.py" clean bdist_wheel
|
||||
--dist-dir ${openvino_wheels_output_dir}
|
||||
--build=${WHEEL_BUILD}
|
||||
--plat-name=${WHEEL_PLATFORM}
|
||||
# COMMAND ${CMAKE_COMMAND} -E remove ${SETUP_ENV_OUT}
|
||||
DEPENDS ${openvino_wheel_deps} ${SETUP_ENV_OUT}
|
||||
DEPENDS ${openvino_wheel_deps}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMENT "Building Python wheel ${openvino_wheel_name}"
|
||||
VERBATIM)
|
||||
|
@ -1,28 +0,0 @@
|
||||
defusedxml>=0.7.1
|
||||
scipy~=1.5.4
|
||||
jstyleson~=0.0.2
|
||||
numpy>=1.16.6,<1.20
|
||||
addict>=2.4.0
|
||||
pandas~=1.1.5
|
||||
hyperopt~=0.1.2
|
||||
networkx~=2.5
|
||||
tqdm>=4.54.1
|
||||
texttable~=1.6.3
|
||||
py-cpuinfo>=7.0.0
|
||||
PyYAML>=5.4.1
|
||||
pillow>=8.1.2
|
||||
scikit-image>=0.17.2
|
||||
scikit-learn>=0.24.1
|
||||
yamlloader>=0.5
|
||||
shapely>=1.7.1
|
||||
nibabel>=3.2.1
|
||||
pydicom>=2.1.2
|
||||
sentencepiece>=0.1.95
|
||||
tokenizers>=0.10.1
|
||||
editdistance>=0.5.3
|
||||
parasail>=1.2.4
|
||||
fast-ctc-decode>=0.2.5
|
||||
rawpy>=0.16.0
|
||||
nltk>=3.5
|
||||
opencv-python==4.5.*
|
||||
progress>=1.5
|
@ -1,22 +0,0 @@
|
||||
[options]
|
||||
py_modules =
|
||||
mo
|
||||
mo_tf
|
||||
mo_caffe
|
||||
mo_mxnet
|
||||
mo_onnx
|
||||
mo_kaldi
|
||||
|
||||
[options.package_data]
|
||||
* = *
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
|
||||
[metadata]
|
||||
license_files =
|
||||
readme*
|
||||
*LICENSE*
|
||||
*license*
|
||||
*third-party-programs*
|
||||
*EULA*
|
@ -1 +0,0 @@
|
||||
numpy>=1.16.6,<1.20
|
@ -1,32 +0,0 @@
|
||||
## OpenVINO™ Toolkit
|
||||
|
||||
OpenVINO™ toolkit quickly deploys applications and solutions that emulate human vision. Based on Convolutional Neural Networks (CNNs), the toolkit extends computer vision (CV) workloads across Intel® hardware, maximizing performance. The OpenVINO™ toolkit includes the Deep Learning Deployment Toolkit (DLDT).
|
||||
|
||||
OpenVINO™ toolkit:
|
||||
|
||||
- Enables CNN-based deep learning inference on the edge
|
||||
- Supports heterogeneous execution across an Intel® CPU, Intel® Integrated Graphics, Intel® Neural Compute Stick 2, and Intel® Vision Accelerator Design with Intel® Movidius™ VPUs
|
||||
- Speeds time-to-market via an easy-to-use library of computer vision functions and pre-optimized kernels
|
||||
- Includes optimized calls for computer vision standards, including OpenCV\* and OpenCL™
|
||||
|
||||
Operating Systems:
|
||||
- Ubuntu* 18.04 long-term support (LTS), 64-bit
|
||||
- Windows* 10, 64-bit
|
||||
- macOS* 10.15, 64-bit
|
||||
|
||||
## Install the Runtime Package Using the PyPI Repository
|
||||
1. Set up and update pip to the highest version:
|
||||
```sh
|
||||
python3 -m pip install --upgrade pip
|
||||
```
|
||||
2. Install the Intel® distribution of OpenVINO™ toolkit:
|
||||
```sh
|
||||
pip install openvino
|
||||
```
|
||||
|
||||
3. Verify that the package is installed:
|
||||
```sh
|
||||
python3 -c "from openvino.inference_engine import IECore"
|
||||
```
|
||||
|
||||
Now you are ready to develop and run your application.
|
@ -1,3 +1,3 @@
|
||||
setuptools>=53.0.0
|
||||
wheel>=0.36.2
|
||||
python-decouple>=3.4
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
[metadata]
|
||||
license_files =
|
||||
readme*
|
||||
*LICENSE*
|
||||
*license*
|
||||
*third-party-programs*
|
||||
*EULA*
|
||||
readme*
|
||||
*LICENSE*
|
||||
*license*
|
||||
*third-party-programs*
|
||||
../../../../licensing/runtime-third-party-programs.txt
|
||||
../../../../licensing/tbb_third-party-programs.txt
|
||||
../../../../licensing/onednn_third-party-programs.txt
|
||||
../../../../LICENSE
|
||||
|
||||
|
@ -21,7 +21,6 @@ from setuptools import setup, find_namespace_packages, Extension
|
||||
from setuptools.command.build_ext import build_ext
|
||||
from setuptools.command.build_clib import build_clib
|
||||
from setuptools.command.install import install
|
||||
from decouple import config
|
||||
|
||||
WHEEL_LIBS_INSTALL_DIR = os.path.join('openvino', 'libs')
|
||||
WHEEL_LIBS_PACKAGE = 'openvino.libs'
|
||||
@ -41,10 +40,11 @@ elif machine == 'aarch64':
|
||||
ARCH = 'arm64'
|
||||
|
||||
# The following variables can be defined in environment or .env file
|
||||
CMAKE_BUILD_DIR = config('CMAKE_BUILD_DIR', '.')
|
||||
OV_RUNTIME_LIBS_DIR = config('OV_RUNTIME_LIBS_DIR', f'runtime/{LIBS_DIR}/{ARCH}/{CONFIG}')
|
||||
TBB_LIBS_DIR = config('TBB_LIBS_DIR', f'runtime/3rdparty/tbb/{LIBS_DIR}')
|
||||
PY_PACKAGES_DIR = config('PY_PACKAGES_DIR', f'python/{PYTHON_VERSION}')
|
||||
SCRIPT_DIR = Path(__file__).resolve().parents[0]
|
||||
CMAKE_BUILD_DIR = os.getenv('CMAKE_BUILD_DIR', '.')
|
||||
OV_RUNTIME_LIBS_DIR = os.getenv('OV_RUNTIME_LIBS_DIR', f'runtime/{LIBS_DIR}/{ARCH}/{CONFIG}')
|
||||
TBB_LIBS_DIR = os.getenv('TBB_LIBS_DIR', f'runtime/3rdparty/tbb/{LIBS_DIR}')
|
||||
PY_PACKAGES_DIR = os.getenv('PY_PACKAGES_DIR', f'python/{PYTHON_VERSION}')
|
||||
LIBS_RPATH = '$ORIGIN' if sys.platform == 'linux' else '@loader_path'
|
||||
|
||||
LIB_INSTALL_CFG = {
|
||||
@ -428,28 +428,28 @@ if not any(pl in sys.platform for pl in platforms):
|
||||
sys.exit(f'Unsupported platform: {sys.platform}, expected: linux, win32, darwin')
|
||||
|
||||
# copy license file into the build directory
|
||||
package_license = config('WHEEL_LICENSE', '')
|
||||
package_license = os.getenv('WHEEL_LICENSE', SCRIPT_DIR.parents[3] / 'LICENSE')
|
||||
if os.path.exists(package_license):
|
||||
copyfile(package_license, 'LICENSE')
|
||||
|
||||
packages = find_namespace_packages(get_package_dir(PY_INSTALL_CFG))
|
||||
package_data: typing.Dict[str, list] = {}
|
||||
pkg_name = config('WHEEL_PACKAGE_NAME', 'openvino')
|
||||
pkg_name = os.getenv('WHEEL_PACKAGE_NAME', 'openvino')
|
||||
ext_modules = find_prebuilt_extensions(get_dir_list(PY_INSTALL_CFG)) if pkg_name == 'openvino' else []
|
||||
|
||||
setup(
|
||||
version=config('WHEEL_VERSION', '0.0.0'),
|
||||
build=config('WHEEL_BUILD', '000'),
|
||||
author_email=config('WHEEL_AUTHOR_EMAIL', 'openvino_pushbot@intel.com'),
|
||||
version=os.getenv('WHEEL_VERSION', '0.0.0'),
|
||||
build=os.getenv('WHEEL_BUILD', '000'),
|
||||
author_email=os.getenv('WHEEL_AUTHOR_EMAIL', 'openvino_pushbot@intel.com'),
|
||||
name=pkg_name,
|
||||
license=config('WHEEL_LICENCE_TYPE', 'OSI Approved :: Apache Software License'),
|
||||
author=config('WHEEL_AUTHOR', 'Intel Corporation'),
|
||||
description=config('WHEEL_DESC', 'Inference Engine Python* API'),
|
||||
install_requires=get_dependencies(config('WHEEL_REQUIREMENTS', 'meta/openvino.requirements.txt')),
|
||||
long_description=get_description(config('WHEEL_OVERVIEW', 'meta/pypi_overview.md')),
|
||||
license=os.getenv('WHEEL_LICENCE_TYPE', 'OSI Approved :: Apache Software License'),
|
||||
author=os.getenv('WHEEL_AUTHOR', 'Intel(R) Corporation'),
|
||||
description=os.getenv('WHEEL_DESC', 'OpenVINO(TM) Runtime'),
|
||||
install_requires=get_dependencies(os.getenv('WHEEL_REQUIREMENTS', SCRIPT_DIR.parents[0] / 'requirements.txt')),
|
||||
long_description=get_description(os.getenv('WHEEL_OVERVIEW', SCRIPT_DIR.parents[3] / 'docs/install_guides/pypi-openvino-rt.md')),
|
||||
long_description_content_type='text/markdown',
|
||||
download_url=config('WHEEL_DOWNLOAD_URL', 'https://github.com/openvinotoolkit/openvino/tags'),
|
||||
url=config('WHEEL_URL', 'https://docs.openvinotoolkit.org/latest/index.html'),
|
||||
download_url=os.getenv('WHEEL_DOWNLOAD_URL', 'https://github.com/openvinotoolkit/openvino/tags'),
|
||||
url=os.getenv('WHEEL_URL', 'https://docs.openvinotoolkit.org/latest/index.html'),
|
||||
cmdclass={
|
||||
'build': CustomBuild,
|
||||
'install': CustomInstall,
|
||||
|
@ -25,6 +25,8 @@ public:
|
||||
type = shape.is_static() ? ShapeType::Static : ShapeType::Dynamic;
|
||||
|
||||
initDims();
|
||||
|
||||
hasZeroDimensions = std::any_of(dims.begin(), dims.end(), [](size_t dim) { return dim == 0; } );
|
||||
}
|
||||
|
||||
explicit Shape(const InferenceEngine::SizeVector& shape) {
|
||||
@ -33,6 +35,8 @@ public:
|
||||
type = ShapeType::Static;
|
||||
|
||||
initDims();
|
||||
|
||||
hasZeroDimensions = std::any_of(dims.begin(), dims.end(), [](size_t dim) { return dim == 0; } );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,6 +110,10 @@ public:
|
||||
return type == ShapeType::Dynamic;
|
||||
}
|
||||
|
||||
bool hasZeroDims() const {
|
||||
return hasZeroDimensions;
|
||||
}
|
||||
|
||||
size_t getRank() const {
|
||||
return minDims.size();
|
||||
}
|
||||
@ -169,6 +177,8 @@ private:
|
||||
Dynamic
|
||||
} type {ShapeType::Static};
|
||||
|
||||
bool hasZeroDimensions = false;
|
||||
|
||||
VectorDims minDims;
|
||||
VectorDims maxDims;
|
||||
VectorDims dims;
|
||||
|
@ -16,7 +16,8 @@ CpuBlockedMemoryDesc::CpuBlockedMemoryDesc(InferenceEngine::Precision prc, const
|
||||
offsetPadding = 0;
|
||||
offsetPaddingToData.resize(dims.size(), 0);
|
||||
strides.resize(order.size());
|
||||
strides[strides.size() - 1] = 1;
|
||||
// for empty tensor case we fill all strides with 0 values
|
||||
strides[strides.size() - 1] = shape.hasZeroDims() ? 0 : 1;
|
||||
for (size_t i = 2; i <= order.size(); i++) {
|
||||
strides[strides.size() - i] = strides[strides.size() - (i - 1)] * blockedDims[blockedDims.size() - (i - 1)];
|
||||
}
|
||||
@ -33,6 +34,15 @@ CpuBlockedMemoryDesc::CpuBlockedMemoryDesc(InferenceEngine::Precision prc, const
|
||||
IE_THROW() << "CpuBlockedMemoryDesc doesn't support undefined blockedDims.";
|
||||
}
|
||||
|
||||
if (shape.hasZeroDims()) {
|
||||
const auto& dims = shape.getDims();
|
||||
for (size_t i = 0; i < shape.getRank(); i++) {
|
||||
if (dims[order[i]] == 0 && !dimsEqualWeak(blockedDims[i], 0)) {
|
||||
IE_THROW() << "Can't create CpuBlockedMemoryDesc. Mistmatch zero dims in dims and blocked dims";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->order = order;
|
||||
this->blockedDims = blockedDims;
|
||||
this->offsetPadding = offsetPadding;
|
||||
@ -44,7 +54,9 @@ CpuBlockedMemoryDesc::CpuBlockedMemoryDesc(InferenceEngine::Precision prc, const
|
||||
}
|
||||
|
||||
if (strides.empty() && !order.empty()) {
|
||||
if (std::any_of(this->blockedDims.begin(), this->blockedDims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
if (shape.hasZeroDims()) {
|
||||
this->strides.resize(order.size(), 0);
|
||||
} else if (std::any_of(this->blockedDims.begin(), this->blockedDims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
this->strides.resize(order.size(), Shape::UNDEFINED_DIM);
|
||||
} else {
|
||||
this->strides.resize(order.size());
|
||||
@ -54,6 +66,9 @@ CpuBlockedMemoryDesc::CpuBlockedMemoryDesc(InferenceEngine::Precision prc, const
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (shape.hasZeroDims() && std::any_of(strides.begin(), strides.end(), [](size_t stride) { return stride != 0; } )) {
|
||||
IE_THROW() << "Can't create CpuBlockedMemoryDesc with zero dim, but with non zero strides";
|
||||
}
|
||||
this->strides = strides;
|
||||
}
|
||||
|
||||
@ -92,11 +107,16 @@ bool CpuBlockedMemoryDesc::isCompatible(const DnnlBlockedMemoryDesc &rhs) const
|
||||
return rhs.isCompatible(*this);
|
||||
}
|
||||
|
||||
bool CpuBlockedMemoryDesc::canComputeMemSizeZeroDims() const {
|
||||
return getShape().hasZeroDims() && getOffsetPadding() != Shape::UNDEFINED_DIM;
|
||||
}
|
||||
|
||||
size_t CpuBlockedMemoryDesc::getCurrentMemSizeImp() const {
|
||||
int64_t e_size = getOffsetPadding() + 1; // size in bytes (from begin of data to last element)
|
||||
for (int j = 0; j < getBlockDims().size(); j++)
|
||||
e_size += (getBlockDims()[j] - 1) * getStrides()[j];
|
||||
|
||||
if (!getShape().hasZeroDims()) {
|
||||
for (int j = 0; j < getBlockDims().size(); j++)
|
||||
e_size += (getBlockDims()[j] - 1) * getStrides()[j];
|
||||
}
|
||||
|
||||
e_size *= getPrecision() == InferenceEngine::Precision::BIN ? 1 : getPrecision().size();
|
||||
|
||||
@ -104,14 +124,14 @@ size_t CpuBlockedMemoryDesc::getCurrentMemSizeImp() const {
|
||||
}
|
||||
|
||||
size_t CpuBlockedMemoryDesc::getMaxMemSize() const {
|
||||
if (shape.isStatic()) {
|
||||
if (shape.isStatic() || shape.hasZeroDims()) {
|
||||
return getCurrentMemSize();
|
||||
}
|
||||
|
||||
auto& maxDims = shape.getMaxDims();
|
||||
const auto& maxDims = shape.getMaxDims();
|
||||
if (std::any_of(maxDims.begin(), maxDims.end(), [](size_t x){ return Shape::UNDEFINED_DIM == x ||
|
||||
// WA: for some nodes ngraph compute upper bound depending on precision max value
|
||||
std::numeric_limits<int32_t>::max() == x; })) {
|
||||
x >= std::numeric_limits<int32_t>::max(); })) {
|
||||
return UNDEFINED_SIZE;
|
||||
}
|
||||
|
||||
@ -270,15 +290,23 @@ bool CpuBlockedMemoryDesc::blocksExtended() const {
|
||||
}
|
||||
|
||||
size_t CpuBlockedMemoryDesc::getPaddedElementsCount() const {
|
||||
if (std::any_of(blockedDims.begin(), blockedDims.end(), [](Dim dim) { return dim == Shape::UNDEFINED_DIM; }))
|
||||
if (getShape().hasZeroDims()) {
|
||||
return 0;
|
||||
}
|
||||
if (std::any_of(blockedDims.begin(), blockedDims.end(), [](Dim dim) { return dim == Shape::UNDEFINED_DIM; })) {
|
||||
IE_THROW() << "Can't compute padded elements count for non undefined blocked dims";
|
||||
}
|
||||
return std::accumulate(blockedDims.begin(), blockedDims.end(), size_t{1}, std::multiplies<size_t>());
|
||||
}
|
||||
|
||||
MemoryDescPtr CpuBlockedMemoryDesc::cloneWithUndefStridesAndOffset() const {
|
||||
const auto orderSize = getOrder().size();
|
||||
return std::make_shared<CpuBlockedMemoryDesc>(getPrecision(), getShape(), getBlockDims(), getOrder(), Shape::UNDEFINED_DIM,
|
||||
VectorDims(orderSize, 0), VectorDims(orderSize, Shape::UNDEFINED_DIM));
|
||||
CpuBlockedMemoryDescPtr newDesc = std::make_shared<CpuBlockedMemoryDesc>(*this);
|
||||
newDesc->strides = VectorDims(orderSize, Shape::UNDEFINED_DIM);
|
||||
newDesc->offsetPadding = Shape::UNDEFINED_DIM;
|
||||
newDesc->offsetPaddingToData = VectorDims(orderSize, 0);
|
||||
newDesc->status = descStatus::Undefined;
|
||||
return newDesc;
|
||||
}
|
||||
|
||||
MemoryDescPtr CpuBlockedMemoryDesc::cloneWithDefaultStridesAndOffset() const {
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
|
||||
private:
|
||||
size_t getElementOffset(size_t elemNumber) const override;
|
||||
bool canComputeMemSizeZeroDims() const override;
|
||||
size_t getCurrentMemSizeImp() const override;
|
||||
size_t getOffset(const InferenceEngine::SizeVector& v) const;
|
||||
bool isPlainFormat() const;
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
*/
|
||||
size_t getCurrentMemSize() const {
|
||||
size_t retVal = UNDEFINED_SIZE;
|
||||
if (isDefined()) {
|
||||
if (canComputeMemSize()) {
|
||||
retVal = getCurrentMemSizeImp();
|
||||
}
|
||||
return retVal;
|
||||
@ -140,8 +140,13 @@ protected:
|
||||
// Get offset to the n'th element. Returns physical index of the element by the logical one considering padding, layout, blocking etc.
|
||||
virtual size_t getElementOffset(size_t elemNumber) const = 0;
|
||||
|
||||
virtual bool canComputeMemSizeZeroDims() const = 0;
|
||||
virtual bool isDefinedImp() const = 0;
|
||||
|
||||
bool canComputeMemSize() const {
|
||||
return isDefined() || canComputeMemSizeZeroDims();
|
||||
}
|
||||
|
||||
virtual MemoryDescPtr cloneWithNewDimsImp(const VectorDims& dims) const = 0;
|
||||
|
||||
MemoryDescType type;
|
||||
|
@ -48,17 +48,37 @@ DnnlBlockedMemoryDesc MemoryDescUtils::convertToDnnlBlockedMemoryDesc(const Memo
|
||||
CpuBlockedMemoryDesc MemoryDescUtils::convertToCpuBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc) {
|
||||
if (desc.getLayout() == InferenceEngine::Layout::ANY)
|
||||
IE_THROW() << "Cannot convert InferenceEngine::TensorDesc with ANY layout to CpuBlockedMemoryDesc";
|
||||
const auto &blkDesc = desc.getBlockingDesc();
|
||||
return CpuBlockedMemoryDesc(desc.getPrecision(), Shape(desc.getDims()), blkDesc.getBlockDims(), blkDesc.getOrder(), blkDesc.getOffsetPadding(),
|
||||
blkDesc.getOffsetPaddingToData(), blkDesc.getStrides());
|
||||
|
||||
const auto& blkDesc = desc.getBlockingDesc();
|
||||
const auto& dims = desc.getDims();
|
||||
|
||||
auto strides = blkDesc.getStrides();
|
||||
// for empty tensor case InferenceEngine::TensorDesc fill strides with non zero values before first 0 dims
|
||||
// i.e. dims[1, 0, 2, 3] -> strides [0, 6, 3, 1]
|
||||
if (std::any_of(dims.begin(), dims.end(), [](size_t dim){ return dim == 0; })) {
|
||||
std::fill(strides.begin(), strides.end(), 0);
|
||||
}
|
||||
|
||||
return CpuBlockedMemoryDesc(desc.getPrecision(), Shape(dims), blkDesc.getBlockDims(), blkDesc.getOrder(), blkDesc.getOffsetPadding(),
|
||||
blkDesc.getOffsetPaddingToData(), strides);
|
||||
}
|
||||
|
||||
DnnlBlockedMemoryDesc MemoryDescUtils::convertToDnnlBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc) {
|
||||
const auto &blkDesc = desc.getBlockingDesc();
|
||||
if (desc.getLayout() == InferenceEngine::Layout::ANY)
|
||||
IE_THROW() << "Cannot convert InferenceEngine::TensorDesc with ANY layout to DnnlBlockedMemoryDesc";
|
||||
|
||||
const auto& blkDesc = desc.getBlockingDesc();
|
||||
const auto& dims = desc.getDims();
|
||||
|
||||
auto strides = blkDesc.getStrides();
|
||||
// for empty tensor case InferenceEngine::TensorDesc fill strides with non zero values before first 0 dims
|
||||
// i.e. dims[1, 0, 2, 3] -> strides [0, 6, 3, 1]
|
||||
if (std::any_of(dims.begin(), dims.end(), [](size_t dim){ return dim == 0; })) {
|
||||
std::fill(strides.begin(), strides.end(), 0);
|
||||
}
|
||||
|
||||
return DnnlBlockedMemoryDesc(desc.getPrecision(), Shape(desc.getDims()), blkDesc.getBlockDims(), blkDesc.getOrder(), blkDesc.getOffsetPadding(),
|
||||
blkDesc.getOffsetPaddingToData(), blkDesc.getStrides());
|
||||
blkDesc.getOffsetPaddingToData(), strides);
|
||||
}
|
||||
|
||||
BlockedMemoryDescPtr MemoryDescUtils::convertToBlockedMemoryDesc(const MemoryDescPtr &desc) {
|
||||
@ -80,9 +100,16 @@ InferenceEngine::Blob::Ptr MemoryDescUtils::interpretAsBlob(const MKLDNNMemory &
|
||||
|
||||
InferenceEngine::TensorDesc MemoryDescUtils::convertToTensorDesc(const MemoryDesc& desc) {
|
||||
if (auto blockingDesc = dynamic_cast<const BlockedMemoryDesc*>(&desc)) {
|
||||
return InferenceEngine::TensorDesc(blockingDesc->getPrecision(), blockingDesc->getShape().getStaticDims(),
|
||||
{blockingDesc->getBlockDims(), blockingDesc->getOrder(), blockingDesc->getOffsetPadding(),
|
||||
blockingDesc->getOffsetPaddingToData(), blockingDesc->getStrides()});
|
||||
InferenceEngine::BlockingDesc blkDesc = desc.getShape().hasZeroDims() ? InferenceEngine::BlockingDesc(blockingDesc->getBlockDims(),
|
||||
blockingDesc->getOrder(),
|
||||
blockingDesc->getOffsetPadding(),
|
||||
blockingDesc->getOffsetPaddingToData()) :
|
||||
InferenceEngine::BlockingDesc(blockingDesc->getBlockDims(),
|
||||
blockingDesc->getOrder(),
|
||||
blockingDesc->getOffsetPadding(),
|
||||
blockingDesc->getOffsetPaddingToData(),
|
||||
blockingDesc->getStrides());
|
||||
return InferenceEngine::TensorDesc(blockingDesc->getPrecision(), blockingDesc->getShape().getStaticDims(), blkDesc);
|
||||
} else {
|
||||
IE_THROW() << "Cannot convert MemoryDesc to InferenceEngine::TensorDesc";
|
||||
}
|
||||
|
@ -15,12 +15,17 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, con
|
||||
const auto &dims = shape.getDims();
|
||||
|
||||
if (!strides.empty()) { // custom strides
|
||||
if (shape.hasZeroDims() && std::any_of(strides.begin(), strides.end(), [](size_t stride) { return stride != 0; } )) {
|
||||
IE_THROW() << "Can't create DnnlBlockedMemoryDesc with zero dim, but with non zero strides";
|
||||
}
|
||||
desc = {MKLDNNExtensionUtils::convertToDnnlDims(dims),
|
||||
MKLDNNExtensionUtils::IEPrecisionToDataType(prc),
|
||||
MKLDNNExtensionUtils::convertToDnnlDims(strides)};
|
||||
} else {
|
||||
mkldnn::memory::dims plain_strides;
|
||||
if (std::any_of(dims.begin(), dims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
if (shape.hasZeroDims()) {
|
||||
plain_strides.resize(ndims, 0);
|
||||
} else if (std::any_of(dims.begin(), dims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
plain_strides.resize(ndims, DNNL_RUNTIME_DIM_VAL);
|
||||
} else {
|
||||
plain_strides.resize(ndims, 1);
|
||||
@ -58,8 +63,8 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, con
|
||||
* Limitation of conversion first N elements of order should be permutation of [0,1,2 ... N]
|
||||
*/
|
||||
DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, const Shape& shape, const VectorDims& blockedDims,
|
||||
const VectorDims& order, size_t offsetPadding, const VectorDims& offsetPaddingToData,
|
||||
const VectorDims& strides) : MemoryDesc(shape, DnnlBlocked) {
|
||||
const VectorDims& order, size_t offsetPadding, const VectorDims& offsetPaddingToData,
|
||||
const VectorDims& strides) : MemoryDesc(shape, DnnlBlocked) {
|
||||
using namespace mkldnn;
|
||||
// scalar case
|
||||
if (shape.getRank() == 0) {
|
||||
@ -90,8 +95,8 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, con
|
||||
IE_THROW() << "DnnlBlockedMemoryDesc doesn't support undefined order.";
|
||||
}
|
||||
|
||||
if (std::any_of(blockedDims.begin() + shape.getRank(), blockedDims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
IE_THROW() << "DnnlBlockedMemoryDesc doesn't support undefined blockedDims.";
|
||||
if (std::any_of(blockedDims.begin() + shape.getRank(), blockedDims.end(), [](size_t val) { return val == Shape::UNDEFINED_DIM || val == 0; })) {
|
||||
IE_THROW() << "DnnlBlockedMemoryDesc doesn't support undefined or zero blockedDims.";
|
||||
}
|
||||
|
||||
auto dims = MKLDNNExtensionUtils::convertToDnnlDims(shape.getDims());
|
||||
@ -106,7 +111,12 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, con
|
||||
|
||||
size_t inner_ndims = order.size() - dims.size();
|
||||
|
||||
const bool emptyDesc = shape.hasZeroDims();
|
||||
if (!strides.empty()) {
|
||||
if (emptyDesc && std::any_of(strides.begin(), strides.end(), [](size_t dim) { return dim != 0; } )) {
|
||||
IE_THROW() << "Can't create DnnlBlockedMemoryDesc with zero dim, but with non zero strides";
|
||||
}
|
||||
|
||||
bool is_descending_strides = true;
|
||||
for (int i = 1; i < strides.size(); i++) {
|
||||
is_descending_strides &= (strides[i - 1] >= strides[i]);
|
||||
@ -118,7 +128,7 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(InferenceEngine::Precision prc, con
|
||||
IE_THROW() << "Can not construct DnnlBlockedMemoryDesc from strides: " << vec2str(strides);
|
||||
}
|
||||
|
||||
if (!strides.empty() && std::none_of(strides.begin(), strides.end(), [](size_t x) { return Shape::UNDEFINED_DIM == x; })) {
|
||||
if (!strides.empty() && !emptyDesc && std::none_of(strides.begin(), strides.end(), [](size_t x) { return Shape::UNDEFINED_DIM == x; })) {
|
||||
bool inner_block_are_dense = one_of(strides.back(), 0, 1); // stride 1 - is dense case, 0 - broad casted
|
||||
for (int i = outer_ndims; i < strides.size() - 1; i++) {
|
||||
inner_block_are_dense &= (strides[i] == strides[i + 1] * blockedDims[i + 1]);
|
||||
@ -203,6 +213,11 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(const Shape& shape, mkldnn::memory:
|
||||
order.swap(perm);
|
||||
order.insert(order.end(), inner_idxs.begin(), inner_idxs.end());
|
||||
|
||||
if (shape.hasZeroDims()) {
|
||||
auto& blk = desc.data.format_desc.blocking;
|
||||
std::fill(std::begin(blk.strides), std::begin(blk.strides) + desc.data.ndims, 0);
|
||||
}
|
||||
|
||||
initBlockedParams();
|
||||
}
|
||||
|
||||
@ -296,6 +311,12 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(const mkldnn::memory::desc& mdesc)
|
||||
IE_THROW(Unexpected) << "Can't create DnnlBlockedMemoryDesc from not blocking desc";
|
||||
|
||||
order = extractOrder(desc);
|
||||
|
||||
if (getShape().hasZeroDims()) {
|
||||
auto& blk = desc.data.format_desc.blocking;
|
||||
std::fill(std::begin(blk.strides), std::begin(blk.strides) + desc.data.ndims, 0);
|
||||
}
|
||||
|
||||
initBlockedParams();
|
||||
}
|
||||
|
||||
@ -368,6 +389,7 @@ bool DnnlBlockedMemoryDesc::isTailCFormat() const {
|
||||
static mkldnn::memory::desc cloneDescWithNewDims(const mkldnn::memory::desc& desc, const VectorDims& dims, const VectorDims& order) {
|
||||
using namespace dnnl::impl::utils;
|
||||
auto mklDims = MKLDNNExtensionUtils::convertToDnnlDims(dims);
|
||||
const auto offsetPadding = desc.data.offset0;
|
||||
mkldnn::memory::desc newMklDesc = desc;
|
||||
array_copy(newMklDesc.data.dims, mklDims.data(), mklDims.size());
|
||||
std::vector<int> perm(order.begin(), order.begin() + mklDims.size());
|
||||
@ -379,6 +401,9 @@ static mkldnn::memory::desc cloneDescWithNewDims(const mkldnn::memory::desc& des
|
||||
if (retCode != dnnl::impl::status::success) {
|
||||
IE_THROW() << "Can not clone DnnlBlockedMemoryDesc with dims: " << MemoryDescUtils::dims2str(dims);
|
||||
}
|
||||
// dnnl::impl::fill_blocked always set offset0 to 0
|
||||
// so we need to restore actual value
|
||||
newMklDesc.data.offset0 = offsetPadding;
|
||||
return newMklDesc;
|
||||
}
|
||||
|
||||
@ -476,14 +501,14 @@ bool DnnlBlockedMemoryDesc::isSame(mkldnn::memory::format_tag fmt) const {
|
||||
}
|
||||
|
||||
size_t DnnlBlockedMemoryDesc::getMaxMemSize() const {
|
||||
if (shape.isStatic()) {
|
||||
if (shape.isStatic() || shape.hasZeroDims()) {
|
||||
return getCurrentMemSize();
|
||||
}
|
||||
|
||||
auto& maxDims = shape.getMaxDims();
|
||||
const auto& maxDims = shape.getMaxDims();
|
||||
if (std::any_of(maxDims.begin(), maxDims.end(), [](size_t x){ return Shape::UNDEFINED_DIM == x ||
|
||||
// WA: for some nodes ngraph compute upper bound depending on precision max value
|
||||
std::numeric_limits<int32_t>::max() == x; })) {
|
||||
x >= std::numeric_limits<int32_t>::max(); })) {
|
||||
return UNDEFINED_SIZE;
|
||||
}
|
||||
|
||||
@ -492,6 +517,13 @@ size_t DnnlBlockedMemoryDesc::getMaxMemSize() const {
|
||||
}
|
||||
|
||||
size_t DnnlBlockedMemoryDesc::getPaddedElementsCount() const {
|
||||
if (getShape().hasZeroDims()) {
|
||||
return 0;
|
||||
}
|
||||
if (std::any_of(std::begin(desc.data.padded_dims), std::begin(desc.data.padded_dims) + desc.data.ndims,
|
||||
[](dnnl_dim_t dim) { return dim == DNNL_RUNTIME_DIM_VAL; })) {
|
||||
IE_THROW() << "Can't compute padded elements count for non undefined blocked dims";
|
||||
}
|
||||
return std::accumulate(std::begin(desc.data.padded_dims), std::begin(desc.data.padded_dims) + desc.data.ndims, size_t{1},
|
||||
std::multiplies<int64_t>());
|
||||
}
|
||||
@ -548,7 +580,7 @@ void DnnlBlockedMemoryDesc::initStrides() {
|
||||
const size_t total_ndims = outer_ndims + inner_ndims;
|
||||
|
||||
// strides of inner dims. In case of 4i16o4i will be {64, 4, 1}
|
||||
VectorDims inner_strides(inner_ndims, 1);
|
||||
VectorDims inner_strides(inner_ndims, getShape().hasZeroDims() ? 0 : 1);
|
||||
for (size_t i = 1; i < blk_desc.inner_nblks; i++) {
|
||||
inner_strides[blk_desc.inner_nblks - 1 - i] = inner_strides[blk_desc.inner_nblks - i] * blk_desc.inner_blks[blk_desc.inner_nblks - i];
|
||||
}
|
||||
@ -600,7 +632,9 @@ void DnnlBlockedMemoryDesc::recomputeDefaultStrides() {
|
||||
IE_THROW() << "Can't recompute stride: order size != blocked dims size";
|
||||
|
||||
auto &oneDnnStrides = desc.data.format_desc.blocking.strides;
|
||||
if (std::any_of(blockedDims.begin(), blockedDims.end(), [](Dim val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
if (getShape().hasZeroDims()) {
|
||||
std::fill(std::begin(oneDnnStrides), std::begin(oneDnnStrides) + getShape().getRank(), 0);
|
||||
} else if (std::any_of(blockedDims.begin(), blockedDims.end(), [](Dim val) { return val == Shape::UNDEFINED_DIM; })) {
|
||||
std::fill(std::begin(oneDnnStrides), std::begin(oneDnnStrides) + rank, DNNL_RUNTIME_DIM_VAL);
|
||||
initStrides();
|
||||
} else {
|
||||
@ -633,6 +667,11 @@ DnnlBlockedMemoryDesc::DnnlBlockedMemoryDesc(const mkldnn::memory::desc& mdesc,
|
||||
|
||||
desc = cloneDescWithNewDims(mdesc, shape.getDims(), order);
|
||||
|
||||
if (shape.hasZeroDims()) {
|
||||
auto& blk = desc.data.format_desc.blocking;
|
||||
std::fill(std::begin(blk.strides), std::begin(blk.strides) + desc.data.ndims, 0);
|
||||
}
|
||||
|
||||
initBlockedParams();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
explicit DnnlBlockedMemoryDesc(const mkldnn::memory::desc& mdesc);
|
||||
|
||||
// Creates DnnlBlockedMemoryDesc using the shape parameter as a true shape but all other params (layout, blocks, etc.) are used from the mdesc, but
|
||||
// the mdesc own shape is ignored. The main purpose of this constructor is making dynamic descriptor form some dummy mdesc, which stores info about
|
||||
// the mdesc own shape is ignored. The main purpose of this constructor is making dynamic descriptor from some dummy mdesc, which stores info about
|
||||
// layout, blocking, strides, etc., and the provided dynamic shape.
|
||||
DnnlBlockedMemoryDesc(const mkldnn::memory::desc& mdesc, const Shape& shape);
|
||||
|
||||
|
@ -15,6 +15,10 @@ DnnlMemoryDesc::DnnlMemoryDesc(const mkldnn::memory::desc& desc) :
|
||||
IE_THROW(Unexpected) << "Memory format any is prohibited!";
|
||||
}
|
||||
|
||||
bool DnnlMemoryDesc::canComputeMemSizeZeroDims() const {
|
||||
return getShape().hasZeroDims() && desc.data.offset0 != DNNL_RUNTIME_DIM_VAL;
|
||||
}
|
||||
|
||||
size_t DnnlMemoryDesc::getCurrentMemSizeImp() const {
|
||||
return MKLDNNExtensionUtils::getMemSizeForDnnlDesc(desc);
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
|
||||
size_t getElementOffset(size_t elemNumber) const override;
|
||||
|
||||
bool canComputeMemSizeZeroDims() const override;
|
||||
size_t getCurrentMemSizeImp() const override;
|
||||
bool isDefinedImp() const override;
|
||||
MemoryDescPtr cloneWithNewDimsImp(const VectorDims& dims) const override;
|
||||
|
@ -384,15 +384,16 @@ void MKLDNNGraph::InitOptimalPrimitiveDescriptors() {
|
||||
void MKLDNNGraph::ExtractConstantAndExecutableNodes() {
|
||||
OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::MKLDNN_LT, "MKLDNNGraph::ExtractConstantAndExecutableNodes");
|
||||
for (const auto& graphNode : graphNodes) {
|
||||
if (graphNode->isConstant())
|
||||
if (graphNode->isConstant()) {
|
||||
constantGraphNodes.emplace_back(graphNode);
|
||||
else if (CPU_DEBUG_CAPS_ALWAYS_TRUE(graphNode->isExecutable()))
|
||||
} else if (CPU_DEBUG_CAPS_ALWAYS_TRUE(graphNode->isExecutable())) {
|
||||
/* @todo
|
||||
* Revise implementation.
|
||||
* With current way it is possible that with debug_caps enabled
|
||||
* we execute a node, which is not ready to be executed
|
||||
*/
|
||||
executableGraphNodes.emplace_back(graphNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,7 +793,7 @@ void MKLDNNGraph::PullOutputData(BlobMap &out) {
|
||||
|
||||
// check for empty output blob
|
||||
if (std::any_of(outDims.begin(), outDims.end(), [](const Dim dim) {return dim == 0;})) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto srcPrec = actualDesc.getPrecision();
|
||||
@ -835,10 +836,11 @@ inline void MKLDNNGraph::ExecuteNode(const MKLDNNNodePtr& node, const mkldnn::st
|
||||
DUMP(node, infer_count);
|
||||
OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, node->profiling.execute);
|
||||
|
||||
if (node->isDynamicNode())
|
||||
if (node->isDynamicNode()) {
|
||||
node->executeDynamic(stream);
|
||||
else
|
||||
} else {
|
||||
node->execute(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNGraph::Infer(MKLDNNInferRequest* request, int batch) {
|
||||
@ -854,7 +856,6 @@ void MKLDNNGraph::Infer(MKLDNNInferRequest* request, int batch) {
|
||||
|
||||
if (request)
|
||||
request->ThrowIfCanceled();
|
||||
|
||||
ExecuteNode(node, stream);
|
||||
}
|
||||
|
||||
@ -993,22 +994,6 @@ Config MKLDNNGraph::getProperty() const {
|
||||
return config;
|
||||
}
|
||||
|
||||
Blob::Ptr MKLDNNGraph::getInputBlob(const std::string& name) {
|
||||
auto itr = inputNodesMap.find(name);
|
||||
if (itr != inputNodesMap.end()) {
|
||||
return MemoryDescUtils::interpretAsBlob(itr->second->getChildEdgeAt(0)->getMemory());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Blob::Ptr MKLDNNGraph::getOutputBlob(const std::string& name) {
|
||||
auto itr = outputNodesMap.find(name);
|
||||
if (itr != outputNodesMap.end()) {
|
||||
return MemoryDescUtils::interpretAsBlob(itr->second->getParentEdgeAt(0)->getMemory());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MKLDNNGraph::RemoveEdge(MKLDNNEdgePtr& edge) {
|
||||
for (auto it = graphEdges.begin(); it != graphEdges.end(); it++) {
|
||||
if ((*it) == edge) {
|
||||
|
@ -44,9 +44,6 @@ public:
|
||||
void setProperty(const std::map<std::string, std::string> &properties);
|
||||
Config getProperty() const;
|
||||
|
||||
InferenceEngine::Blob::Ptr getInputBlob(const std::string& name);
|
||||
InferenceEngine::Blob::Ptr getOutputBlob(const std::string& name);
|
||||
|
||||
template<typename NET>
|
||||
void CreateGraph(NET &network,
|
||||
const MKLDNNExtensionManager::Ptr& extMgr,
|
||||
|
@ -190,8 +190,9 @@ void MKLDNNPlugin::MKLDNNInferRequest::redefineMemoryForInputNodes() {
|
||||
const auto inputNode = cpuInputNodes.find(blob.first);
|
||||
if (inputNode == cpuInputNodes.end())
|
||||
IE_THROW() << "CPU execution graph doesn't contain input node with name: " << blob.first;
|
||||
if (inputNode->second->isDynamicNode())
|
||||
if (inputNode->second->isDynamicNode()) {
|
||||
inputNode->second->redefineOutputMemory({blob.second->getTensorDesc().getDims()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ MKLDNNNode::MKLDNNNode(const std::shared_ptr<ngraph::Node>& op, const mkldnn::en
|
||||
for (size_t i = 0; i < op->get_input_size(); i++) {
|
||||
const auto &shape = op->get_input_partial_shape(i);
|
||||
if (shape.rank().is_dynamic()) {
|
||||
IE_THROW(Unexpected) << "CPU plug-in doesn't support operation with dynamic rank";
|
||||
IE_THROW(Unexpected) << "CPU plug-in doesn't support " << getTypeStr() << " operation with dynamic rank. Operation name: " << getName();
|
||||
}
|
||||
|
||||
bool isScalar = shape.rank().get_length() == 0;
|
||||
@ -99,7 +99,7 @@ MKLDNNNode::MKLDNNNode(const std::shared_ptr<ngraph::Node>& op, const mkldnn::en
|
||||
for (size_t i = 0; i < op->get_output_size(); i++) {
|
||||
const auto &shape = op->get_output_partial_shape(i);
|
||||
if (shape.rank().is_dynamic()) {
|
||||
IE_THROW(Unexpected) << "CPU plug-in doesn't support operation with dynamic rank";
|
||||
IE_THROW(Unexpected) << "CPU plug-in doesn't support " << getTypeStr() << " operation with dynamic rank. Operation name: " << getName();
|
||||
}
|
||||
|
||||
bool isScalar = shape.rank().get_length() == 0;
|
||||
@ -230,6 +230,15 @@ bool MKLDNNNode::isEdgesEmpty(const std::vector<MKLDNNEdgeWeakPtr>& edges) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void MKLDNNNode::createPrimitive() {
|
||||
if (inputShapesDefined() && isExecutable()) {
|
||||
if (needPrepareParams()) {
|
||||
prepareParams();
|
||||
}
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNNode::selectOptimalPrimitiveDescriptor() {
|
||||
selectPreferPrimitiveDescriptor(getPrimitivesPriority(), false);
|
||||
}
|
||||
@ -510,12 +519,14 @@ void MKLDNNNode::executeDynamic(mkldnn::stream strm) {
|
||||
if (needShapeInfer()) {
|
||||
redefineOutputMemory(shapeInfer());
|
||||
}
|
||||
if (needPrepareParams()) {
|
||||
IE_ASSERT(inputShapesDefined()) << "Can't prepare params for " << getTypeStr() << " node with name: " << getName() <<
|
||||
" since the input shapes are not defined.";
|
||||
prepareParams();
|
||||
if (isExecutable()) {
|
||||
if (needPrepareParams()) {
|
||||
IE_ASSERT(inputShapesDefined()) << "Can't prepare params for " << getTypeStr() << " node with name: " << getName() <<
|
||||
" since the input shapes are not defined.";
|
||||
prepareParams();
|
||||
}
|
||||
executeDynamicImpl(strm);
|
||||
}
|
||||
executeDynamicImpl(strm);
|
||||
updateLastInputDims();
|
||||
}
|
||||
|
||||
@ -1333,6 +1344,36 @@ std::pair<std::vector<float>, std::vector<float>> MKLDNNNode::getScalesAndShifts
|
||||
return {scales, shifts};
|
||||
}
|
||||
|
||||
bool MKLDNNNode::isInputTensorAtPortEmpty(size_t port) const {
|
||||
if (inputShapes.size() <= port) {
|
||||
IE_THROW() << "Incorrect input port number for node " << getName();
|
||||
}
|
||||
return getParentEdgesAtPort(port)[0]->getMemory().GetShape().hasZeroDims();
|
||||
}
|
||||
|
||||
bool MKLDNNNode::isOutputTensorAtPortEmpty(size_t port) const {
|
||||
if (outputShapes.size() <= port) {
|
||||
IE_THROW() << "Incorrect output port number for node " << getName();
|
||||
}
|
||||
return getChildEdgesAtPort(port)[0]->getMemory().GetShape().hasZeroDims();
|
||||
}
|
||||
|
||||
bool MKLDNNNode::hasEmptyInputTensors() const {
|
||||
for (size_t i = 0; i < getParentEdges().size(); i++) {
|
||||
if (isInputTensorAtPortEmpty(i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MKLDNNNode::hasEmptyOutputTensors() const {
|
||||
for (size_t i = 0; i < outputShapes.size(); i++) {
|
||||
if (isOutputTensorAtPortEmpty(i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MKLDNNNode::inputShapesDefined() const {
|
||||
for (size_t i = 0; i < getParentEdges().size(); i++) {
|
||||
if (!getParentEdgesAtPort(i)[0]->getMemory().getDesc().isDefined())
|
||||
@ -1406,8 +1447,11 @@ std::vector<VectorDims> MKLDNNNode::shapeInferGeneric(const std::vector<Shape>&
|
||||
std::vector<VectorDims> newOutputShapes(opToShapeInfer->get_output_size());
|
||||
for (size_t i = 0; i < newOutputShapes.size(); i++) {
|
||||
const auto &partShape = opToShapeInfer->get_output_partial_shape(i);
|
||||
if (partShape.is_dynamic())
|
||||
IE_THROW(NotImplemented) << "CPU plug-in doesn't support default shape infer for nodes with internal dynamism";
|
||||
if (partShape.is_dynamic()) {
|
||||
IE_THROW(NotImplemented) << "CPU plug-in doesn't support default shape infer for node " << getTypeStr()
|
||||
<< " with internal dynamism. Operation name: " << getName();
|
||||
}
|
||||
|
||||
newOutputShapes[i] = partShape.get_shape();
|
||||
}
|
||||
return newOutputShapes;
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
|
||||
// must be called only after MKLDNNGraph::InitEdges()
|
||||
virtual bool isExecutable() const {
|
||||
return true;
|
||||
return !hasEmptyInputTensors();
|
||||
}
|
||||
|
||||
bool isConstant();
|
||||
@ -370,7 +370,7 @@ public:
|
||||
*/
|
||||
virtual void filterSupportedPrimitiveDescriptors();
|
||||
|
||||
virtual void createPrimitive() = 0;
|
||||
virtual void createPrimitive();
|
||||
|
||||
virtual void selectOptimalPrimitiveDescriptor();
|
||||
virtual void initOptimalPrimitiveDescriptor();
|
||||
@ -728,6 +728,12 @@ protected:
|
||||
|
||||
bool isDynamic = false;
|
||||
|
||||
bool isInputTensorAtPortEmpty(size_t port) const;
|
||||
bool isOutputTensorAtPortEmpty(size_t port) const;
|
||||
|
||||
bool hasEmptyInputTensors() const;
|
||||
bool hasEmptyOutputTensors() const;
|
||||
|
||||
bool inputShapesDefined() const;
|
||||
bool outputShapesDefined() const;
|
||||
bool shapesDefined() const;
|
||||
|
@ -80,6 +80,7 @@
|
||||
#include "nodes/mkldnn_reduce_node.h"
|
||||
#include "nodes/mkldnn_if_node.h"
|
||||
#include "nodes/mkldnn_ctc_greedy_decoder_node.h"
|
||||
#include "nodes/mkldnn_non_zero.h"
|
||||
|
||||
#define MKLDNN_NODE(__prim, __type) \
|
||||
registerNodeIfRequired(MKLDNNPlugin, __prim, __type, MKLDNNNodeImpl<__prim>)
|
||||
@ -168,4 +169,5 @@ MKLDNNPlugin::MKLDNNNode::NodesFactory::NodesFactory()
|
||||
MKLDNN_NODE(MKLDNNTopKNode, TopK);
|
||||
MKLDNN_NODE(MKLDNNStridedSliceNode, StridedSlice);
|
||||
MKLDNN_NODE(MKLDNNGRNNode, GRN);
|
||||
MKLDNN_NODE(MKLDNNNonZeroNode, NonZero);
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "dnnl_executor.h"
|
||||
|
||||
using namespace mkldnn;
|
||||
using namespace MKLDNNPlugin;
|
||||
|
||||
DnnlExecutor::IntermReorder::IntermReorder(const mkldnn::memory::desc& descSrc,
|
||||
const mkldnn::memory::desc& descDst,
|
||||
const mkldnn::engine& engine) : m_descSrc(descSrc), m_descDst(descDst) {
|
||||
auto reorderPd = mkldnn::reorder::primitive_desc(engine, descSrc, engine, descDst);
|
||||
m_reorder = mkldnn::reorder(reorderPd);
|
||||
}
|
||||
|
||||
void DnnlExecutor::IntermReorder::exec(mkldnn::memory& memSrc, mkldnn::memory& memDst, mkldnn::stream strm) {
|
||||
m_reorder.execute(strm, memSrc, memDst);
|
||||
}
|
||||
|
||||
void DnnlExecutor::exec(std::unordered_map<int, mkldnn::memory> primArgs, mkldnn::stream strm) {
|
||||
for (auto &inReorder : inputReorders) {
|
||||
if (primArgs.count(inReorder.first)) {
|
||||
mkldnn::memory memDst(inReorder.second.getDstDesc(), strm.get_engine());
|
||||
inReorder.second.exec(primArgs[inReorder.first], memDst, strm);
|
||||
primArgs[inReorder.first] = memDst;
|
||||
} else {
|
||||
IE_THROW() << "DnnlExecutor has reorder for input " << inReorder.first << ", but doesn't have source memory";
|
||||
}
|
||||
}
|
||||
std::unordered_map<int, mkldnn::memory> outputMem;
|
||||
for (auto &outReorder : outputReorders) {
|
||||
if (primArgs.count(outReorder.first)) {
|
||||
mkldnn::memory memSrc(outReorder.second.getSrcDesc(), strm.get_engine());
|
||||
outputMem[outReorder.first] = primArgs[outReorder.first];
|
||||
primArgs[outReorder.first] = memSrc;
|
||||
} else {
|
||||
IE_THROW() << "DnnlExecutor has reorder for output " << outReorder.first << ", but doesn't have destination memory";
|
||||
}
|
||||
}
|
||||
(*execPrim).execute(strm, primArgs);
|
||||
for (auto &outReorder : outputReorders) {
|
||||
outReorder.second.exec(primArgs[outReorder.first], outputMem[outReorder.first], strm);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mkldnn_memory.h"
|
||||
#include "mkldnn_primitive.h"
|
||||
|
||||
namespace MKLDNNPlugin {
|
||||
|
||||
class DnnlExecutor {
|
||||
protected:
|
||||
class IntermReorder {
|
||||
public:
|
||||
IntermReorder(const mkldnn::memory::desc& descSrc, const mkldnn::memory::desc& descDst, const mkldnn::engine& engine);
|
||||
void exec(mkldnn::memory& memSrc, mkldnn::memory& memDst, mkldnn::stream strm);
|
||||
const mkldnn::memory::desc& getSrcDesc() const { return m_descSrc; }
|
||||
const mkldnn::memory::desc& getDstDesc() const { return m_descDst; }
|
||||
|
||||
private:
|
||||
mkldnn::reorder m_reorder;
|
||||
mkldnn::memory::desc m_descSrc;
|
||||
mkldnn::memory::desc m_descDst;
|
||||
};
|
||||
|
||||
public:
|
||||
void exec(std::unordered_map<int, mkldnn::memory> primArgs, mkldnn::stream strm);
|
||||
virtual ~DnnlExecutor() = default;
|
||||
|
||||
protected:
|
||||
DnnlExecutor() = default;
|
||||
MKLDNNPrimitive execPrim;
|
||||
// key is the port number for the primitive that needs memory reordering
|
||||
std::unordered_map<int, IntermReorder> inputReorders;
|
||||
std::unordered_map<int, IntermReorder> outputReorders;
|
||||
};
|
||||
|
||||
} // namespace MKLDNNPlugin
|
@ -145,6 +145,10 @@ void MKLDNNAdaptivePoolingNode::initSupportedPrimitiveDescriptors() {
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNAdaptivePoolingNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNAdaptivePoolingNode::execute(mkldnn::stream strm) {
|
||||
auto inputPrec = getParentEdgeAt(0)->getMemory().GetDataType();
|
||||
auto outputPrec = getChildEdgeAt(0)->getMemory().GetDataType();
|
||||
@ -283,8 +287,6 @@ bool MKLDNNAdaptivePoolingNode::created() const {
|
||||
return getType() == AdaptivePooling;
|
||||
}
|
||||
|
||||
void MKLDNNAdaptivePoolingNode::createPrimitive() {}
|
||||
|
||||
inline void MKLDNNAdaptivePoolingNode::setBinBorders(size_t *startPtr, size_t *endPtr, size_t idx, size_t inputLength, size_t outputLength) {
|
||||
*(startPtr) = idx * inputLength / outputLength;
|
||||
*(endPtr) = ceil(static_cast<float>((idx + 1) * inputLength) / outputLength);
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
@ -36,7 +35,7 @@ protected:
|
||||
bool needShapeInfer() const override;
|
||||
std::vector<VectorDims> shapeInfer() const override;
|
||||
bool needPrepareParams() const override { return false; };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
};
|
||||
|
||||
} // namespace MKLDNNPlugin
|
||||
|
@ -225,6 +225,10 @@ void MKLDNNBatchToSpaceNode::batchToSpaceKernel() {
|
||||
});
|
||||
}
|
||||
|
||||
void MKLDNNBatchToSpaceNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNBatchToSpaceNode::execute(mkldnn::stream strm) {
|
||||
switch (getParentEdgeAt(0)->getMemory().getDesc().getPrecision().size()) {
|
||||
case 1: batchToSpaceKernel<PrecisionTrait<Precision::U8>::value_type>(); break;
|
||||
|
@ -18,12 +18,11 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override {};
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool needPrepareParams() const override { return false; };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
|
@ -107,14 +107,6 @@ void MKLDNNBroadcastNode::initSupportedPrimitiveDescriptors() {
|
||||
supportedPrimitiveDescriptors = getSupportedConfigs(this);
|
||||
}
|
||||
|
||||
void MKLDNNBroadcastNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
bool MKLDNNBroadcastNode::needPrepareParams() const {
|
||||
return needPrepareParamsVar;
|
||||
}
|
||||
@ -215,6 +207,14 @@ std::vector<VectorDims> MKLDNNBroadcastNode::shapeInfer() const {
|
||||
return newOutputShapes;
|
||||
}
|
||||
|
||||
bool MKLDNNBroadcastNode::isExecutable() const {
|
||||
return !isInputTensorAtPortEmpty(0);
|
||||
}
|
||||
|
||||
void MKLDNNBroadcastNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNBroadcastNode::execute(mkldnn::stream strm) {
|
||||
if (optimizedCase) {
|
||||
optimizedExecute(getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(), getChildEdgeAt(0)->getMemoryPtr());
|
||||
|
@ -19,13 +19,11 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override {
|
||||
execute(strm);
|
||||
}
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
protected:
|
||||
|
@ -203,12 +203,8 @@ void MKLDNNBucketizeNode::prepareParams() {
|
||||
std::accumulate(input_tensor_dims.begin(), input_tensor_dims.end(), size_t(1), std::multiplies<size_t>());
|
||||
}
|
||||
|
||||
void MKLDNNBucketizeNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
bool MKLDNNBucketizeNode::isExecutable() const {
|
||||
return !isInputTensorAtPortEmpty(0);
|
||||
}
|
||||
|
||||
std::vector<VectorDims> MKLDNNBucketizeNode::shapeInfer() const {
|
||||
|
@ -15,15 +15,16 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void prepareParams() override;
|
||||
std::vector<VectorDims> shapeInfer() const override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
private:
|
||||
|
@ -31,6 +31,10 @@ namespace {
|
||||
constexpr size_t channelAxis = 1lu;
|
||||
}
|
||||
|
||||
bool MKLDNNConcatNode::isExecutable() const {
|
||||
return !hasEmptyOutputTensors() && !isOptimized();
|
||||
}
|
||||
|
||||
bool MKLDNNConcatNode::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept {
|
||||
try {
|
||||
const auto concatOp = ngraph::as_type_ptr<const ngraph::op::v0::Concat>(op);
|
||||
@ -173,7 +177,7 @@ void MKLDNNConcatNode::initSupportedPrimitiveDescriptors() {
|
||||
}
|
||||
|
||||
// TODO [DS]: inplace
|
||||
if (!canBeInPlace)
|
||||
if (!canBeInPlace || std::any_of(inputShapes.begin(), inputShapes.end(), [](const Shape& shape) { return shape.hasZeroDims(); }))
|
||||
return;
|
||||
|
||||
// Optimized inplace case
|
||||
@ -353,7 +357,6 @@ void MKLDNNConcatNode::prepareParams() {
|
||||
IE_THROW() << "Preferable primitive descriptor is not set.";
|
||||
|
||||
std::vector<memory::desc> srcs_d;
|
||||
|
||||
for (size_t i = 0; i < getParentEdges().size(); i++) {
|
||||
const auto& srcMemPtr = getParentEdgesAtPort(i)[0]->getMemoryPtr();
|
||||
if (!srcMemPtr || !srcMemPtr->GetPrimitivePtr()) {
|
||||
@ -362,6 +365,10 @@ void MKLDNNConcatNode::prepareParams() {
|
||||
<< getName() << ".";
|
||||
}
|
||||
|
||||
if (srcMemPtr->GetShape().hasZeroDims()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto desc = srcMemPtr->GetDescWithType<DnnlMemoryDesc>()->getDnnlDesc();
|
||||
const auto& dims = srcMemPtr->getStaticDims();
|
||||
for (size_t j = 0; j < dims.size(); j++) {
|
||||
@ -382,14 +389,6 @@ void MKLDNNConcatNode::prepareParams() {
|
||||
prim.reset(new concat(primitive_desc));
|
||||
}
|
||||
|
||||
void MKLDNNConcatNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
size_t MKLDNNConcatNode::inverseOrder(const SizeVector& order, size_t axis) {
|
||||
for (size_t i = 0; i < order.size(); i++) {
|
||||
if (axis == order[i]) {
|
||||
@ -489,16 +488,23 @@ void MKLDNNConcatNode::execute(mkldnn::stream strm) {
|
||||
return;
|
||||
}
|
||||
|
||||
const MKLDNNMemory& dst_memory = getChildEdgeAt(0)->getMemory();
|
||||
if (canOptimizeNspc) {
|
||||
execNspcSpecCase();
|
||||
return;
|
||||
}
|
||||
|
||||
const MKLDNNMemory& dst_memory = getChildEdgeAt(0)->getMemory();
|
||||
const size_t num_src = getParentEdges().size();
|
||||
std::unordered_map<int, memory> mem_ags {{DNNL_ARG_DST, dst_memory.GetPrimitive()}};
|
||||
for (int i = 0; i < num_src; i++)
|
||||
mem_ags[DNNL_ARG_MULTIPLE_SRC + i] = getParentEdgeAt(i)->getMemory().GetPrimitive();
|
||||
size_t nonZeroInShapes = 0;
|
||||
for (int i = 0; i < num_src; i++) {
|
||||
const auto& srcMem = getParentEdgesAtPort(i)[0]->getMemory();
|
||||
if (srcMem.GetShape().hasZeroDims()) {
|
||||
continue;
|
||||
}
|
||||
mem_ags[DNNL_ARG_MULTIPLE_SRC + nonZeroInShapes] = srcMem.GetPrimitive();
|
||||
nonZeroInShapes++;
|
||||
}
|
||||
|
||||
(*prim).execute(strm, mem_ags);
|
||||
}
|
||||
@ -518,21 +524,32 @@ void MKLDNNConcatNode::execNspcSpecCase() {
|
||||
std::vector<const uint8_t*> src_ptrs;
|
||||
std::vector<uint8_t*> dst_ptrs;
|
||||
|
||||
size_t nonZeroInShapes = 0;
|
||||
int firstNonZeroEdge = -1;
|
||||
for (size_t i = 0; i < num_src; i++) {
|
||||
const MKLDNNMemory& src_mem = getParentEdgeAt(i)->getMemory();
|
||||
const MKLDNNMemory& src_mem = getParentEdgesAtPort(i)[0]->getMemory();
|
||||
if (src_mem.GetShape().hasZeroDims()) {
|
||||
continue;
|
||||
}
|
||||
const size_t num_channels = src_mem.getStaticDims()[channelAxis];
|
||||
|
||||
channelsDataSize.push_back(num_channels * dataSize);
|
||||
src_ptrs.push_back(reinterpret_cast<const uint8_t*>(src_mem.GetData()));
|
||||
dst_ptrs.push_back(dst_ptr + channels_size);
|
||||
channels_size += num_channels * dataSize;
|
||||
|
||||
if (firstNonZeroEdge == -1) {
|
||||
firstNonZeroEdge = i;
|
||||
}
|
||||
|
||||
nonZeroInShapes++;
|
||||
}
|
||||
|
||||
const size_t iter_count = getParentEdgeAt(0)->getMemory().GetSize() / channelsDataSize[0];
|
||||
const size_t iter_count = getParentEdgeAt(firstNonZeroEdge)->getMemory().GetSize() / channelsDataSize[0];
|
||||
|
||||
parallel_for(iter_count, [&](int i) {
|
||||
const size_t dst_off = i * channels_size;
|
||||
for (int j = 0; j < num_src; j++) {
|
||||
for (int j = 0; j < nonZeroInShapes; j++) {
|
||||
cpu_memcpy(dst_ptrs[j] + dst_off, src_ptrs[j] + i * channelsDataSize[j], channelsDataSize[j]);
|
||||
}
|
||||
});
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
void getSupportedDescriptors() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void initOptimalPrimitiveDescriptor() override;
|
||||
void createPrimitive() override;
|
||||
void selectOptimalPrimitiveDescriptor() override;
|
||||
bool created() const override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
@ -28,10 +27,8 @@ public:
|
||||
bool isOptimized() const;
|
||||
|
||||
InferenceEngine::Precision getRuntimePrecision() const override;
|
||||
bool isExecutable() const override {
|
||||
return !isOptimized();
|
||||
}
|
||||
|
||||
bool isExecutable() const override;
|
||||
bool needPrepareParams() const override;
|
||||
void prepareParams() override;
|
||||
|
||||
|
@ -487,15 +487,6 @@ void MKLDNNConvolutionNode::initSupportedPrimitiveDescriptors() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MKLDNNConvolutionNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
bool MKLDNNConvolutionNode::created() const {
|
||||
return getType() == Convolution;
|
||||
}
|
||||
@ -545,7 +536,14 @@ MKLDNNConvolutionNode::createDescriptorInternal(const mkldnn::memory::desc& inpu
|
||||
|
||||
void MKLDNNConvolutionNode::createDescriptor(const std::vector<MemoryDescPtr>& inputDesc,
|
||||
const std::vector<MemoryDescPtr>& outputDesc) {
|
||||
auto inpDesc = inputDesc[0]->isDefined() ? inputDesc[0] : MemoryDescUtils::makeDummyDesc(*inputDesc[0]);
|
||||
MemoryDescPtr inpDesc;
|
||||
if (inputDesc[0]->isDefined()) {
|
||||
inpDesc = inputDesc[0];
|
||||
} else {
|
||||
auto dummyInDims = MemoryDescUtils::makeDummyShape(inputDesc[0]->getShape()).getStaticDims();
|
||||
dummyInDims[1] = IC;
|
||||
inpDesc = inputDesc[0]->cloneWithNewDims(dummyInDims);
|
||||
}
|
||||
DnnlMemoryDescPtr definedInpMemDesc = MemoryDescUtils::convertToDnnlMemoryDesc(inpDesc);
|
||||
DnnlMemoryDescPtr definedOutMemDesc;
|
||||
|
||||
@ -906,14 +904,57 @@ InferenceEngine::Blob::Ptr MKLDNNConvolutionNode::createInternalBlob(InferenceEn
|
||||
return internalBlob;
|
||||
}
|
||||
|
||||
std::shared_ptr<MKLDNNDescriptor> MKLDNNConvolutionNode::createMkldnnConvDesc(const mkldnn::memory::desc& srcDesc,
|
||||
const mkldnn::memory::desc& wghDesc,
|
||||
const mkldnn::memory::desc& dstDesc,
|
||||
const mkldnn::memory::desc& biasDesc) {
|
||||
std::shared_ptr<mkldnn::convolution_forward::desc> dnnlConvDesc;
|
||||
auto alg = isWinograd() ? mkldnn::algorithm::convolution_winograd : mkldnn::algorithm::convolution_direct;
|
||||
|
||||
if (withBiases) {
|
||||
// WA to align IR bias representation (3 to 5 rank tensors) to oneDNN representation (1 rank tensor)
|
||||
mkldnn::memory::desc dnnlBiasDesc = biasDesc.reshape(MKLDNNExtensionUtils::convertToDnnlDims(biasesDims));
|
||||
return std::make_shared<MKLDNNDescriptor>(createDescriptorInternal(srcDesc,
|
||||
wghDesc,
|
||||
dnnlBiasDesc,
|
||||
dstDesc,
|
||||
alg));
|
||||
} else {
|
||||
return std::make_shared<MKLDNNDescriptor>(createDescriptorInternal(srcDesc,
|
||||
wghDesc,
|
||||
dstDesc,
|
||||
alg));
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNConvolutionNode::prepareParams() {
|
||||
auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr();
|
||||
auto wghMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr();
|
||||
auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr();
|
||||
if (!dstMemPtr || !dstMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Destination memory didn't allocate.";
|
||||
if (!srcMemPtr || !srcMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Input memory didn't allocate.";
|
||||
if (!wghMemPtr || !wghMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Weight memory didn't allocate.";
|
||||
MKLDNNMemoryPtr biasMemPtr = nullptr;
|
||||
if (withBiases) {
|
||||
biasMemPtr = getParentEdgesAtPort(2)[0]->getMemoryPtr();
|
||||
if (!biasMemPtr || !biasMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Input memory didn't allocate.";
|
||||
}
|
||||
|
||||
const NodeDesc *selected_pd = getSelectedPrimitiveDescriptor();
|
||||
if (selected_pd == nullptr)
|
||||
IE_THROW() << "Preferable primitive descriptor is not set for node " << getName() << ".";
|
||||
|
||||
auto inMemoryDesc = getParentEdgesAtPort(0).front()->getMemory().GetDescWithType<DnnlMemoryDesc>();
|
||||
auto weightMemoryDesc = getParentEdgesAtPort(1).front()->getMemory().GetDescWithType<DnnlMemoryDesc>();
|
||||
auto outMemoryDesc = getChildEdgesAtPort(0).front()->getMemory().GetDescWithType<DnnlMemoryDesc>();
|
||||
auto inMemoryDesc = srcMemPtr->GetDescWithType<DnnlMemoryDesc>();
|
||||
auto weightMemoryDesc = wghMemPtr->GetDescWithType<DnnlMemoryDesc>();
|
||||
auto outMemoryDesc = dstMemPtr->GetDescWithType<DnnlMemoryDesc>();
|
||||
mkldnn::memory::desc biasDesc;
|
||||
if (biasMemPtr) {
|
||||
biasDesc = biasMemPtr->GetDescWithType<DnnlMemoryDesc>()->getDnnlDesc();
|
||||
}
|
||||
|
||||
auto initPrimitiveAttr = [&]() {
|
||||
mkldnn::primitive_attr attr;
|
||||
@ -934,55 +975,95 @@ void MKLDNNConvolutionNode::prepareParams() {
|
||||
pAttrLocal = initPrimitiveAttr();
|
||||
}
|
||||
|
||||
std::shared_ptr<mkldnn::convolution_forward::desc> dnnlConvDesc;
|
||||
auto alg = isWinograd() ? mkldnn::algorithm::convolution_winograd : mkldnn::algorithm::convolution_direct;
|
||||
std::shared_ptr<MKLDNNDescriptor> desc = createMkldnnConvDesc(inMemoryDesc->getDnnlDesc(),
|
||||
weightMemoryDesc->getDnnlDesc(),
|
||||
outMemoryDesc->getDnnlDesc(),
|
||||
biasDesc);
|
||||
|
||||
if (withBiases) {
|
||||
auto biasMemoryDesc = getParentEdgesAtPort(2).front()->getMemory().GetDescWithType<DnnlMemoryDesc>();
|
||||
// WA to align IR bias representation (3 to 5 rank tensors) to oneDNN representation (1 rank tensor)
|
||||
mkldnn::memory::desc dnnlBiasDesc = biasMemoryDesc->getDnnlDesc().reshape(MKLDNNExtensionUtils::convertToDnnlDims(biasesDims));
|
||||
dnnlConvDesc = createDescriptorInternal(inMemoryDesc->getDnnlDesc(),
|
||||
weightMemoryDesc->getDnnlDesc(),
|
||||
dnnlBiasDesc,
|
||||
outMemoryDesc->getDnnlDesc(),
|
||||
alg);
|
||||
} else {
|
||||
dnnlConvDesc = createDescriptorInternal(inMemoryDesc->getDnnlDesc(),
|
||||
weightMemoryDesc->getDnnlDesc(),
|
||||
outMemoryDesc->getDnnlDesc(),
|
||||
alg);
|
||||
}
|
||||
|
||||
MKLDNNDescriptor desc(dnnlConvDesc);
|
||||
|
||||
auto itpd = desc.createPrimitiveDescriptorIterator(getEngine(), *pAttrLocal);
|
||||
auto itpd = desc->createPrimitiveDescriptorIterator(getEngine(), *pAttrLocal);
|
||||
|
||||
convolution_forward::primitive_desc prim_desc;
|
||||
while (static_cast<bool>(itpd)) {
|
||||
|
||||
execPtr = nullptr;
|
||||
while (static_cast<bool>(itpd)) {
|
||||
impl_desc_type impl_type = parse_impl_name(itpd.impl_info_str());
|
||||
|
||||
if (impl_type == selected_pd->getImplementationType()) {
|
||||
prim_desc = convolution_forward::primitive_desc(itpd.get());
|
||||
execPtr = std::make_shared<ConvolutionExecutor>(prim_desc,
|
||||
srcMemPtr->GetPrimitive().get_desc(),
|
||||
wghMemPtr->GetPrimitive().get_desc(),
|
||||
dstMemPtr->GetPrimitive().get_desc(),
|
||||
getEngine());
|
||||
break;
|
||||
}
|
||||
if (!itpd.next_impl())
|
||||
IE_THROW() << "Primitive descriptor was not found for node " << getName() << ".";
|
||||
|
||||
if (!itpd.next_impl()) {
|
||||
auto inDesc = mkldnn::memory::desc(MKLDNNExtensionUtils::convertToDnnlDims(srcMemPtr->getStaticDims()),
|
||||
srcMemPtr->GetDataType(),
|
||||
memory::format_tag::any);
|
||||
auto wghDesc = mkldnn::memory::desc(MKLDNNExtensionUtils::convertToDnnlDims(wghMemPtr->getStaticDims()),
|
||||
wghMemPtr->GetDataType(),
|
||||
memory::format_tag::any);
|
||||
auto outDesc = mkldnn::memory::desc(MKLDNNExtensionUtils::convertToDnnlDims(dstMemPtr->getStaticDims()),
|
||||
dstMemPtr->GetDataType(),
|
||||
memory::format_tag::any);
|
||||
|
||||
std::shared_ptr<MKLDNNDescriptor> reorderConvDesc = createMkldnnConvDesc(inDesc, wghDesc, outDesc, biasDesc);
|
||||
auto reordItpd = reorderConvDesc->createPrimitiveDescriptorIterator(getEngine(), *pAttrLocal);
|
||||
if (static_cast<bool>(reordItpd)) {
|
||||
auto prim_desc = convolution_forward::primitive_desc(reordItpd.get());
|
||||
execPtr = std::make_shared<ConvolutionExecutor>(prim_desc, srcMemPtr->GetPrimitive().get_desc(),
|
||||
wghMemPtr->GetPrimitive().get_desc(),
|
||||
dstMemPtr->GetPrimitive().get_desc(),
|
||||
getEngine());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (execPtr) {
|
||||
primArgs[DNNL_ARG_SRC] = srcMemPtr->GetPrimitive();
|
||||
primArgs[DNNL_ARG_WEIGHTS] = wghMemPtr->GetPrimitive();
|
||||
primArgs[DNNL_ARG_DST] = dstMemPtr->GetPrimitive();
|
||||
|
||||
prim.reset(new convolution_forward(prim_desc));
|
||||
if (withBiases) {
|
||||
primArgs[DNNL_ARG_BIAS] = biasMemPtr->GetPrimitive();
|
||||
}
|
||||
|
||||
primArgs[DNNL_ARG_SRC] = getParentEdgesAtPort(0)[0]->getMemoryPtr()->GetPrimitive();
|
||||
primArgs[DNNL_ARG_WEIGHTS] = getWeights();
|
||||
primArgs[DNNL_ARG_DST] = getChildEdgesAtPort(0)[0]->getMemoryPtr()->GetPrimitive();
|
||||
|
||||
if (withBiases) {
|
||||
primArgs[DNNL_ARG_BIAS] = getBias();
|
||||
MKLDNNNode::appendPostOpArgs(*pAttrLocal, primArgs, binaryPostOpsArgs);
|
||||
} else {
|
||||
IE_THROW() << "Primitive descriptor was not found for node " << getName() << ".";
|
||||
}
|
||||
|
||||
appendPostOpArgs(*pAttrLocal, primArgs, binaryPostOpsArgs);
|
||||
}
|
||||
|
||||
void MKLDNNConvolutionNode::executeDynamicImpl(dnnl::stream strm) {
|
||||
MKLDNNConvolutionNode::ConvolutionExecutor::ConvolutionExecutor(const mkldnn::convolution_forward::primitive_desc& pd,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine) {
|
||||
execPrim.reset(new mkldnn::convolution_forward(pd));
|
||||
|
||||
if (inMemDesc != pd.src_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_SRC, IntermReorder(inMemDesc, pd.src_desc(), engine)});
|
||||
}
|
||||
|
||||
if (weightMemDesc != pd.weights_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_WEIGHTS, IntermReorder(weightMemDesc, pd.weights_desc(), engine)});
|
||||
}
|
||||
|
||||
if (outMemDesc != pd.dst_desc()) {
|
||||
outputReorders.insert({DNNL_ARG_DST, IntermReorder(pd.dst_desc(), outMemDesc, engine)});
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNConvolutionNode::execute(mkldnn::stream strm) {
|
||||
if (!execPtr) {
|
||||
IE_THROW() << "Can't execute Convolution node with name: " << getName() << ", because executor is not compiled";
|
||||
}
|
||||
execPtr->exec(primArgs, strm);
|
||||
}
|
||||
|
||||
void MKLDNNConvolutionNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common/dnnl_executor.h"
|
||||
|
||||
namespace MKLDNNPlugin {
|
||||
|
||||
@ -23,7 +24,6 @@ public:
|
||||
void createDescriptor(const std::vector<MemoryDescPtr>& inputDesc,
|
||||
const std::vector<MemoryDescPtr>& outputDesc) override;
|
||||
void initDescriptor(const NodeConfig& config) override;
|
||||
void createPrimitive() override;
|
||||
void selectOptimalPrimitiveDescriptor() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void filterSupportedPrimitiveDescriptors() override;
|
||||
@ -65,7 +65,25 @@ protected:
|
||||
InferenceEngine::Precision fusedEltwisePrecision(const MKLDNNNodePtr& fusingNode) const;
|
||||
|
||||
private:
|
||||
using executorPtr = std::shared_ptr<DnnlExecutor>;
|
||||
executorPtr execPtr = nullptr;
|
||||
|
||||
class ConvolutionExecutor : public DnnlExecutor {
|
||||
public:
|
||||
ConvolutionExecutor(const mkldnn::convolution_forward::primitive_desc& pd,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine);
|
||||
};
|
||||
|
||||
std::shared_ptr<MKLDNNDescriptor> createMkldnnConvDesc(const mkldnn::memory::desc& srcDesc,
|
||||
const mkldnn::memory::desc& wghDesc,
|
||||
const mkldnn::memory::desc& dstDesc,
|
||||
const mkldnn::memory::desc& biasDesc);
|
||||
|
||||
void prepareParams() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
void addZeroPoints(mkldnn::primitive_attr& attr) const;
|
||||
|
@ -129,15 +129,8 @@ void MKLDNNConvertNode::initSupportedPrimitiveDescriptors() {
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNConvertNode::createPrimitive() {
|
||||
auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr();
|
||||
auto& srcMemPtr = getParentEdgeAt(0)->getMemoryPtr();
|
||||
if (!dstMemPtr || !dstMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << errorPrefix << " has not allocated destination memory";
|
||||
if (!srcMemPtr || !srcMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << errorPrefix << " has not allocated input memory";
|
||||
if (getSelectedPrimitiveDescriptor() == nullptr)
|
||||
IE_THROW() << errorPrefix << " has nullable preferable primitive descriptor";
|
||||
void MKLDNNConvertNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNConvertNode::execute(mkldnn::stream strm) {
|
||||
|
@ -19,9 +19,8 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
bool canBeInPlace() const override {
|
||||
return false;
|
||||
|
@ -165,14 +165,8 @@ bool MKLDNNCTCGreedyDecoderNode::created() const {
|
||||
return getType() == CTCGreedyDecoder;
|
||||
}
|
||||
|
||||
void MKLDNNCTCGreedyDecoderNode::executeDynamicImpl(dnnl::stream strm) {
|
||||
MKLDNNCTCGreedyDecoderNode::execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNCTCGreedyDecoderNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
void MKLDNNCTCGreedyDecoderNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
bool MKLDNNCTCGreedyDecoderNode::needPrepareParams() const {
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
void executeDynamicImpl(dnnl::stream strm) override;
|
||||
|
@ -168,14 +168,8 @@ bool MKLDNNCTCGreedyDecoderSeqLenNode::created() const {
|
||||
return getType() == CTCGreedyDecoderSeqLen;
|
||||
}
|
||||
|
||||
void MKLDNNCTCGreedyDecoderSeqLenNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNCTCGreedyDecoderSeqLenNode::executeDynamicImpl(dnnl::stream strm) {
|
||||
MKLDNNCTCGreedyDecoderSeqLenNode::execute(strm);
|
||||
void MKLDNNCTCGreedyDecoderSeqLenNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
bool MKLDNNCTCGreedyDecoderSeqLenNode::needPrepareParams() const {
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
void executeDynamicImpl(dnnl::stream strm) override;
|
||||
|
@ -57,12 +57,8 @@ void MKLDNNCTCLossNode::initSupportedPrimitiveDescriptors() {
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNCTCLossNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
void MKLDNNCTCLossNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNCTCLossNode::execute(mkldnn::stream strm) {
|
||||
|
@ -15,13 +15,12 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
bool needPrepareParams() const override { return false; };
|
||||
|
||||
private:
|
||||
|
@ -258,13 +258,7 @@ bool MKLDNNCumSumNode::needPrepareParams() const {
|
||||
}
|
||||
|
||||
void MKLDNNCumSumNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
return execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNCumSumNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
REG_MKLDNN_PRIM_FOR(MKLDNNCumSumNode, CumSum)
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -475,7 +475,7 @@ void MKLDNNDeconvolutionNode::execute(mkldnn::stream strm) {
|
||||
if (!execPtr) {
|
||||
IE_THROW() << "Can't execute Deconvolution node with name: " << getName() << ", because executor is not compiled";
|
||||
}
|
||||
execPtr->exec(strm);
|
||||
execPtr->exec(primArgs, strm);
|
||||
|
||||
if (externOutShape) {
|
||||
lastOutputSpatialDims = readOutputSpatialDims();
|
||||
@ -519,12 +519,18 @@ void MKLDNNDeconvolutionNode::createDeconvPrim(std::shared_ptr<MKLDNNDescriptor>
|
||||
prepareMemory(itpd);
|
||||
}
|
||||
auto prim_desc = deconvolution_forward::primitive_desc(itpd.get());
|
||||
execPtr = std::make_shared<DeconvExecutorInt8>(prim_desc, srcMemPtr, internalBlobMemory.front(), dstMemPtr, *attr,
|
||||
binaryPostOpsArgs, getEngine());
|
||||
execPtr = std::make_shared<DeconvExecutorInt8>(prim_desc,
|
||||
srcMemPtr->GetPrimitive().get_desc(),
|
||||
internalBlobMemory.front()->GetPrimitive().get_desc(),
|
||||
dstMemPtr->GetPrimitive().get_desc(),
|
||||
getEngine());
|
||||
} else {
|
||||
auto prim_desc = convolution_backward_data::primitive_desc(itpd.get());
|
||||
execPtr = std::make_shared<DeconvExecutorDefault>(prim_desc, srcMemPtr, wghMemPtr, dstMemPtr, *attr,
|
||||
binaryPostOpsArgs, getEngine());
|
||||
execPtr = std::make_shared<DeconvExecutorDefault>(prim_desc,
|
||||
srcMemPtr->GetPrimitive().get_desc(),
|
||||
wghMemPtr->GetPrimitive().get_desc(),
|
||||
dstMemPtr->GetPrimitive().get_desc(),
|
||||
getEngine());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -544,8 +550,11 @@ void MKLDNNDeconvolutionNode::createDeconvPrim(std::shared_ptr<MKLDNNDescriptor>
|
||||
auto anyDeconvItpd = anyDeconvDesc->createPrimitiveDescriptorIterator(getEngine(), *attr);
|
||||
if (static_cast<bool>(anyDeconvItpd)) {
|
||||
auto prim_desc = convolution_backward_data::primitive_desc(anyDeconvItpd.get());
|
||||
execPtr = std::make_shared<DeconvExecutorDefault>(prim_desc, srcMemPtr, wghMemPtr, dstMemPtr, *attr,
|
||||
binaryPostOpsArgs, getEngine());
|
||||
execPtr = std::make_shared<DeconvExecutorDefault>(prim_desc,
|
||||
srcMemPtr->GetPrimitive().get_desc(),
|
||||
wghMemPtr->GetPrimitive().get_desc(),
|
||||
dstMemPtr->GetPrimitive().get_desc(),
|
||||
getEngine());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -555,12 +564,15 @@ void MKLDNNDeconvolutionNode::createDeconvPrim(std::shared_ptr<MKLDNNDescriptor>
|
||||
|
||||
void MKLDNNDeconvolutionNode::prepareParams() {
|
||||
auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr();
|
||||
auto wghMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr();
|
||||
auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr();
|
||||
if (!dstMemPtr || !dstMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Destination memory didn't allocate.";
|
||||
if (!srcMemPtr || !srcMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Input memory didn't allocate.";
|
||||
const NodeDesc *selected_pd = getSelectedPrimitiveDescriptor();
|
||||
if (!wghMemPtr || !wghMemPtr->GetPrimitivePtr())
|
||||
IE_THROW() << "Weight memory didn't allocate.";
|
||||
if (selected_pd == nullptr)
|
||||
IE_THROW() << "Preferable primitive descriptor is not set for node " << getName() << ".";
|
||||
|
||||
@ -610,7 +622,18 @@ void MKLDNNDeconvolutionNode::prepareParams() {
|
||||
selected_pd->getImplementationType() == MKLDNNPlugin::impl_desc_type::jit_avx512_winograd);
|
||||
}
|
||||
|
||||
createDeconvPrim(desc, srcMemPtr, getParentEdgesAtPort(1)[0]->getMemoryPtr(), dstMemPtr, pAttrLocal, selected_pd->getImplementationType());
|
||||
createDeconvPrim(desc, srcMemPtr, wghMemPtr, dstMemPtr, pAttrLocal, selected_pd->getImplementationType());
|
||||
|
||||
if (std::dynamic_pointer_cast<DeconvExecutorInt8>(execPtr)) {
|
||||
primArgs = {{DNNL_ARG_SRC, srcMemPtr->GetPrimitive()},
|
||||
{DNNL_ARG_WEIGHTS, internalBlobMemory.front()->GetPrimitive()},
|
||||
{DNNL_ARG_DST, dstMemPtr->GetPrimitive()}};
|
||||
} else {
|
||||
primArgs = {{DNNL_ARG_DIFF_DST, srcMemPtr->GetPrimitive()},
|
||||
{DNNL_ARG_WEIGHTS, wghMemPtr->GetPrimitive()},
|
||||
{DNNL_ARG_DIFF_SRC, dstMemPtr->GetPrimitive()}};
|
||||
}
|
||||
MKLDNNNode::appendPostOpArgs(attr, primArgs, binaryPostOpsArgs);
|
||||
}
|
||||
|
||||
void MKLDNNDeconvolutionNode::createPrimitive() {
|
||||
@ -738,100 +761,44 @@ InferenceEngine::Precision MKLDNNDeconvolutionNode::getRuntimePrecision() const
|
||||
return getMaxPrecision(inputPrecisions);
|
||||
}
|
||||
|
||||
MKLDNNDeconvolutionNode::DeconvExecutor::IntermReorder::IntermReorder(MKLDNNMemoryPtr memFrom,
|
||||
const mkldnn::memory::desc& descTo,
|
||||
const mkldnn::engine& engine) : m_memFrom(memFrom) {
|
||||
m_memTo = std::make_shared<MKLDNNMemory>(engine);
|
||||
m_memTo->Create(MKLDNNExtensionUtils::makeDescriptor(descTo));
|
||||
m_reorder = mkldnn::reorder(m_memFrom->GetPrimitive(), m_memTo->GetPrimitive());
|
||||
}
|
||||
|
||||
MKLDNNDeconvolutionNode::DeconvExecutor::IntermReorder::IntermReorder(const mkldnn::memory::desc& descFrom,
|
||||
MKLDNNMemoryPtr memTo,
|
||||
const mkldnn::engine& engine) : m_memTo(memTo) {
|
||||
m_memFrom = std::make_shared<MKLDNNMemory>(engine);
|
||||
m_memFrom->Create(MKLDNNExtensionUtils::makeDescriptor(descFrom));
|
||||
m_reorder = mkldnn::reorder(m_memFrom->GetPrimitive(), m_memTo->GetPrimitive());
|
||||
}
|
||||
|
||||
void MKLDNNDeconvolutionNode::DeconvExecutor::IntermReorder::exec(mkldnn::stream strm) {
|
||||
auto src = m_memFrom->GetPrimitive();
|
||||
auto dst = m_memTo->GetPrimitive();
|
||||
m_reorder.execute(strm, src, dst);
|
||||
}
|
||||
|
||||
void MKLDNNDeconvolutionNode::DeconvExecutor::exec(mkldnn::stream strm) {
|
||||
for (auto &inReorder : inputReorders) {
|
||||
inReorder.exec(strm);
|
||||
}
|
||||
(*execPrim).execute(strm, primArgs);
|
||||
for (auto &outReorder : outputReorders) {
|
||||
outReorder.exec(strm);
|
||||
}
|
||||
}
|
||||
|
||||
MKLDNNDeconvolutionNode::DeconvExecutorDefault::DeconvExecutorDefault(const mkldnn::convolution_backward_data::primitive_desc& pd,
|
||||
MKLDNNMemoryPtr inMem,
|
||||
MKLDNNMemoryPtr weightMem,
|
||||
MKLDNNMemoryPtr outMem,
|
||||
const mkldnn::primitive_attr &attr,
|
||||
const std::vector<MKLDNNMemoryPtr>& binPostOpsArgs,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine) {
|
||||
execPrim.reset(new mkldnn::convolution_backward_data(pd));
|
||||
|
||||
if (inMem->GetPrimitive().get_desc() != pd.diff_dst_desc()) {
|
||||
inputReorders.push_back(IntermReorder(inMem, pd.diff_dst_desc(), engine));
|
||||
primArgs[DNNL_ARG_DIFF_DST] = inputReorders.back().getToMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_DIFF_DST] = inMem->GetPrimitive();
|
||||
if (inMemDesc != pd.diff_dst_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_DIFF_DST, IntermReorder(inMemDesc, pd.diff_dst_desc(), engine)});
|
||||
}
|
||||
|
||||
if (weightMem->GetPrimitive().get_desc() != pd.weights_desc()) {
|
||||
inputReorders.push_back(IntermReorder(weightMem, pd.weights_desc(), engine));
|
||||
primArgs[DNNL_ARG_WEIGHTS] = inputReorders.back().getToMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_WEIGHTS] = weightMem->GetPrimitive();
|
||||
if (weightMemDesc != pd.weights_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_WEIGHTS, IntermReorder(weightMemDesc, pd.weights_desc(), engine)});
|
||||
}
|
||||
|
||||
if (outMem->GetPrimitive().get_desc() != pd.diff_src_desc()) {
|
||||
outputReorders.push_back(IntermReorder(pd.diff_src_desc(), outMem, engine));
|
||||
primArgs[DNNL_ARG_DIFF_SRC] = outputReorders.back().getFromMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_DIFF_SRC] = outMem->GetPrimitive();
|
||||
if (outMemDesc != pd.diff_src_desc()) {
|
||||
outputReorders.insert({DNNL_ARG_DIFF_SRC, IntermReorder(pd.diff_src_desc(), outMemDesc, engine)});
|
||||
}
|
||||
MKLDNNNode::appendPostOpArgs(attr, primArgs, binPostOpsArgs);
|
||||
}
|
||||
|
||||
MKLDNNDeconvolutionNode::DeconvExecutorInt8::DeconvExecutorInt8(const mkldnn::deconvolution_forward::primitive_desc& pd,
|
||||
MKLDNNMemoryPtr inMem,
|
||||
MKLDNNMemoryPtr weightMem,
|
||||
MKLDNNMemoryPtr outMem,
|
||||
const mkldnn::primitive_attr &attr,
|
||||
const std::vector<MKLDNNMemoryPtr>& binPostOpsArgs,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine) {
|
||||
execPrim.reset(new mkldnn::deconvolution_forward(pd));
|
||||
|
||||
if (inMem->GetPrimitive().get_desc() != pd.src_desc()) {
|
||||
inputReorders.push_back(IntermReorder(inMem, pd.src_desc(), engine));
|
||||
primArgs[DNNL_ARG_SRC] = inputReorders.back().getToMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_SRC] = inMem->GetPrimitive();
|
||||
if (inMemDesc != pd.src_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_SRC, IntermReorder(inMemDesc, pd.src_desc(), engine)});
|
||||
}
|
||||
|
||||
if (weightMem->GetPrimitive().get_desc() != pd.weights_desc()) {
|
||||
inputReorders.push_back(IntermReorder(weightMem, pd.weights_desc(), engine));
|
||||
primArgs[DNNL_ARG_WEIGHTS] = inputReorders.back().getToMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_WEIGHTS] = weightMem->GetPrimitive();
|
||||
if (weightMemDesc != pd.weights_desc()) {
|
||||
inputReorders.insert({DNNL_ARG_WEIGHTS, IntermReorder(weightMemDesc, pd.weights_desc(), engine)});
|
||||
}
|
||||
|
||||
if (outMem->GetPrimitive().get_desc() != pd.dst_desc()) {
|
||||
outputReorders.push_back(IntermReorder(pd.dst_desc(), outMem, engine));
|
||||
primArgs[DNNL_ARG_DST] = outputReorders.back().getFromMem()->GetPrimitive();
|
||||
} else {
|
||||
primArgs[DNNL_ARG_DST] = outMem->GetPrimitive();
|
||||
if (outMemDesc != pd.dst_desc()) {
|
||||
outputReorders.insert({DNNL_ARG_DST, IntermReorder(pd.dst_desc(), outMemDesc, engine)});
|
||||
}
|
||||
MKLDNNNode::appendPostOpArgs(attr, primArgs, binPostOpsArgs);
|
||||
}
|
||||
|
||||
std::vector<int32_t> MKLDNNDeconvolutionNode::readOutputSpatialDims() const {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common/dnnl_executor.h"
|
||||
|
||||
namespace MKLDNNPlugin {
|
||||
|
||||
@ -53,56 +54,24 @@ public:
|
||||
std::vector<VectorDims> shapeInfer() const override;
|
||||
|
||||
private:
|
||||
class DeconvExecutor {
|
||||
protected:
|
||||
class IntermReorder {
|
||||
public:
|
||||
IntermReorder(MKLDNNMemoryPtr memFrom, const mkldnn::memory::desc& descTo, const mkldnn::engine& engine);
|
||||
IntermReorder(const mkldnn::memory::desc& descFrom, MKLDNNMemoryPtr memTo, const mkldnn::engine& engine);
|
||||
MKLDNNMemoryPtr getFromMem() const { return m_memFrom; }
|
||||
MKLDNNMemoryPtr getToMem() const { return m_memTo; }
|
||||
void exec(mkldnn::stream strm);
|
||||
|
||||
private:
|
||||
MKLDNNMemoryPtr m_memFrom;
|
||||
MKLDNNMemoryPtr m_memTo;
|
||||
mkldnn::reorder m_reorder;
|
||||
};
|
||||
|
||||
public:
|
||||
void exec(mkldnn::stream strm);
|
||||
virtual ~DeconvExecutor() = default;
|
||||
|
||||
protected:
|
||||
DeconvExecutor() = default;
|
||||
std::vector<IntermReorder> inputReorders;
|
||||
MKLDNNPrimitive execPrim;
|
||||
std::vector<IntermReorder> outputReorders;
|
||||
std::unordered_map<int, mkldnn::memory> primArgs;
|
||||
};
|
||||
|
||||
using executorPtr = std::shared_ptr<DeconvExecutor>;
|
||||
using executorPtr = std::shared_ptr<DnnlExecutor>;
|
||||
executorPtr execPtr = nullptr;
|
||||
|
||||
class DeconvExecutorDefault : public DeconvExecutor {
|
||||
class DeconvExecutorDefault : public DnnlExecutor {
|
||||
public:
|
||||
DeconvExecutorDefault(const mkldnn::convolution_backward_data::primitive_desc& pd,
|
||||
MKLDNNMemoryPtr inMem,
|
||||
MKLDNNMemoryPtr weightMem,
|
||||
MKLDNNMemoryPtr outMem,
|
||||
const mkldnn::primitive_attr &attr,
|
||||
const std::vector<MKLDNNMemoryPtr>& binPostOpsArgs,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine);
|
||||
};
|
||||
|
||||
class DeconvExecutorInt8 : public DeconvExecutor {
|
||||
class DeconvExecutorInt8 : public DnnlExecutor {
|
||||
public:
|
||||
DeconvExecutorInt8(const mkldnn::deconvolution_forward::primitive_desc& pd,
|
||||
MKLDNNMemoryPtr inMem,
|
||||
MKLDNNMemoryPtr weightMem,
|
||||
MKLDNNMemoryPtr outMem,
|
||||
const mkldnn::primitive_attr &attr,
|
||||
const std::vector<MKLDNNMemoryPtr>& binPostOpsArgs,
|
||||
const mkldnn::memory::desc& inMemDesc,
|
||||
const mkldnn::memory::desc& weightMemDesc,
|
||||
const mkldnn::memory::desc& outMemDesc,
|
||||
const mkldnn::engine& engine);
|
||||
};
|
||||
|
||||
|
@ -49,15 +49,7 @@ bool MKLDNNDetectionOutputNode::isSupportedOperation(const std::shared_ptr<const
|
||||
return true;
|
||||
}
|
||||
|
||||
void MKLDNNDetectionOutputNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
MKLDNNDetectionOutputNode::MKLDNNDetectionOutputNode(const std::shared_ptr<ov::Node>& op, const mkldnn::engine& eng,
|
||||
MKLDNNDetectionOutputNode::MKLDNNDetectionOutputNode(const std::shared_ptr<ngraph::Node>& op, const mkldnn::engine& eng,
|
||||
MKLDNNWeightsSharing::Ptr &cache) : MKLDNNNode(op, eng, cache) {
|
||||
std::string errorMessage;
|
||||
if (!isSupportedOperation(op, errorMessage)) {
|
||||
@ -170,6 +162,10 @@ struct ConfidenceComparatorDO {
|
||||
const float* confData;
|
||||
};
|
||||
|
||||
void MKLDNNDetectionOutputNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNDetectionOutputNode::execute(mkldnn::stream strm) {
|
||||
float *dstData = reinterpret_cast<float *>(getChildEdgesAtPort(0)[0]->getMemoryPtr()->GetPtr());
|
||||
|
||||
|
@ -16,7 +16,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
@ -24,7 +23,7 @@ public:
|
||||
|
||||
protected:
|
||||
void prepareParams() override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
private:
|
||||
static const int ID_LOC = 0;
|
||||
|
@ -1525,14 +1525,6 @@ void MKLDNNEltwiseNode::selectOptimalPrimitiveDescriptor() {
|
||||
selectPreferPrimitiveDescriptor(getPrimitivesPriority(), true);
|
||||
}
|
||||
|
||||
void MKLDNNEltwiseNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNEltwiseNode::initOptimalPrimitiveDescriptor() {
|
||||
auto selected_pd = getSelectedPrimitiveDescriptor();
|
||||
if (selected_pd == nullptr)
|
||||
@ -1683,6 +1675,10 @@ void MKLDNNEltwiseNode::executeReference(const jit_eltwise_params &jep, const ji
|
||||
});
|
||||
}
|
||||
|
||||
void MKLDNNEltwiseNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNEltwiseNode::execute(mkldnn::stream strm) {
|
||||
if (execPtr) {
|
||||
jit_eltwise_call_args_ptrs args_ptrs = {};
|
||||
|
@ -90,13 +90,11 @@ public:
|
||||
bool isWithBroadcast();
|
||||
bool isSpecialConvolutionAddFusing() const { return specialConvolutionAddFusing; }
|
||||
|
||||
void createPrimitive() override;
|
||||
|
||||
std::vector<VectorDims> shapeInfer() const override;
|
||||
bool needPrepareParams() const override;
|
||||
void prepareParams() override;
|
||||
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
enum BroadcastingPolicy {
|
||||
PerChannel,
|
||||
|
@ -70,14 +70,6 @@ void MKLDNNEmbeddingBagOffsetSumNode::initSupportedPrimitiveDescriptors() {
|
||||
addSupportedPrimDesc(inDataConfigurators, {{LayoutType::ncsp, inDataPrecision}}, impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagOffsetSumNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagOffsetSumNode::prepareParams() {
|
||||
_indicesLen = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[0];
|
||||
_offsetsLen = getParentEdgesAtPort(OFFSETS_IDX)[0]->getMemory().getStaticDims()[0];
|
||||
@ -126,6 +118,14 @@ void MKLDNNEmbeddingBagOffsetSumNode::getIndices(int embIndex, const int*& indic
|
||||
weightsIdx = offsetsData_[embIndex];
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagOffsetSumNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
bool MKLDNNEmbeddingBagOffsetSumNode::isExecutable() const {
|
||||
return !isInputTensorAtPortEmpty(0);
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagOffsetSumNode::execute(mkldnn::stream strm) {
|
||||
const auto *srcData = reinterpret_cast<const uint8_t *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
auto *dstData = reinterpret_cast<uint8_t *>(getChildEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
|
@ -19,15 +19,15 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
protected:
|
||||
void prepareParams() override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
private:
|
||||
void initFromInputs() override;
|
||||
|
@ -64,14 +64,6 @@ void MKLDNNEmbeddingBagPackedSumNode::initSupportedPrimitiveDescriptors() {
|
||||
addSupportedPrimDesc(inDataConfigurators, {{LayoutType::ncsp, inDataPrecision}}, impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagPackedSumNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagPackedSumNode::prepareParams() {
|
||||
_batch = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[0];
|
||||
_indicesPerBag = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[1];
|
||||
@ -94,6 +86,14 @@ void MKLDNNEmbeddingBagPackedSumNode::getIndices(int embIndex, const int*& indic
|
||||
weightsIdx = embIndex * _indicesPerBag;
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagPackedSumNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
bool MKLDNNEmbeddingBagPackedSumNode::isExecutable() const {
|
||||
return !isInputTensorAtPortEmpty(0);
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingBagPackedSumNode::execute(mkldnn::stream strm) {
|
||||
const auto *srcData = reinterpret_cast<const uint8_t *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
auto *dstData = reinterpret_cast<uint8_t *>(getChildEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
|
@ -19,15 +19,15 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
protected:
|
||||
void prepareParams() override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
private:
|
||||
void initFromInputs() override;
|
||||
|
@ -11,14 +11,6 @@
|
||||
using namespace MKLDNNPlugin;
|
||||
using namespace InferenceEngine;
|
||||
|
||||
void MKLDNNEmbeddingSegmentsSumNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
bool MKLDNNEmbeddingSegmentsSumNode::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept {
|
||||
try {
|
||||
const auto embBagSegSumOp = ngraph::as_type_ptr<const ngraph::op::v3::EmbeddingSegmentsSum>(op);
|
||||
@ -129,6 +121,14 @@ void MKLDNNEmbeddingSegmentsSumNode::getIndices(int embIndex, const int*& indice
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingSegmentsSumNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
bool MKLDNNEmbeddingSegmentsSumNode::isExecutable() const {
|
||||
return !isInputTensorAtPortEmpty(0);
|
||||
}
|
||||
|
||||
void MKLDNNEmbeddingSegmentsSumNode::execute(mkldnn::stream strm) {
|
||||
const auto *srcData = reinterpret_cast<const uint8_t *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
auto *dstData = reinterpret_cast<uint8_t *>(getChildEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
|
@ -19,15 +19,15 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
protected:
|
||||
void prepareParams() override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
private:
|
||||
void initFromInputs() override;
|
||||
|
@ -272,12 +272,6 @@ void MKLDNNExperimentalDetectronDetectionOutputNode::initSupportedPrimitiveDescr
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronDetectionOutputNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronDetectionOutputNode::execute(mkldnn::stream strm) {
|
||||
const int rois_num = getParentEdgeAt(INPUT_ROIS)->getMemory().getStaticDims()[0];
|
||||
assert(classes_num_ == static_cast<int>(getParentEdgeAt(INPUT_SCORES)->getMemory().getStaticDims()[1]));
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -320,12 +320,6 @@ void MKLDNNExperimentalDetectronGenerateProposalsSingleImageNode::initSupportedP
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronGenerateProposalsSingleImageNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronGenerateProposalsSingleImageNode::execute(mkldnn::stream strm) {
|
||||
try {
|
||||
if (inputShapes.size() != 4 || outputShapes.size() != 2) {
|
||||
|
@ -16,7 +16,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -56,12 +56,6 @@ void MKLDNNExperimentalDetectronPriorGridGeneratorNode::initSupportedPrimitiveDe
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronPriorGridGeneratorNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNExperimentalDetectronPriorGridGeneratorNode::execute(mkldnn::stream strm) {
|
||||
const int num_priors_ = getParentEdgeAt(INPUT_PRIORS)->getMemory().getStaticDims()[0];
|
||||
assert(getParentEdgeAt(INPUT_PRIORS)->getMemory().getStaticDims()[1] == 4);
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override {};
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override {};
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -327,14 +327,6 @@ MKLDNNExtractImagePatchesNode::MKLDNNExtractImagePatchesNode(const std::shared_p
|
||||
IE_THROW() << errorPrefix << "must have the following attributes with shape {2}: sizes, strides, rates.";
|
||||
}
|
||||
|
||||
void MKLDNNExtractImagePatchesNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNExtractImagePatchesNode::prepareParams() {
|
||||
const auto& srcMemPtr0 = getParentEdgeAt(0)->getMemoryPtr();
|
||||
const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr();
|
||||
@ -381,7 +373,7 @@ void MKLDNNExtractImagePatchesNode::execute(mkldnn::stream strm) {
|
||||
}
|
||||
|
||||
void MKLDNNExtractImagePatchesNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
return execute(strm);
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNExtractImagePatchesNode::ExtractImagePatchesRefExecutor::executeReference(
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -1387,13 +1387,6 @@ void MKLDNNFakeQuantizeNode::prepareParams() {
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNFakeQuantizeNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNFakeQuantizeNode::executeReference() {
|
||||
auto &srcMemory = getParentEdgeAt(0)->getMemoryPtr();
|
||||
auto &dstMemory = getChildEdgeAt(0)->getMemoryPtr();
|
||||
@ -1652,6 +1645,10 @@ void MKLDNNFakeQuantizeNode::executeQuantization(const std::unique_ptr<jit_uni_q
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNFakeQuantizeNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNFakeQuantizeNode::execute(mkldnn::stream strm) {
|
||||
auto selectedPrimitiveDescriptor = getSelectedPrimitiveDescriptor();
|
||||
if (!selectedPrimitiveDescriptor)
|
||||
|
@ -70,10 +70,9 @@ public:
|
||||
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void getSupportedDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
bool created() const override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
size_t getAxis() const { return axis; }
|
||||
|
||||
|
@ -54,14 +54,6 @@ MKLDNNGatherElementsNode::MKLDNNGatherElementsNode(const std::shared_ptr<ngraph:
|
||||
axis_ = axis;
|
||||
}
|
||||
|
||||
void MKLDNNGatherElementsNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNGatherElementsNode::prepareParams() {
|
||||
const auto& dataDims = getParentEdgesAtPort(dataIndex_)[0]->getMemory().getStaticDims();
|
||||
const auto& dstDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims();
|
||||
@ -102,6 +94,10 @@ void MKLDNNGatherElementsNode::initSupportedPrimitiveDescriptors() {
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNGatherElementsNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
void MKLDNNGatherElementsNode::directExecution() {
|
||||
const auto *srcData = reinterpret_cast<const dataType *>(getParentEdgeAt(dataIndex_)->getMemoryPtr()->GetPtr());
|
||||
|
@ -18,14 +18,13 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
protected:
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
void prepareParams() override;
|
||||
|
||||
private:
|
||||
|
@ -80,14 +80,6 @@ void MKLDNNGatherNDNode::initSupportedPrimitiveDescriptors() {
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNGatherNDNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNGatherNDNode::prepareParams() {
|
||||
auto& srcMemPtr = getParentEdgeAt(GATHERND_DATA)->getMemoryPtr();
|
||||
auto& idxMemPtr = getParentEdgeAt(GATHERND_INDEXES)->getMemoryPtr();
|
||||
@ -227,7 +219,7 @@ void MKLDNNGatherNDNode::GatherNDExecutor::gatherElementwise(const MKLDNNMemoryP
|
||||
});
|
||||
}
|
||||
|
||||
void MKLDNNGatherNDNode::executeDynamicImpl(dnnl::stream strm) {
|
||||
void MKLDNNGatherNDNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -110,20 +110,12 @@ void MKLDNNGatherNode::prepareParams() {
|
||||
}
|
||||
|
||||
bool MKLDNNGatherNode::needPrepareParams() const {
|
||||
bool result = MKLDNNNode::needPrepareParams();
|
||||
bool result = inputShapesModified();
|
||||
if (!isAxisInputConst)
|
||||
result = result || axis != (reinterpret_cast<const int32_t*>(getParentEdgeAt(GATHER_AXIS)->getMemoryPtr()->GetPtr()))[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
void MKLDNNGatherNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNGatherNode::execute(mkldnn::stream strm) {
|
||||
const int32_t* srcIndexes = reinterpret_cast<const int32_t*>(getParentEdgeAt(GATHER_INDEXES)->getMemoryPtr()->GetPtr());
|
||||
const uint8_t* srcData = reinterpret_cast<const uint8_t*>(getParentEdgeAt(GATHER_DATA)->getMemoryPtr()->GetPtr());
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
|
@ -2075,7 +2075,7 @@ void MKLDNNInterpolateNode::createPrimitive() {
|
||||
interpAttrs.inPrc = srcMemPtr->getDesc().getPrecision();
|
||||
interpAttrs.outPrc = dstMemPtr->getDesc().getPrecision();
|
||||
|
||||
if (shapesDefined()) {
|
||||
if (shapesDefined() && isExecutable()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
|
@ -60,14 +60,6 @@ void MKLDNNLogSoftmaxNode::initSupportedPrimitiveDescriptors() {
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNLogSoftmaxNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNLogSoftmaxNode::prepareParams() {
|
||||
const auto &dims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims();
|
||||
reducedAxisStride = 1;
|
||||
@ -87,6 +79,10 @@ void MKLDNNLogSoftmaxNode::prepareParams() {
|
||||
reducedAxisStride *= dims[i];
|
||||
}
|
||||
|
||||
void MKLDNNLogSoftmaxNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNLogSoftmaxNode::execute(mkldnn::stream strm) {
|
||||
const float *srcData = reinterpret_cast<const float *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
float* dstData = reinterpret_cast<float *>(getChildEdgesAtPort(0)[0]->getMemoryPtr()->GetPtr());
|
||||
|
@ -16,12 +16,11 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
void prepareParams() override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
|
@ -110,14 +110,6 @@ std::shared_ptr<MemoryDesc> MKLDNNLrnNode::getSrcMemDesc(mkldnn::primitive_desc_
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNLrnNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNLrnNode::prepareParams() {
|
||||
auto& srcMemPtr = getParentEdgeAt(0)->getMemoryPtr();
|
||||
auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr();
|
||||
@ -174,8 +166,8 @@ std::vector<VectorDims> MKLDNNLrnNode::shapeInfer() const {
|
||||
return { getParentEdgesAtPort(0).front()->getMemory().getStaticDims() };
|
||||
}
|
||||
|
||||
void MKLDNNLrnNode::executeDynamicImpl(dnnl::stream strm) {
|
||||
MKLDNNNode::execute(strm);
|
||||
void MKLDNNLrnNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
REG_MKLDNN_PRIM_FOR(MKLDNNLrnNode, Lrn);
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
return static_cast<size_t>(getOriginalInputsNumber());
|
||||
}
|
||||
std::shared_ptr<MemoryDesc> getSrcMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx) override;
|
||||
void createPrimitive() override;
|
||||
bool created() const override;
|
||||
bool canBeInPlace() const override {
|
||||
return false;
|
||||
|
@ -63,6 +63,10 @@ std::vector<VectorDims> MKLDNNMathNode::shapeInfer() const {
|
||||
return std::vector<VectorDims>{getParentEdgesAtPort(0)[0]->getMemory().getStaticDims()};
|
||||
}
|
||||
|
||||
void MKLDNNMathNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNMathNode::execute(mkldnn::stream strm) {
|
||||
size_t dataSize = getChildEdgesAtPort(0)[0]->getMemory().GetShape().getElementsCount();
|
||||
const float *src_data = reinterpret_cast<const float *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
|
||||
|
@ -15,13 +15,12 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override {};
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
std::vector<VectorDims> shapeInfer() const override;
|
||||
bool needPrepareParams() const override { return false; };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
|
@ -313,14 +313,6 @@ void MKLDNNMatMulNode::initSupportedPrimitiveDescriptors() {
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNMatMulNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
MemoryDescPtr MKLDNNMatMulNode::getSrcMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx) {
|
||||
auto desc = idx > 0 ? primitive_desc_it.weights_desc(idx - 1): primitive_desc_it.src_desc(idx);
|
||||
|
||||
|
@ -22,7 +22,6 @@ public:
|
||||
const std::vector<MemoryDescPtr>& outputDesc) override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
MemoryDescPtr getSrcMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx) override;
|
||||
void createPrimitive() override;
|
||||
bool canFuse(const MKLDNNNodePtr& node) const override;
|
||||
bool created() const override;
|
||||
size_t getMaxBatch() const override;
|
||||
|
@ -240,13 +240,6 @@ size_t MKLDNNMatrixNmsNode::nmsMatrix(const float* boxesData, const float* score
|
||||
return numDet;
|
||||
}
|
||||
|
||||
void MKLDNNMatrixNmsNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNMatrixNmsNode::prepareParams() {
|
||||
const auto& boxes_dims = getParentEdgeAt(NMS_BOXES)->getMemory().getStaticDims();
|
||||
const auto& scores_dims = getParentEdgeAt(NMS_SCORES)->getMemory().getStaticDims();
|
||||
@ -288,6 +281,23 @@ void MKLDNNMatrixNmsNode::prepareParams() {
|
||||
}
|
||||
}
|
||||
|
||||
bool MKLDNNMatrixNmsNode::isExecutable() const {
|
||||
return isDynamicNode() || MKLDNNNode::isExecutable();
|
||||
}
|
||||
|
||||
void MKLDNNMatrixNmsNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
if (hasEmptyInputTensors()) {
|
||||
getChildEdgesAtPort(NMS_SELECTED_OUTPUTS)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTED_OUTPUTS)->cloneWithNewDims({0, 6}));
|
||||
getChildEdgesAtPort(NMS_SELECTED_INDICES)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTED_INDICES)->cloneWithNewDims({0, 1}));
|
||||
getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_VALID_OUTPUTS)->cloneWithNewDims({0}));
|
||||
return;
|
||||
}
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNMatrixNmsNode::execute(mkldnn::stream strm) {
|
||||
const float* boxes = reinterpret_cast<const float*>(getParentEdgeAt(NMS_BOXES)->getMemoryPtr()->GetPtr());
|
||||
const float* scores = reinterpret_cast<const float*>(getParentEdgeAt(NMS_SCORES)->getMemoryPtr()->GetPtr());
|
||||
|
@ -27,13 +27,13 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
bool isExecutable() const override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
bool needShapeInfer() const override { return false; }
|
||||
void prepareParams() override;
|
||||
|
@ -105,13 +105,6 @@ void MKLDNNMultiClassNmsNode::initSupportedPrimitiveDescriptors() {
|
||||
impl_desc_type::ref_any);
|
||||
}
|
||||
|
||||
void MKLDNNMultiClassNmsNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNMultiClassNmsNode::prepareParams() {
|
||||
const auto& boxes_dims = getParentEdgeAt(NMS_BOXES)->getMemory().getStaticDims();
|
||||
const auto& scores_dims = getParentEdgeAt(NMS_SCORES)->getMemory().getStaticDims();
|
||||
@ -145,6 +138,23 @@ void MKLDNNMultiClassNmsNode::prepareParams() {
|
||||
m_numBoxOffset.resize(m_numBatches);
|
||||
}
|
||||
|
||||
bool MKLDNNMultiClassNmsNode::isExecutable() const {
|
||||
return isDynamicNode() || MKLDNNNode::isExecutable();
|
||||
}
|
||||
|
||||
void MKLDNNMultiClassNmsNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
if (hasEmptyInputTensors()) {
|
||||
getChildEdgesAtPort(NMS_SELECTEDOUTPUTS)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTEDOUTPUTS)->cloneWithNewDims({0, 6}));
|
||||
getChildEdgesAtPort(NMS_SELECTEDINDICES)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims({0, 1}));
|
||||
getChildEdgesAtPort(NMS_SELECTEDNUM)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTEDNUM)->cloneWithNewDims({0}));
|
||||
return;
|
||||
}
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNMultiClassNmsNode::execute(mkldnn::stream strm) {
|
||||
const float* boxes = reinterpret_cast<const float*>(getParentEdgeAt(NMS_BOXES)->getMemoryPtr()->GetPtr());
|
||||
const float* scores = reinterpret_cast<const float*>(getParentEdgeAt(NMS_SCORES)->getMemoryPtr()->GetPtr());
|
||||
|
@ -23,13 +23,13 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
bool isExecutable() const override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
bool needShapeInfer() const override { return false; }
|
||||
void prepareParams() override;
|
||||
|
@ -849,14 +849,6 @@ void MKLDNNMVNNode::prepareParams() {
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNMVNNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
if (needPrepareParams())
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
}
|
||||
|
||||
void MKLDNNMVNNode::transformTo5DCase(const SizeVector& shape) {
|
||||
switch (shape.size()) {
|
||||
// for 1 and 2 rank, if initAcrossChannels_ is true, adjust shape to fully vectorize under unified 5d procedure.
|
||||
@ -908,6 +900,10 @@ void MKLDNNMVNNode::setPostOps(mkldnn::primitive_attr &attr, bool initWeights) {
|
||||
attr.set_post_ops(ops);
|
||||
}
|
||||
|
||||
void MKLDNNMVNNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNMVNNode::execute(mkldnn::stream strm) {
|
||||
auto &dstMemPtr = getChildEdgeAt(0)->getMemoryPtr();
|
||||
auto &srcMemPtr = getParentEdgeAt(0)->getMemoryPtr();
|
||||
|
@ -77,10 +77,9 @@ public:
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
void getSupportedDescriptors() override;
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
bool created() const override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); }
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
bool canBeInPlace() const override {
|
||||
return false;
|
||||
}
|
||||
|
@ -147,14 +147,20 @@ void MKLDNNNonMaxSuppressionNode::prepareParams() {
|
||||
i.resize(num_classes);
|
||||
}
|
||||
|
||||
void MKLDNNNonMaxSuppressionNode::createPrimitive() {
|
||||
if (inputShapesDefined()) {
|
||||
prepareParams();
|
||||
updateLastInputDims();
|
||||
}
|
||||
bool MKLDNNNonMaxSuppressionNode::isExecutable() const {
|
||||
return isDynamicNode() || MKLDNNNode::isExecutable();
|
||||
}
|
||||
|
||||
void MKLDNNNonMaxSuppressionNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
if (hasEmptyInputTensors() || (inputShapes.size() > NMS_MAXOUTPUTBOXESPERCLASS &&
|
||||
reinterpret_cast<int *>(getParentEdgeAt(NMS_MAXOUTPUTBOXESPERCLASS)->getMemoryPtr()->GetPtr())[0] == 0)) {
|
||||
getChildEdgesAtPort(NMS_SELECTEDINDICES)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims({0, 3}));
|
||||
getChildEdgesAtPort(NMS_SELECTEDSCORES)[0]->getMemoryPtr()->redefineDesc(
|
||||
getBaseMemDescAtOutputPort(NMS_SELECTEDSCORES)->cloneWithNewDims({0, 3}));
|
||||
*reinterpret_cast<int *>(getChildEdgesAtPort(NMS_VALIDOUTPUTS)[0]->getMemoryPtr()->GetPtr()) = 0;
|
||||
return;
|
||||
}
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
@ -168,8 +174,9 @@ void MKLDNNNonMaxSuppressionNode::execute(mkldnn::stream strm) {
|
||||
|
||||
max_output_boxes_per_class = std::min(max_output_boxes_per_class, num_boxes);
|
||||
|
||||
if (max_output_boxes_per_class == 0)
|
||||
if (max_output_boxes_per_class == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inputShapes.size() > NMS_IOUTHRESHOLD)
|
||||
iou_threshold = reinterpret_cast<float *>(getParentEdgeAt(NMS_IOUTHRESHOLD)->getMemoryPtr()->GetPtr())[0];
|
||||
|
@ -20,7 +20,6 @@ public:
|
||||
|
||||
void getSupportedDescriptors() override {};
|
||||
void initSupportedPrimitiveDescriptors() override;
|
||||
void createPrimitive() override;
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
@ -52,6 +51,7 @@ public:
|
||||
|
||||
void executeDynamicImpl(mkldnn::stream strm) override;
|
||||
|
||||
bool isExecutable() const override;
|
||||
bool needShapeInfer() const override { return false; }
|
||||
void prepareParams() override;
|
||||
|
||||
|
@ -85,6 +85,11 @@ struct MKLDNNNonZeroNode::NonZeroExecute {
|
||||
ctx.node.executeSpecified<T>();
|
||||
}
|
||||
};
|
||||
|
||||
void MKLDNNNonZeroNode::executeDynamicImpl(mkldnn::stream strm) {
|
||||
execute(strm);
|
||||
}
|
||||
|
||||
void MKLDNNNonZeroNode::execute(mkldnn::stream strm) {
|
||||
auto inputPrec = getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision();
|
||||
NonZeroContext ctx = {*this };
|
||||
@ -104,6 +109,7 @@ void MKLDNNNonZeroNode::executeSpecified() {
|
||||
Shape inShape = getParentEdgeAt(0)->getMemory().GetShape();
|
||||
size_t inRank = inShape.getRank();
|
||||
size_t nonZeroCount = getNonZeroElementsCount(src, inShape);
|
||||
|
||||
if (isDynamicNode()) {
|
||||
VectorDims newDims{inRank, nonZeroCount};
|
||||
dstMemPtr->redefineDesc(getBaseMemDescAtOutputPort(0)->cloneWithNewDims(newDims));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user