Merge onnx_importer to onnx_ngraph_frontend (#6825)
* Merge onnx_importer to onnx_ngraph_frontend * address review comments * use onnx_ngraph_frontend in docs/template_extension * link onnx_ngraph_frontend instead of onnx_importer * switch onnxruntime branch to rel-1.8.1_ov_2022.1 in https://github.com/intel/onnxruntime * Remove pip install cmake since the 1.8.1 release doesnt require it * add alias * set IMPORTED_GLOBAL Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
This commit is contained in:
@@ -117,7 +117,6 @@ jobs:
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
|
||||
-DENABLE_WHEEL=ON
|
||||
-DENABLE_TESTS=ON
|
||||
-DNGRAPH_ONNX_IMPORT_ENABLE=ON
|
||||
-DNGRAPH_ONNX_FRONTEND_ENABLE=ON
|
||||
-DENABLE_FASTER_BUILD=ON
|
||||
-DENABLE_STRICT_DEPENDENCIES=OFF
|
||||
|
||||
@@ -94,7 +94,6 @@ jobs:
|
||||
-DENABLE_PROFILING_ITT=OFF
|
||||
-DENABLE_SAMPLES=OFF
|
||||
-DENABLE_SPEECH_DEMO=OFF
|
||||
-DNGRAPH_ONNX_IMPORT_ENABLE=ON
|
||||
-DNGRAPH_ONNX_FRONTEND_ENABLE=ON
|
||||
-DNGRAPH_DEBUG_ENABLE=OFF
|
||||
$(REPO_DIR)
|
||||
|
||||
@@ -68,7 +68,6 @@ RUN cmake .. \
|
||||
-DENABLE_SPEECH_DEMO=OFF \
|
||||
-DENABLE_PYTHON=ON \
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
|
||||
-DNGRAPH_ONNX_IMPORT_ENABLE=ON \
|
||||
-DNGRAPH_ONNX_FRONTEND_ENABLE=ON \
|
||||
-DNGRAPH_DEBUG_ENABLE=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX=/openvino/dist \
|
||||
|
||||
@@ -90,17 +90,10 @@ ie_coverage_extract(INPUT "openvino" OUTPUT "ngraph"
|
||||
ie_coverage_genhtml(INFO_FILE "ngraph"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx_importer"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx/onnx_common*"
|
||||
"${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx/onnx_import*")
|
||||
ie_coverage_genhtml(INFO_FILE "onnx_importer"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx_ngraph_frontend"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx/frontend*")
|
||||
ie_coverage_genhtml(INFO_FILE "onnx_ngraph_frontend"
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx/*"
|
||||
"${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx/*")
|
||||
ie_coverage_genhtml(INFO_FILE "onnx"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
@@ -122,13 +122,12 @@ else()
|
||||
set(protoc_available ON)
|
||||
endif()
|
||||
|
||||
ie_dependent_option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" ON "protoc_available" OFF)
|
||||
ie_dependent_option(NGRAPH_ONNX_FRONTEND_ENABLE "Enable ONNX FrontEnd" OFF "NGRAPH_ONNX_IMPORT_ENABLE" OFF)
|
||||
ie_dependent_option(NGRAPH_ONNX_FRONTEND_ENABLE "Enable ONNX FrontEnd" ON "protoc_available" OFF)
|
||||
ie_dependent_option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" ON "protoc_available" OFF)
|
||||
ie_dependent_option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" ON
|
||||
"NGRAPH_ONNX_IMPORT_ENABLE" OFF)
|
||||
"NGRAPH_ONNX_FRONTEND_ENABLE" OFF)
|
||||
ie_dependent_option(NGRAPH_USE_SYSTEM_PROTOBUF "Use system protobuf" OFF
|
||||
"NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE" OFF)
|
||||
"NGRAPH_ONNX_FRONTEND_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE" OFF)
|
||||
ie_dependent_option(NGRAPH_UNIT_TEST_ENABLE "Enables ngraph unit tests" ON "ENABLE_TESTS;NOT ANDROID" OFF)
|
||||
ie_dependent_option(NGRAPH_UNIT_TEST_BACKENDS_ENABLE "Control the building of unit tests using backends" ON
|
||||
"NGRAPH_UNIT_TEST_ENABLE" OFF)
|
||||
|
||||
@@ -28,9 +28,8 @@
|
||||
#
|
||||
# ngraph::frontend_manager - nGraph frontend manager
|
||||
#
|
||||
# ngraph_onnx_importer_FOUND - True if the system has onnx_importer library
|
||||
# ngraph::onnx_importer - ONNX importer target (optional)
|
||||
# ONNX_IMPORTER_LIBRARIES - ONNX importer libraries
|
||||
# ngraph_onnx_ngraph_frontend_FOUND - True if the system has onnx_ngraph_frontend library
|
||||
# ngraph::onnx_ngraph_frontend - ONNX FrontEnd target (optional)
|
||||
#
|
||||
# ngraph_paddlepaddle_frontend_FOUND - True if the system has PDPD frontend
|
||||
# ngraph::paddlepaddle_ngraph_frontend - nGraph PDPD frontend (optional)
|
||||
@@ -38,18 +37,30 @@
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
function(set_imported_global target)
|
||||
get_target_property(IS_IMPORTED_GLOBAL ${target} IMPORTED_GLOBAL)
|
||||
if (NOT IS_IMPORTED_GLOBAL)
|
||||
set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT TARGET ngraph)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake")
|
||||
set_imported_global(ngraph::ngraph)
|
||||
set_imported_global(ngraph::frontend_manager)
|
||||
endif()
|
||||
|
||||
set(ngraph_ngraph_FOUND ON)
|
||||
set(NGRAPH_LIBRARIES ngraph::ngraph)
|
||||
|
||||
set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_IMPORT_ENABLE@)
|
||||
if(ngraph_onnx_importer_FOUND)
|
||||
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_importer)
|
||||
set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
|
||||
if (ngraph_onnx_ngraph_frontend_FOUND AND NOT TARGET onnx_ngraph_frontend AND NOT TARGET ngraph::onnx_importer)
|
||||
set_imported_global(ngraph::onnx_ngraph_frontend)
|
||||
add_library(ngraph::onnx_importer ALIAS ngraph::onnx_ngraph_frontend)
|
||||
endif()
|
||||
set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
|
||||
if(ngraph_paddlepaddle_frontend_FOUND AND NOT TARGET paddlepaddle_ngraph_frontend)
|
||||
set_imported_global(ngraph::paddlepaddle_ngraph_frontend)
|
||||
endif()
|
||||
|
||||
set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
|
||||
|
||||
check_required_components(ngraph)
|
||||
|
||||
@@ -17,7 +17,7 @@ function(ov_model_convert SRC DST OUT)
|
||||
get_filename_component(name_we "${in_file}" NAME_WE)
|
||||
set(model_source_dir "${SRC}/${rel_dir}")
|
||||
|
||||
if(NOT NGRAPH_ONNX_IMPORT_ENABLE AND ext MATCHES "^\\.(onnx|prototxt)$")
|
||||
if(NOT NGRAPH_ONNX_FRONTEND_ENABLE AND ext MATCHES "^\\.(onnx|prototxt)$")
|
||||
# don't copy / process ONNX / prototxt files
|
||||
continue()
|
||||
endif()
|
||||
@@ -78,7 +78,7 @@ ov_model_convert("${OpenVINO_SOURCE_DIR}/${rel_path}"
|
||||
ie_onnx_import_out_files)
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE AND ENABLE_REQUIREMENTS_INSTALL)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE AND ENABLE_REQUIREMENTS_INSTALL)
|
||||
find_package(PythonInterp 3 REQUIRED)
|
||||
|
||||
get_filename_component(PYTHON_EXEC_DIR ${PYTHON_EXECUTABLE} DIRECTORY)
|
||||
|
||||
@@ -25,7 +25,7 @@ if(NOT ENABLE_DOCKER)
|
||||
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(onnx_custom_op)
|
||||
endif()
|
||||
add_subdirectory(template_extension)
|
||||
|
||||
@@ -50,10 +50,9 @@ The example below demonstrates how to unregister an operator from the destructor
|
||||
|
||||
## Requirements for Building with CMake
|
||||
|
||||
A program that uses the `register_operator` functionality requires `ngraph` and `onnx_importer` libraries in addition to the Inference Engine.
|
||||
The `onnx_importer` is a component of the `ngraph` package , so `find_package(ngraph REQUIRED COMPONENTS onnx_importer)` can find both.
|
||||
The `ngraph` package exposes two variables, `${NGRAPH_LIBRARIES}` and `${ONNX_IMPORTER_LIBRARIES}`, which reference the `ngraph` and `onnx_importer` libraries.
|
||||
Those variables need to be passed to the `target_link_libraries` command in the CMakeLists.txt file.
|
||||
A program that uses the `register_operator` functionality requires `ngraph::ngraph` and `ngraph::onnx_ngraph_frontend` libraries in addition to the Inference Engine.
|
||||
The `onnx_ngraph_frontend` is a component of the `ngraph` package , so `find_package(ngraph REQUIRED COMPONENTS onnx_ngraph_frontend)` can find both.
|
||||
Those libraries need to be passed to the `target_link_libraries` command in the CMakeLists.txt file.
|
||||
|
||||
See CMakeLists.txt below for reference:
|
||||
@snippet onnx_custom_op/CMakeLists.txt cmake:onnx_custom_op
|
||||
|
||||
@@ -7,11 +7,11 @@ set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(TARGET_NAME "onnx_custom_op")
|
||||
|
||||
find_package(ngraph REQUIRED COMPONENTS onnx_importer)
|
||||
find_package(ngraph REQUIRED COMPONENTS onnx_ngraph_frontend)
|
||||
|
||||
add_library(${TARGET_NAME} STATIC onnx_custom_op.cpp onnx_custom_op.hpp)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} ${ONNX_IMPORTER_LIBRARIES})
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ngraph::ngraph ngraph::onnx_ngraph_frontend)
|
||||
# [cmake:onnx_custom_op]
|
||||
|
||||
# Enable code style check
|
||||
|
||||
@@ -44,8 +44,8 @@ if(OpenCV_FOUND)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE opencv_core)
|
||||
endif()
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE onnx_importer)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE onnx_ngraph_frontend)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
|
||||
@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(TARGET_NAME "template_extension")
|
||||
|
||||
find_package(ngraph REQUIRED OPTIONAL_COMPONENTS onnx_importer)
|
||||
find_package(ngraph REQUIRED OPTIONAL_COMPONENTS onnx_ngraph_frontend)
|
||||
find_package(InferenceEngine REQUIRED)
|
||||
find_package(OpenCV QUIET COMPONENTS core)
|
||||
|
||||
@@ -28,9 +28,9 @@ target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE IE::inference_engine
|
||||
${NGRAPH_LIBRARIES})
|
||||
|
||||
if (ngraph_onnx_importer_FOUND)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE ${ONNX_IMPORTER_LIBRARIES})
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE NGRAPH_ONNX_IMPORT_ENABLED)
|
||||
if (ngraph_onnx_ngraph_frontend_FOUND)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE ngraph::onnx_ngraph_frontend)
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE NGRAPH_ONNX_FRONTEND_ENABLED)
|
||||
endif()
|
||||
# [cmake:extension]
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include "fft_op.hpp"
|
||||
#endif
|
||||
#include <ngraph/ngraph.hpp>
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLED
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED
|
||||
# include <onnx_import/onnx_utils.hpp>
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ using namespace TemplateExtension;
|
||||
|
||||
//! [extension:ctor]
|
||||
Extension::Extension() {
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLED
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED
|
||||
ngraph::onnx_import::register_operator(Operation::type_info.name,
|
||||
1,
|
||||
"custom_domain",
|
||||
@@ -49,12 +49,12 @@ Extension::Extension() {
|
||||
|
||||
//! [extension:dtor]
|
||||
Extension::~Extension() {
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLED
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED
|
||||
ngraph::onnx_import::unregister_operator(Operation::type_info.name, 1, "custom_domain");
|
||||
# ifdef OPENCV_IMPORT_ENABLED
|
||||
ngraph::onnx_import::unregister_operator(FFTOp::type_info.name, 1, "custom_domain");
|
||||
# endif // OPENCV_IMPORT_ENABLED
|
||||
#endif // NGRAPH_ONNX_IMPORT_ENABLED
|
||||
#endif // NGRAPH_ONNX_FRONTEND_ENABLED
|
||||
}
|
||||
//! [extension:dtor]
|
||||
|
||||
|
||||
@@ -52,6 +52,6 @@ add_custom_target(ie_libraries ALL
|
||||
inference_engine_ir_v7_reader inference_engine_ir_reader
|
||||
inference_engine_lp_transformations inference_engine_snippets)
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_dependencies(ie_libraries inference_engine_onnx_reader)
|
||||
endif()
|
||||
|
||||
@@ -18,6 +18,6 @@ add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${reader_api_hpp})
|
||||
add_subdirectory(ir_reader)
|
||||
add_subdirectory(ir_reader_v7)
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(onnx_reader)
|
||||
endif()
|
||||
|
||||
@@ -23,7 +23,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_PLUGIN)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_reader_api onnx_importer inference_engine)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_reader_api onnx_ngraph_frontend inference_engine)
|
||||
|
||||
ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ set(DEPENDENCIES
|
||||
test_model_zoo
|
||||
)
|
||||
|
||||
if (NOT NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if (NOT NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
list(APPEND EXCLUDED_SOURCE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/onnx_reader")
|
||||
endif()
|
||||
|
||||
@@ -56,9 +56,9 @@ addIeTargetTest(
|
||||
|
||||
set_ie_threading_interface_for(${TARGET_NAME})
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE
|
||||
NGRAPH_ONNX_IMPORT_ENABLE
|
||||
NGRAPH_ONNX_FRONTEND_ENABLE
|
||||
ONNX_TEST_MODELS="${TEST_MODEL_ZOO}/onnx_reader/models/")
|
||||
add_dependencies(${TARGET_NAME} inference_engine_onnx_reader)
|
||||
endif()
|
||||
|
||||
@@ -61,7 +61,7 @@ TEST_F(CustomOpsSerializationTest, CustomOpUser_MO) {
|
||||
ASSERT_TRUE(success) << message;
|
||||
}
|
||||
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLE
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLE
|
||||
|
||||
TEST_F(CustomOpsSerializationTest, CustomOpUser_ONNXImporter) {
|
||||
const std::string model = CommonTestUtils::getModelFromTestModelZoo(
|
||||
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLE
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLE
|
||||
|
||||
TEST_F(SerializationDeterministicityTest, BasicModel) {
|
||||
const std::string model = CommonTestUtils::getModelFromTestModelZoo(
|
||||
|
||||
@@ -78,7 +78,7 @@ INSTANTIATE_TEST_SUITE_P(IRSerialization, SerializationTest,
|
||||
std::make_tuple("loop_2d_add.xml", "loop_2d_add.bin"),
|
||||
std::make_tuple("nms5_dynamism.xml", "nms5_dynamism.bin")));
|
||||
|
||||
#ifdef NGRAPH_ONNX_IMPORT_ENABLE
|
||||
#ifdef NGRAPH_ONNX_FRONTEND_ENABLE
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ONNXSerialization, SerializationTest,
|
||||
testing::Values(std::make_tuple("add_abc.onnx", ""),
|
||||
|
||||
@@ -11,7 +11,7 @@ target_link_libraries(cpuSpecificRtInfo PRIVATE ngraph)
|
||||
set(INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${IE_MAIN_SOURCE_DIR}/src/mkldnn_plugin)
|
||||
set(DEPENDENCIES MKLDNNPlugin AutoPlugin)
|
||||
set(LINK_LIBRARIES funcSharedTests cpuSpecificRtInfo)
|
||||
if (NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if (NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
list(APPEND INCLUDES "${OpenVINO_SOURCE_DIR}/docs/onnx_custom_op")
|
||||
list(APPEND LINK_LIBRARIES onnx_custom_op)
|
||||
list(APPEND DEPENDENCIES template_extension onnx_custom_op)
|
||||
|
||||
@@ -24,6 +24,6 @@ if (ENABLE_MYRIAD)
|
||||
add_subdirectory(vpu)
|
||||
endif ()
|
||||
|
||||
if(NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(frontends/onnx_import)
|
||||
endif()
|
||||
|
||||
@@ -11,7 +11,7 @@ addIeTargetTest(
|
||||
gtest
|
||||
gtest_main
|
||||
commonTestUtils
|
||||
onnx_importer
|
||||
onnx_ngraph_frontend
|
||||
DEFINES
|
||||
ONNX_MODELS_DIR=\"${TEST_MODEL_ZOO}/onnx_import\"
|
||||
ADD_CPPLINT
|
||||
|
||||
@@ -6,7 +6,7 @@ set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend")
|
||||
|
||||
add_subdirectory(frontend_manager)
|
||||
|
||||
if (NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
if (NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(onnx)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -3,7 +3,4 @@
|
||||
#
|
||||
|
||||
add_subdirectory(onnx_common)
|
||||
add_subdirectory(onnx_import)
|
||||
if (NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(frontend)
|
||||
endif()
|
||||
add_subdirectory(frontend)
|
||||
|
||||
@@ -2,11 +2,23 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
|
||||
file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)
|
||||
|
||||
set(ONNX_OPSET_VERSION 13 CACHE INTERNAL "Supported version of ONNX operator set")
|
||||
set(ONNX_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
|
||||
file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
|
||||
file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${ONNX_FRONTEND_INCLUDE_DIR}/*.hpp)
|
||||
|
||||
# Remove disabled ops
|
||||
list(REMOVE_ITEM LIBRARY_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.cpp
|
||||
)
|
||||
list(REMOVE_ITEM LIBRARY_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.hpp
|
||||
)
|
||||
|
||||
# Create named folders for the sources within the .vcproj
|
||||
# Empty name lists them directly under the .vcproj
|
||||
|
||||
@@ -20,29 +32,35 @@ add_library(ngraph::onnx_ngraph_frontend ALIAS onnx_ngraph_frontend)
|
||||
|
||||
add_clang_format_target(onnx_ngraph_frontend_clang FOR_TARGETS onnx_ngraph_frontend)
|
||||
|
||||
ov_ncc_naming_style(FOR_TARGET onnx_ngraph_frontend
|
||||
INCLUDE_DIRECTORY "${ONNX_FRONTEND_INCLUDE_DIR}"
|
||||
ADDITIONAL_INCLUDE_DIRECTORIES
|
||||
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
# TODO: fix empty class name
|
||||
#ov_ncc_naming_style(FOR_TARGET onnx_ngraph_frontend
|
||||
# INCLUDE_DIRECTORY "${ONNX_FRONTEND_INCLUDE_DIR}"
|
||||
# ADDITIONAL_INCLUDE_DIRECTORIES
|
||||
# $<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
if(COMMAND ie_add_vs_version_file)
|
||||
ie_add_vs_version_file(NAME onnx_ngraph_frontend
|
||||
FILEDESCRIPTION "nGraph ONNX frontend library")
|
||||
endif()
|
||||
|
||||
target_link_libraries(onnx_ngraph_frontend PRIVATE onnx_importer frontend_manager)
|
||||
target_link_libraries(onnx_ngraph_frontend PUBLIC ngraph PRIVATE frontend_manager ngraph::builder onnx_common inference_engine_transformations)
|
||||
|
||||
target_include_directories(onnx_ngraph_frontend PUBLIC $<BUILD_INTERFACE:${ONNX_FRONTEND_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>)
|
||||
|
||||
target_include_directories(onnx_ngraph_frontend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
target_compile_definitions(onnx_ngraph_frontend PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
|
||||
if(NGRAPH_USE_PROTOBUF_LITE)
|
||||
target_compile_definitions(onnx_ngraph_frontend PRIVATE NGRAPH_USE_PROTOBUF_LITE)
|
||||
endif()
|
||||
|
||||
install(TARGETS onnx_ngraph_frontend EXPORT ngraphTargets
|
||||
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
|
||||
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
|
||||
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
|
||||
|
||||
install(DIRECTORY ${ONNX_FRONTEND_INCLUDE_DIR}/onnx_frontend
|
||||
${ONNX_FRONTEND_INCLUDE_DIR}/onnx_import
|
||||
DESTINATION ${FRONTEND_INSTALL_INCLUDE}
|
||||
COMPONENT ngraph_dev
|
||||
FILES_MATCHING PATTERN "*.hpp")
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "ngraph/except.hpp"
|
||||
#include "ngraph/node.hpp"
|
||||
#include "onnx_import/utils/onnx_importer_visibility.hpp"
|
||||
#include "onnx_import/onnx_importer_visibility.hpp"
|
||||
|
||||
namespace ONNX_NAMESPACE
|
||||
{
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ngraph/node.hpp"
|
||||
#include "onnx_import/utils/onnx_importer_visibility.hpp"
|
||||
#include "onnx_import/onnx_importer_visibility.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -31,7 +31,7 @@ namespace ngraph
|
||||
///
|
||||
/// More:
|
||||
/// https://github.com/onnx/onnx/blob/master/docs/IR.md#optional-inputs-and-outputs
|
||||
class NullNode : public ngraph::Node
|
||||
class ONNX_IMPORTER_API NullNode : public ngraph::Node
|
||||
{
|
||||
public:
|
||||
static constexpr NodeTypeInfo type_info{"NullNode", 0};
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "ngraph/function.hpp"
|
||||
#include "utils/onnx_importer_visibility.hpp"
|
||||
#include "onnx_importer_visibility.hpp"
|
||||
|
||||
/// \brief Top level nGraph namespace.
|
||||
namespace ngraph
|
||||
@@ -72,12 +72,6 @@ namespace ngraph
|
||||
/// \return An nGraph function that represents a single output from the created graph.
|
||||
ONNX_IMPORTER_API
|
||||
std::shared_ptr<Function> import_onnx_model(const std::string& file_path);
|
||||
|
||||
/// \brief Converts a nGraph function (onnx model decoded to function with
|
||||
/// ONNXFrameworkNode(s))
|
||||
/// to a complete function with actual compute operations
|
||||
ONNX_IMPORTER_API
|
||||
void convert_decoded_function(std::shared_ptr<Function> function);
|
||||
} // namespace onnx_import
|
||||
|
||||
} // namespace ngraph
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "ngraph/visibility.hpp"
|
||||
|
||||
#ifdef onnx_importer_EXPORTS // defined if we are building the ONNX_IMPORTER
|
||||
#ifdef onnx_ngraph_frontend_EXPORTS
|
||||
#define ONNX_IMPORTER_API NGRAPH_HELPER_DLL_EXPORT
|
||||
#else
|
||||
#define ONNX_IMPORTER_API NGRAPH_HELPER_DLL_IMPORT
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "onnx_import/core/operator_set.hpp"
|
||||
#include "utils/onnx_importer_visibility.hpp"
|
||||
#include "onnx_importer_visibility.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "core/attribute.hpp"
|
||||
#include "core/graph.hpp"
|
||||
#include "core/model.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "onnx_import/core/model.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "core/graph.hpp"
|
||||
#include "core/null_node.hpp"
|
||||
#include "core/value_info.hpp"
|
||||
#include "default_opset.hpp"
|
||||
#include "exceptions.hpp"
|
||||
@@ -17,6 +16,7 @@
|
||||
#include "ngraph/provenance.hpp"
|
||||
#include "onnx_framework_node.hpp"
|
||||
#include "onnx_import/core/node.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/provenance_tag.hpp"
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "core/graph_cache.hpp"
|
||||
#include "core/model.hpp"
|
||||
#include "ngraph/op/parameter.hpp"
|
||||
#include "onnx_import/core/model.hpp"
|
||||
#include "onnx_import/core/operator_set.hpp"
|
||||
|
||||
namespace ngraph
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
#include <onnx/onnx_pb.h>
|
||||
|
||||
#include "core/model.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "onnx_framework_node.hpp"
|
||||
#include "onnx_import/core/model.hpp"
|
||||
#include "ops_bridge.hpp"
|
||||
|
||||
namespace ngraph
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "core/attribute.hpp"
|
||||
#include "core/graph.hpp"
|
||||
#include "core/null_node.hpp"
|
||||
#include "core/tensor.hpp"
|
||||
#include "onnx_import/core/node.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "ngraph/node.hpp"
|
||||
#include "null_node.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <onnx/defs/function.h>
|
||||
#include <onnx/defs/schema.h>
|
||||
|
||||
#include "core/model.hpp"
|
||||
#include "core/transform.hpp"
|
||||
#include "onnx_import/core/model.hpp"
|
||||
|
||||
#include "ngraph/file_util.hpp"
|
||||
#include "ops_bridge.hpp"
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "onnx_editor/editor_types.hpp"
|
||||
#include "editor_types.hpp"
|
||||
|
||||
namespace ONNX_NAMESPACE
|
||||
{
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <algorithm>
|
||||
#include <onnx/onnx_pb.h>
|
||||
|
||||
#include "edge_mapper.hpp"
|
||||
#include "ngraph/check.hpp"
|
||||
#include "ngraph/except.hpp"
|
||||
#include "onnx_editor/edge_mapper.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace ngraph::onnx_editor;
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "onnx_editor/editor_types.hpp"
|
||||
#include "editor_types.hpp"
|
||||
|
||||
namespace ONNX_NAMESPACE
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace ngraph
|
||||
class EdgeMapper
|
||||
{
|
||||
public:
|
||||
ONNX_IMPORTER_API EdgeMapper() = default;
|
||||
EdgeMapper() = default;
|
||||
|
||||
/// \brief Creates an edge mapper based on a GraphProto object.
|
||||
///
|
||||
@@ -51,8 +51,7 @@ namespace ngraph
|
||||
///
|
||||
/// \param input An EditorInput helper structure created based on a input name
|
||||
/// or a input index.
|
||||
ONNX_IMPORTER_API InputEdge find_input_edge(const EditorNode& node,
|
||||
const EditorInput& input) const;
|
||||
InputEdge find_input_edge(const EditorNode& node, const EditorInput& input) const;
|
||||
|
||||
/// \brief Returns an OutputEdge based on a node (node name or output name)
|
||||
/// and an output (output name or output index).
|
||||
@@ -69,8 +68,7 @@ namespace ngraph
|
||||
///
|
||||
/// \param output An EditorOutput helper structure created based on a output name
|
||||
/// or a output index.
|
||||
ONNX_IMPORTER_API OutputEdge find_output_edge(const EditorNode& node,
|
||||
const EditorOutput& output) const;
|
||||
OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output) const;
|
||||
|
||||
/// \brief Returns an OutputEdge based on a output name.
|
||||
///
|
||||
@@ -78,7 +76,7 @@ namespace ngraph
|
||||
///
|
||||
/// \param output_name A node output name.
|
||||
///
|
||||
ONNX_IMPORTER_API OutputEdge find_output_edge(const std::string& output_name) const;
|
||||
OutputEdge find_output_edge(const std::string& output_name) const;
|
||||
|
||||
/// \brief Returns a vector of InputEdges which consume an output of a node
|
||||
/// determined by provided output name.
|
||||
@@ -87,8 +85,7 @@ namespace ngraph
|
||||
///
|
||||
/// \param output_name A node output name.
|
||||
///
|
||||
ONNX_IMPORTER_API std::vector<InputEdge>
|
||||
find_output_consumers(const std::string& output_name) const;
|
||||
std::vector<InputEdge> find_output_consumers(const std::string& output_name) const;
|
||||
|
||||
/// \brief Returns true if a provided node is correct (exists in a graph)
|
||||
/// and is not ambiguous (identification of an ONNX node can be ambiguous
|
||||
@@ -97,7 +94,7 @@ namespace ngraph
|
||||
/// \param node An EditorNode helper structure created based on a node name
|
||||
/// or a node output name.
|
||||
///
|
||||
ONNX_IMPORTER_API bool is_correct_and_unambiguous_node(const EditorNode& node) const;
|
||||
bool is_correct_and_unambiguous_node(const EditorNode& node) const;
|
||||
|
||||
/// \brief Returns true if a provided tensor name is correct (exists in a graph).
|
||||
///
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <onnx/shape_inference/implementation.h>
|
||||
|
||||
#include "detail/subgraph_extraction.hpp"
|
||||
#include "edge_mapper.hpp"
|
||||
#include "editor.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "onnx_common/parser.hpp"
|
||||
#include "onnx_common/utils.hpp"
|
||||
#include "onnx_editor/edge_mapper.hpp"
|
||||
#include "onnx_editor/editor.hpp"
|
||||
#include "onnx_import/utils/onnx_internal.hpp"
|
||||
#include "utils/onnx_internal.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace ngraph::onnx_editor;
|
||||
@@ -8,12 +8,12 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "editor_types.hpp"
|
||||
#include "ngraph/function.hpp"
|
||||
#include "ngraph/op/constant.hpp"
|
||||
#include "ngraph/partial_shape.hpp"
|
||||
#include "ngraph/type/element_type.hpp"
|
||||
#include "onnx_editor/editor.hpp"
|
||||
#include "onnx_editor/editor_types.hpp"
|
||||
#include "onnx_import/onnx_importer_visibility.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "onnx_import/utils/onnx_importer_visibility.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
enum class EdgeType
|
||||
@@ -87,7 +85,7 @@ namespace ngraph
|
||||
///
|
||||
/// The optional argument "new_input_name" can be used to set a custom input name
|
||||
/// which can be created during cutting a graph.
|
||||
struct ONNX_IMPORTER_API EditorInput
|
||||
struct EditorInput
|
||||
{
|
||||
EditorInput() = delete;
|
||||
EditorInput(std::string input_name, std::string new_input_name = "")
|
||||
@@ -112,7 +110,7 @@ namespace ngraph
|
||||
/// ----(in_A)----> | test_node |
|
||||
/// +-----------+ ---(out2)--->
|
||||
/// You can indicate out2 as EditorOutput("out2") or EditorOutput(1)
|
||||
struct ONNX_IMPORTER_API EditorOutput
|
||||
struct EditorOutput
|
||||
{
|
||||
EditorOutput() = delete;
|
||||
EditorOutput(std::string output_name)
|
||||
@@ -137,7 +135,7 @@ namespace ngraph
|
||||
/// You can indicate test_node by name as EditorNode("test_node")
|
||||
/// or by assigned output as EditorNode(EditorOutput("out1"))
|
||||
/// or EditorNode(EditorOutput("out2"))
|
||||
struct ONNX_IMPORTER_API EditorNode
|
||||
struct EditorNode
|
||||
{
|
||||
EditorNode(std::string node_name)
|
||||
: m_node_name{std::move(node_name)}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <input_model.hpp>
|
||||
#include <onnx_frontend/frontend.hpp>
|
||||
#include <onnx_import/onnx.hpp>
|
||||
#include <utils/onnx_internal.hpp>
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace ngraph::frontend;
|
||||
@@ -19,7 +20,7 @@ extern "C" ONNX_FRONTEND_API FrontEndVersion GetAPIVersion()
|
||||
extern "C" ONNX_FRONTEND_API void* GetFrontEndData()
|
||||
{
|
||||
FrontEndPluginInfo* res = new FrontEndPluginInfo();
|
||||
res->m_name = "onnx";
|
||||
res->m_name = "onnx_experimental";
|
||||
res->m_creator = []() { return std::make_shared<FrontEndONNX>(); };
|
||||
return res;
|
||||
}
|
||||
@@ -44,7 +45,7 @@ std::shared_ptr<ngraph::Function> FrontEndONNX::convert(InputModel::Ptr model) c
|
||||
|
||||
void FrontEndONNX::convert(std::shared_ptr<ngraph::Function> partially_converted) const
|
||||
{
|
||||
onnx_import::convert_decoded_function(partially_converted);
|
||||
onnx_import::detail::convert_decoded_function(partially_converted);
|
||||
}
|
||||
|
||||
std::shared_ptr<ngraph::Function> FrontEndONNX::decode(InputModel::Ptr model) const
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <editor.hpp>
|
||||
#include <frontend_manager/input_model.hpp>
|
||||
#include <onnx_editor/editor.hpp>
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "ngraph/except.hpp"
|
||||
#include "onnx_common/parser.hpp"
|
||||
#include "onnx_import/onnx.hpp"
|
||||
#include "onnx_import/utils/onnx_internal.hpp"
|
||||
#include "ops_bridge.hpp"
|
||||
#include "utils/onnx_internal.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "core/null_node.hpp"
|
||||
#include "default_opset.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
#include "op/batch_norm.hpp"
|
||||
|
||||
namespace ngraph
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
#include "core/null_node.hpp"
|
||||
#include "default_opset.hpp"
|
||||
#include "ngraph/builder/make_constant.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
#include "op/clip.hpp"
|
||||
|
||||
namespace ngraph
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user