openvino/onnx-frontend-enable.patch
Alexander F. Lent bc9d3f2564 Enable ONNX Frontend
This introduces a new subpackage, libopenvino-onnx-frontend, which
contains the ONNX frontend for OpenVINO.

The new patch contains some tweaks to make it build against the
system-provided protobuf and ONNX libraries.
(I think with ONNX we are supposed to include its CMake files
somehow, but I'm not a CMake expert, so I manually set the vars.)

Signed-off-by: Alexander F. Lent <lx@xanderlent.com>
2025-03-03 12:01:58 +00:00

53 lines
2.9 KiB
Diff

diff -ur a/cmake/developer_package/frontends/frontends.cmake b/cmake/developer_package/frontends/frontends.cmake
--- a/cmake/developer_package/frontends/frontends.cmake 2024-11-09 01:14:37.000000000 -0500
+++ b/cmake/developer_package/frontends/frontends.cmake 2024-11-09 01:14:37.000000000 -0500
@@ -246,7 +246,7 @@
set(protobuf_target_name libprotobuf-lite)
set(protobuf_install_name "protobuf_lite_installed")
else()
- set(protobuf_target_name libprotobuf)
+ set(protobuf_target_name protobuf)
set(protobuf_install_name "protobuf_installed")
endif()
if(ENABLE_SYSTEM_PROTOBUF)
diff -ur a/src/frontends/common/CMakeLists.txt b/src/frontends/common/CMakeLists.txt
--- a/src/frontends/common/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
+++ b/src/frontends/common/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
@@ -83,6 +83,6 @@
${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL})
# Shutdown protobuf library
-if(Protobuf_IN_FRONTEND AND BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS)
add_subdirectory(shutdown_protobuf)
endif()
diff -ur a/src/frontends/common/shutdown_protobuf/CMakeLists.txt b/src/frontends/common/shutdown_protobuf/CMakeLists.txt
--- a/src/frontends/common/shutdown_protobuf/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
+++ b/src/frontends/common/shutdown_protobuf/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
@@ -9,7 +9,7 @@
add_library(openvino::protobuf_shutdown ALIAS ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME protobuf_shutdown)
-target_include_directories(${TARGET_NAME} SYSTEM PRIVATE
- $<BUILD_INTERFACE:$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>>)
-set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
-target_compile_features(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_FEATURES>)
+#target_include_directories(${TARGET_NAME} SYSTEM PRIVATE
+# $<BUILD_INTERFACE:$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>>)
+#set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
+#target_compile_features(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_FEATURES>)
diff -ur a/src/frontends/onnx/CMakeLists.txt b/src/frontends/onnx/CMakeLists.txt
--- a/src/frontends/onnx/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
+++ b/src/frontends/onnx/CMakeLists.txt 2024-11-09 01:14:37.000000000 -0500
@@ -2,6 +2,11 @@
# SPDX-License-Identifier: Apache-2.0
#
+# TODO: Replace these with including the defs from ONNX's CMake files
+add_definitions(-DONNX_NAMESPACE=onnx -DONNX_ML=1)
+# TODO: The ONNX frontend uses functions only available in -std=c++17
+add_compile_options(-std=c++17)
+
add_subdirectory(onnx_common)
add_subdirectory(frontend)