Accepting request 736849 from home:Guillaume_G:branches:home:mslacken:ml

- Replace patch with an upstreamable version:
 * armnn-generate-versioned-library.patch
- Add ONNX Parser support (disabled by default as there is no 
  official ONNX package yet)

OBS-URL: https://build.opensuse.org/request/show/736849
OBS-URL: https://build.opensuse.org/package/show/science:machinelearning/armnn?expand=0&rev=8
This commit is contained in:
Guillaume GARDET 2019-10-10 12:22:47 +00:00 committed by Git OBS Bridge
parent 98cd3ecc18
commit 3beeef13a8
3 changed files with 142 additions and 20 deletions

View File

@ -1,7 +1,38 @@
diff -purN armnn-19.08.orig/CMakeLists.txt armnn-19.08/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
--- armnn-19.08.orig/CMakeLists.txt 2019-08-30 07:49:26.000000000 +0000 index fc68f3af..3616ae8e 100644
+++ armnn-19.08/CMakeLists.txt 2019-09-05 08:13:37.958980306 +0000 --- a/CMakeLists.txt
@@ -95,6 +95,7 @@ if(BUILD_CAFFE_PARSER) +++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ project(armnn)
set(additional_cmake_files)
list(APPEND additional_cmake_files
+ cmake/armnnVersion.cmake
cmake/Utils.cmake
cmake/GlobalConfig.cmake
cmake/AddDllCopyCommands.cmake)
@@ -15,6 +16,21 @@ foreach(cmake_file ${additional_cmake_files})
include(${cmake_file})
endforeach()
+
+# Define LIB version
+set(GENERIC_LIB_VERSION "${ARMNN_MAJOR_VERSION}.${ARMNN_MINOR_VERSION}")
+# Define LIB soversion
+set(GENERIC_LIB_SOVERSION "${ARMNN_MAJOR_VERSION}")
+# Define _ARMNN_VERSION string to be used in include/armnn/Version.hpp for ARMNN_VERSION string
+set(_ARMNN_VERSION
+ "20${ARMNN_MAJOR_VERSION}${ARMNN_MINOR_VERSION}${ARMNN_BUILD_VERSION}")
+if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
+ add_definitions(-D_ARMNN_VERSION=${_ARMNN_VERSION})
+else()
+ add_compile_definitions(_ARMNN_VERSION=${_ARMNN_VERSION})
+endif()
+
+
if (DYNAMIC_BACKEND_PATHS)
# It's expected to have the format: DYNAMIC_BACKEND_PATHS="PATH_1:PATH_2...:PATH_N"
add_definitions('-DDYNAMIC_BACKEND_PATHS="${DYNAMIC_BACKEND_PATHS}"')
@@ -95,6 +111,7 @@ if(BUILD_CAFFE_PARSER)
target_link_libraries(armnnCaffeParser armnn) target_link_libraries(armnnCaffeParser armnn)
target_link_libraries(armnnCaffeParser ${PROTOBUF_LIBRARIES}) target_link_libraries(armnnCaffeParser ${PROTOBUF_LIBRARIES})
@ -9,7 +40,7 @@ diff -purN armnn-19.08.orig/CMakeLists.txt armnn-19.08/CMakeLists.txt
endif() endif()
@@ -119,6 +120,7 @@ if(BUILD_ONNX_PARSER) @@ -119,6 +136,7 @@ if(BUILD_ONNX_PARSER)
# Protobuf # Protobuf
target_link_libraries(armnnOnnxParser ${PROTOBUF_LIBRARIES}) target_link_libraries(armnnOnnxParser ${PROTOBUF_LIBRARIES})
@ -17,7 +48,7 @@ diff -purN armnn-19.08.orig/CMakeLists.txt armnn-19.08/CMakeLists.txt
endif() endif()
if(BUILD_TF_PARSER) if(BUILD_TF_PARSER)
@@ -142,6 +144,7 @@ if(BUILD_TF_PARSER) @@ -142,6 +160,7 @@ if(BUILD_TF_PARSER)
# Protobuf (use the specific version tensorflow wants) # Protobuf (use the specific version tensorflow wants)
target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES}) target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES})
@ -25,16 +56,16 @@ diff -purN armnn-19.08.orig/CMakeLists.txt armnn-19.08/CMakeLists.txt
endif() endif()
if(BUILD_ARMNN_QUANTIZER AND ARMNNREF) if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
@@ -199,6 +202,8 @@ if(BUILD_ARMNN_QUANTIZER AND ARMNNREF) @@ -200,6 +219,8 @@ if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
if(Threads_FOUND AND (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android)))
target_link_libraries(ArmnnQuantizer pthread) target_link_libraries(ArmnnQuantizer pthread)
endif() endif()
+
+ set_target_properties(ArmnnQuantizer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
+ set_target_properties(ArmnnQuantizer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
+
endif() endif()
@@ -484,6 +489,7 @@ endif()
@@ -539,6 +560,7 @@ endif()
if(PROFILING_BACKEND_STREAMLINE) if(PROFILING_BACKEND_STREAMLINE)
target_link_libraries(armnn pthread) target_link_libraries(armnn pthread)
endif() endif()
@ -42,18 +73,41 @@ diff -purN armnn-19.08.orig/CMakeLists.txt armnn-19.08/CMakeLists.txt
if(BUILD_UNIT_TESTS) if(BUILD_UNIT_TESTS)
set(unittest_sources) set(unittest_sources)
diff -purN armnn-19.08.orig/src/armnnSerializer/CMakeLists.txt armnn-19.08/src/armnnSerializer/CMakeLists.txt diff --git a/cmake/armnnVersion.cmake b/cmake/armnnVersion.cmake
--- armnn-19.08.orig/src/armnnSerializer/CMakeLists.txt 2019-08-30 07:49:26.000000000 +0000 new file mode 100644
+++ armnn-19.08/src/armnnSerializer/CMakeLists.txt 2019-09-05 08:18:41.108319913 +0000 index 00000000..68783370
--- /dev/null
+++ b/cmake/armnnVersion.cmake
@@ -0,0 +1,4 @@
+# ArmNN version number components.
+set(ARMNN_MAJOR_VERSION 19)
+set(ARMNN_MINOR_VERSION 08)
+set(ARMNN_BUILD_VERSION 00)
diff --git a/include/armnn/Version.hpp b/include/armnn/Version.hpp
index 9d73cd54..735be6b9 100644
--- a/include/armnn/Version.hpp
+++ b/include/armnn/Version.hpp
@@ -9,4 +9,5 @@
// YYYY = 4-digit year number
// MM = 2-digit month number
// PP = 2-digit patch number
-#define ARMNN_VERSION "20190800"
+// Defined in CMakeLists.txt
+#define ARMNN_VERSION _ARMNN_VERSION
diff --git a/src/armnnSerializer/CMakeLists.txt b/src/armnnSerializer/CMakeLists.txt
index 225999bb..ccc924e6 100755
--- a/src/armnnSerializer/CMakeLists.txt
+++ b/src/armnnSerializer/CMakeLists.txt
@@ -43,4 +43,5 @@ if(BUILD_ARMNN_SERIALIZER) @@ -43,4 +43,5 @@ if(BUILD_ARMNN_SERIALIZER)
install(TARGETS armnnSerializer install(TARGETS armnnSerializer
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ set_target_properties(armnnSerializer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + set_target_properties(armnnSerializer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
endif() endif()
diff -purN armnn-19.08.orig/src/armnnTfLiteParser/CMakeLists.txt armnn-19.08/src/armnnTfLiteParser/CMakeLists.txt diff --git a/src/armnnTfLiteParser/CMakeLists.txt b/src/armnnTfLiteParser/CMakeLists.txt
--- armnn-19.08.orig/src/armnnTfLiteParser/CMakeLists.txt 2019-08-30 07:49:26.000000000 +0000 index 17d4cf68..ae60079a 100755
+++ armnn-19.08/src/armnnTfLiteParser/CMakeLists.txt 2019-09-05 08:20:47.788043949 +0000 --- a/src/armnnTfLiteParser/CMakeLists.txt
+++ b/src/armnnTfLiteParser/CMakeLists.txt
@@ -21,6 +21,8 @@ if(BUILD_TF_LITE_PARSER) @@ -21,6 +21,8 @@ if(BUILD_TF_LITE_PARSER)
target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY}) target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
target_link_libraries(armnnTfLiteParser armnn ${FLATBUFFERS_LIBRARY}) target_link_libraries(armnnTfLiteParser armnn ${FLATBUFFERS_LIBRARY})

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Mon Oct 7 13:00:59 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org>
- Replace patch with an upstreamable version:
* armnn-generate-versioned-library.patch
-------------------------------------------------------------------
Tue Oct 1 19:04:50 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org>
- Add ONNX Parser support (disabled by default as there is no
official ONNX package yet)
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Oct 1 14:30:13 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org> Tue Oct 1 14:30:13 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org>

View File

@ -65,6 +65,9 @@
%bcond_with armnn_tf %bcond_with armnn_tf
%endif # suse_version %endif # suse_version
# Disable ONNX
%bcond_with armnn_onnx
%define version_major 19 %define version_major 19
%define version_minor 08 %define version_minor 08
@ -77,7 +80,7 @@ Group: Development/Libraries/Other
Url: https://developer.arm.com/products/processors/machine-learning/arm-nn Url: https://developer.arm.com/products/processors/machine-learning/arm-nn
Source0: https://github.com/ARM-software/armnn/archive/v%{version}.tar.gz#/armnn-%{version}.tar.gz Source0: https://github.com/ARM-software/armnn/archive/v%{version}.tar.gz#/armnn-%{version}.tar.gz
Source1: armnn-rpmlintrc Source1: armnn-rpmlintrc
# PATCH: based on http://arago-project.org/git/?p=meta-arago.git;a=blob;f=meta-arago-extras/recipes-support/armnn/armnn/0004-generate-versioned-library.patch;hb=master # PATCH-FIX-UPSTREAM - https://github.com/ARM-software/armnn/issues/275
Patch1: armnn-generate-versioned-library.patch Patch1: armnn-generate-versioned-library.patch
# Patch: http://arago-project.org/git/?p=meta-arago.git;a=blob;f=meta-arago-extras/recipes-support/armnn/armnn/0007-enable-use-of-arm-compute-shared-library.patch;hb=master # Patch: http://arago-project.org/git/?p=meta-arago.git;a=blob;f=meta-arago-extras/recipes-support/armnn/armnn/0007-enable-use-of-arm-compute-shared-library.patch;hb=master
Patch2: 0007-enable-use-of-arm-compute-shared-library.patch Patch2: 0007-enable-use-of-arm-compute-shared-library.patch
@ -115,6 +118,9 @@ BuildRequires: Mesa-libOpenCL
BuildRequires: ocl-icd-devel BuildRequires: ocl-icd-devel
BuildRequires: opencl-cpp-headers BuildRequires: opencl-cpp-headers
%endif %endif
%if %{with armnn_onnx}
BuildRequires: python3-onnx-devel
%endif
BuildRequires: protobuf-devel BuildRequires: protobuf-devel
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
%if %{with armnn_tests} %if %{with armnn_tests}
@ -136,6 +142,9 @@ Requires: libarmnnTfLiteParser%{version_major}%{?package_suffix} = %{versi
%if %{with armnn_caffe} %if %{with armnn_caffe}
Requires: libarmnnCaffeParser%{version_major}%{?package_suffix} = %{version} Requires: libarmnnCaffeParser%{version_major}%{?package_suffix} = %{version}
%endif %endif
%if %{with armnn_onnx}
Requires: libarmnnOnnxParser%{version_major}%{?package_suffix} = %{version}
%endif
%if %{with armnn_tf} %if %{with armnn_tf}
Requires: libarmnnTfParser%{version_major}%{?package_suffix} = %{version} Requires: libarmnnTfParser%{version_major}%{?package_suffix} = %{version}
%endif %endif
@ -166,6 +175,9 @@ Requires: libarmnnTfLiteParser%{version_major}%{?package_suffix} = %{versi
%if %{with armnn_caffe} %if %{with armnn_caffe}
Requires: libarmnnCaffeParser%{version_major}%{?package_suffix} = %{version} Requires: libarmnnCaffeParser%{version_major}%{?package_suffix} = %{version}
%endif %endif
%if %{with armnn_onnx}
Requires: libarmnnOnnxParser%{version_major}%{?package_suffix} = %{version}
%endif
%if %{with armnn_tf} %if %{with armnn_tf}
Requires: libarmnnTfParser%{version_major}%{?package_suffix} = %{version} Requires: libarmnnTfParser%{version_major}%{?package_suffix} = %{version}
%endif %endif
@ -275,6 +287,26 @@ modification across Arm Cortex CPUs and Arm Mali GPUs.
This package contains the libarmnnCaffeParser library from armnn. This package contains the libarmnnCaffeParser library from armnn.
%endif %endif
%if %{with armnn_onnx}
%package -n libarmnnOnnxParser%{version_major}%{?package_suffix}
%if "%{target}" == "opencl"
Conflicts: libarmnnOnnxParser%{version_major}
%else
Conflicts: libarmnnOnnxParser%{version_major}-opencl
%endif
Summary: libarmnnOnnxParser from armnn
Group: Development/Libraries/C and C++
%description -n libarmnnOnnxParser%{version_major}%{?package_suffix}
Arm NN is an inference engine for CPUs, GPUs and NPUs.
It bridges the gap between existing NN frameworks and the underlying IP.
It enables efficient translation of existing neural network frameworks,
such as TensorFlow and Caffe, allowing them to run efficiently without
modification across Arm Cortex CPUs and Arm Mali GPUs.
This package contains the libarmnnOnnxParser library from armnn.
%endif
%prep %prep
%setup -q -n armnn-%{version} %setup -q -n armnn-%{version}
%patch1 -p1 %patch1 -p1
@ -291,9 +323,12 @@ sed -i 's/find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system
sed -i 's/-Wsign-conversion//' ./cmake/GlobalConfig.cmake sed -i 's/-Wsign-conversion//' ./cmake/GlobalConfig.cmake
%build %build
%if %{with armnn_onnx}
mkdir onnx_deps
PROTO=$(find %{_libdir} -name onnx.proto)
protoc $PROTO --proto_path=. --proto_path=%{_includedir} --proto_path=$(dirname $(find %{_libdir} -name onnx)) --cpp_out=./onnx_deps
%endif
%cmake \ %cmake \
-DGENERIC_LIB_VERSION=%{version} \
-DGENERIC_LIB_SOVERSION=%{version_major} \
-DCMAKE_CXX_FLAGS:STRING="%{optflags} -pthread" \ -DCMAKE_CXX_FLAGS:STRING="%{optflags} -pthread" \
-DBOOST_LIBRARYDIR=%{_libdir} \ -DBOOST_LIBRARYDIR=%{_libdir} \
%if %{with armnn_caffe} %if %{with armnn_caffe}
@ -302,7 +337,12 @@ sed -i 's/-Wsign-conversion//' ./cmake/GlobalConfig.cmake
-DBUILD_CAFFE_PARSER=OFF \ -DBUILD_CAFFE_PARSER=OFF \
%endif %endif
-DCAFFE_GENERATED_SOURCES=%{_includedir}/ \ -DCAFFE_GENERATED_SOURCES=%{_includedir}/ \
%if %{with armnn_onnx}
-DBUILD_ONNX_PARSER=ON \
-DONNX_GENERATED_SOURCES=../onnx_deps/ \
%else
-DBUILD_ONNX_PARSER=OFF \ -DBUILD_ONNX_PARSER=OFF \
%endif
%if %{with armnn_flatbuffers} %if %{with armnn_flatbuffers}
-DBUILD_ARMNN_SERIALIZER=ON \ -DBUILD_ARMNN_SERIALIZER=ON \
-DFLATC_DIR=%{_bindir} \ -DFLATC_DIR=%{_bindir} \
@ -408,6 +448,11 @@ LD_LIBRARY_PATH="$(pwd)/build/" \
%postun -n libarmnnCaffeParser%{version_major}%{?package_suffix} -p /sbin/ldconfig %postun -n libarmnnCaffeParser%{version_major}%{?package_suffix} -p /sbin/ldconfig
%endif %endif
%if %{with armnn_onnx}
%post -n libarmnnOnnxParser%{version_major}%{?package_suffix} -p /sbin/ldconfig
%postun -n libarmnnOnnxParser%{version_major}%{?package_suffix} -p /sbin/ldconfig
%endif
%files %files
%defattr(-,root,root) %defattr(-,root,root)
@ -423,6 +468,9 @@ LD_LIBRARY_PATH="$(pwd)/build/" \
%{_bindir}/TfLite*-Armnn %{_bindir}/TfLite*-Armnn
%{_bindir}/Image*Generator %{_bindir}/Image*Generator
%endif %endif
%if %{with armnn_onnx}
%{_bindir}/Onnx*-Armnn
%endif
%if %{with armnn_tf} %if %{with armnn_tf}
%{_bindir}/Tf*-Armnn %{_bindir}/Tf*-Armnn
%endif %endif
@ -452,6 +500,11 @@ LD_LIBRARY_PATH="$(pwd)/build/" \
%{_libdir}/libarmnnCaffeParser.so.* %{_libdir}/libarmnnCaffeParser.so.*
%endif %endif
%if %{with armnn_onnx}
%files -n libarmnnOnnxParser%{version_major}%{?package_suffix}
%{_libdir}/libarmnnOnnxParser.so.*
%endif
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)
%dir %{_includedir}/armnn/ %dir %{_includedir}/armnn/
@ -481,6 +534,9 @@ LD_LIBRARY_PATH="$(pwd)/build/" \
%if %{with armnn_caffe} %if %{with armnn_caffe}
%{_libdir}/libarmnnCaffeParser.so %{_libdir}/libarmnnCaffeParser.so
%endif %endif
%if %{with armnn_onnx}
%{_libdir}/libarmnnOnnxParser.so
%endif
%changelog %changelog