commit 331194d69e4eee12627ae2edf02afb9ac6861802ca799ffe7651c0418045c665 Author: Christian Goll Date: Tue Apr 23 13:38:58 2019 +0000 Accepting request 695957 from home:Guillaume_G:branches:science:machinelearning - Add compute_cl option, disabled by default since check fails as no openCL are enabled in OBS - Split libarmnn and libarmnnSerializer to separate packages - Add patch to have versionned libs: * armnn-generate-versioned-library.patch - Package versionned libs - Enable NEON backend on AArch64 - Add patch to enable use of shared lib for ComputeLibrary: * 0007-enable-use-of-arm-compute-shared-library.patch - Update to 19.02 - Remove upstreamed patch: * armnn-fix_catching_polymorphic_type.patch - Update to 18.11 - Add patch to fix build: * armnn-fix_catching_polymorphic_type.patch * armnn-fix_boost.patch * armnn-fix_stb_include.patch - Initial version 18.08 OBS-URL: https://build.opensuse.org/request/show/695957 OBS-URL: https://build.opensuse.org/package/show/science:machinelearning/armnn?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/0007-enable-use-of-arm-compute-shared-library.patch b/0007-enable-use-of-arm-compute-shared-library.patch new file mode 100644 index 0000000..42a3262 --- /dev/null +++ b/0007-enable-use-of-arm-compute-shared-library.patch @@ -0,0 +1,31 @@ +From 38e8e4bc03a4c1ee801f6af50be94ccd971bf3eb Mon Sep 17 00:00:00 2001 +From: Qin Su +Date: Tue, 27 Nov 2018 18:15:49 -0500 +Subject: [PATCH] enable use of arm compute shared library + +Upstream-Status: Inappropriate [configuration] + +Signed-off-by: Qin Su +--- + cmake/GlobalConfig.cmake | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake +index 491d87a..4cf40a2 100644 +--- a/cmake/GlobalConfig.cmake ++++ b/cmake/GlobalConfig.cmake +@@ -285,6 +285,11 @@ if(ARMCOMPUTENEON OR ARMCOMPUTECL) + find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static) + find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static) + ++ find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute) ++ find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute) ++ find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core) ++ find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core) ++ + set(ARMCOMPUTE_LIBRARIES + debug ${ARMCOMPUTE_LIBRARY_DEBUG} ${ARMCOMPUTE_CORE_LIBRARY_DEBUG} + optimized ${ARMCOMPUTE_LIBRARY_RELEASE} ${ARMCOMPUTE_CORE_LIBRARY_RELEASE} ) +-- +1.9.1 + diff --git a/armnn-19.02.tar.gz b/armnn-19.02.tar.gz new file mode 100644 index 0000000..c599d0c --- /dev/null +++ b/armnn-19.02.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50f1551ec6a40097a38694119db82b7c45f6e10277d26db5010460f19de8c8f2 +size 765857 diff --git a/armnn-fix_boost.patch b/armnn-fix_boost.patch new file mode 100644 index 0000000..e9a5b3c --- /dev/null +++ b/armnn-fix_boost.patch @@ -0,0 +1,10 @@ +--- armnn-19.02.orig/src/armnn/test/TensorHelpers.hpp 2019-03-26 16:08:56.403605790 +0100 ++++ armnn-19.02/src/armnn/test/TensorHelpers.hpp 2019-03-26 16:09:58.448265384 +0100 +@@ -13,6 +13,7 @@ + #include + #include + #include ++#define BOOST_ALLOW_DEPRECATED_HEADERS + #include + #include + diff --git a/armnn-fix_stb_include.patch b/armnn-fix_stb_include.patch new file mode 100644 index 0000000..fead44c --- /dev/null +++ b/armnn-fix_stb_include.patch @@ -0,0 +1,19 @@ +--- armnn-19.02.orig/tests/InferenceTestImage.cpp 2019-03-26 16:40:06.771572115 +0100 ++++ armnn-19.02/tests/InferenceTestImage.cpp 2019-03-26 16:40:25.483761594 +0100 +@@ -12,13 +12,13 @@ + #include + + #define STB_IMAGE_IMPLEMENTATION +-#include ++#include + + #define STB_IMAGE_RESIZE_IMPLEMENTATION +-#include ++#include + + #define STB_IMAGE_WRITE_IMPLEMENTATION +-#include ++#include + + namespace + { diff --git a/armnn-generate-versioned-library.patch b/armnn-generate-versioned-library.patch new file mode 100644 index 0000000..d91310f --- /dev/null +++ b/armnn-generate-versioned-library.patch @@ -0,0 +1,59 @@ +--- armnn-19.02.orig/CMakeLists.txt 2019-04-11 10:31:03.241484945 +0200 ++++ armnn-19.02/CMakeLists.txt 2019-04-11 10:32:20.878025310 +0200 +@@ -82,6 +82,7 @@ if(BUILD_CAFFE_PARSER) + + target_link_libraries(armnnCaffeParser armnn) + target_link_libraries(armnnCaffeParser ${PROTOBUF_LIBRARIES}) ++ set_target_properties(armnnCaffeParser PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + + endif() + +@@ -106,6 +107,7 @@ if(BUILD_ONNX_PARSER) + + # Protobuf + target_link_libraries(armnnOnnxParser ${PROTOBUF_LIBRARIES}) ++ set_target_properties(armnnOnnxParser PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + endif() + + if(BUILD_TF_PARSER) +@@ -129,6 +131,7 @@ if(BUILD_TF_PARSER) + + # Protobuf (use the specific version tensorflow wants) + target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES}) ++ set_target_properties(armnnTfParser PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + endif() + + if(BUILD_TF_LITE_PARSER) +@@ -147,6 +150,7 @@ if(BUILD_TF_LITE_PARSER) + + target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY}) + target_link_libraries(armnnTfLiteParser armnn ${FLATBUFFERS_LIBRARY}) ++ set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + endif() + + if(BUILD_ARMNN_SERIALIZER) +@@ -178,6 +182,7 @@ if(BUILD_ARMNN_SERIALIZER) + target_include_directories(armnnSerializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnSerializer) + + target_link_libraries(armnnSerializer armnn ${FLATBUFFERS_LIBRARY}) ++ set_target_properties(armnnSerializer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + endif() + + if(BUILD_ARMNN_QUANTIZER) +@@ -208,6 +213,8 @@ if(BUILD_ARMNN_QUANTIZER) + if(Threads_FOUND AND (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android))) + target_link_libraries(ArmnnQuantizer pthread) + endif() ++ ++ set_target_properties(ArmnnQuantizer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + + endif() + +@@ -449,6 +456,7 @@ endif() + if(PROFILING_BACKEND_STREAMLINE) + target_link_libraries(armnn pthread) + endif() ++set_target_properties( armnn PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) + + if(BUILD_UNIT_TESTS) + set(unittest_sources) diff --git a/armnn.changes b/armnn.changes new file mode 100644 index 0000000..ade0c50 --- /dev/null +++ b/armnn.changes @@ -0,0 +1,46 @@ +------------------------------------------------------------------- +Fri Apr 19 10:11:29 UTC 2019 - Guillaume GARDET + +- Add compute_cl option, disabled by default since check fails as + no openCL are enabled in OBS + +------------------------------------------------------------------- +Thu Apr 11 09:35:54 UTC 2019 - Guillaume GARDET + +- Split libarmnn and libarmnnSerializer to separate packages + +------------------------------------------------------------------- +Thu Apr 11 07:38:23 UTC 2019 - Guillaume GARDET + +- Add patch to have versionned libs: + * armnn-generate-versioned-library.patch +- Package versionned libs + +------------------------------------------------------------------- +Tue Apr 9 16:18:55 UTC 2019 - Guillaume GARDET + +- Enable NEON backend on AArch64 +- Add patch to enable use of shared lib for ComputeLibrary: + * 0007-enable-use-of-arm-compute-shared-library.patch + +------------------------------------------------------------------- +Tue Mar 26 14:29:39 UTC 2019 - Guillaume GARDET + +- Update to 19.02 +- Remove upstreamed patch: + * armnn-fix_catching_polymorphic_type.patch + +------------------------------------------------------------------- +Thu Jan 17 12:51:41 UTC 2019 - Guillaume GARDET + +- Update to 18.11 +- Add patch to fix build: + * armnn-fix_catching_polymorphic_type.patch + * armnn-fix_boost.patch + * armnn-fix_stb_include.patch + +------------------------------------------------------------------- +Thu Sep 13 12:51:53 UTC 2018 - Guillaume GARDET + +- Initial version 18.08 + diff --git a/armnn.spec b/armnn.spec new file mode 100644 index 0000000..7f7a16a --- /dev/null +++ b/armnn.spec @@ -0,0 +1,308 @@ +# +# spec file for package armnn +# +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# Compute library has neon enabled for aarch64 only +%ifarch aarch64 +%bcond_without compute_neon +%else +%bcond_with compute_neon +%endif + +# Disable OpenCL from Compute library, as check fails +%bcond_with compute_cl + +# stb-devel and flatbuffers-devel are available on Leap 15.1+ +%if 0%{?suse_version} > 1500 +%bcond_without armnn_tests +%bcond_without armnn_flatbuffers +%else +%bcond_with armnn_tests +%bcond_with armnn_flatbuffers +%endif + +# Disable CAFFE for now (build broken) +%bcond_with armnn_caffe + +# Disable TensorFlow for now (build broken) +%bcond_with armnn_tf + +%define version_major 19 +%define version_minor 02 + +Name: armnn +Version: %{version_major}.%{version_minor} +Release: 0 +Summary: Arm NN SDK enables machine learning workloads on power-efficient devices +License: MIT +Group: Development/Libraries/Other +Url: https://developer.arm.com/products/processors/machine-learning/arm-nn +Source0: https://github.com/ARM-software/armnn/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch1: armnn-fix_boost.patch +Patch2: armnn-fix_stb_include.patch +# 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 +Patch3: 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 +Patch4: 0007-enable-use-of-arm-compute-shared-library.patch +%if 0%{?suse_version} < 1330 +BuildRequires: boost-devel >= 1.59 +%else +BuildRequires: libboost_filesystem-devel >= 1.59 +BuildRequires: libboost_log-devel >= 1.59 +BuildRequires: libboost_program_options-devel >= 1.59 +BuildRequires: libboost_system-devel >= 1.59 +BuildRequires: libboost_test-devel >= 1.59 +BuildRequires: libboost_thread-devel >= 1.59 +%endif +%if %{with armnn_caffe} +BuildRequires: caffe-devel +%endif +BuildRequires: cmake >= 3.0.2 +BuildRequires: ComputeLibrary-devel +BuildRequires: gcc-c++ +%if %{with armnn_flatbuffers} +BuildRequires: flatbuffers-devel +%endif +%if %{with compute_cl} +# Mesa-libOpenCl is required for tests +BuildRequires: Mesa-libOpenCL +BuildRequires: ocl-icd-devel +BuildRequires: opencl-cpp-headers +%endif +BuildRequires: protobuf-devel +BuildRequires: python-rpm-macros +%if %{with armnn_tests} +BuildRequires: stb-devel +%endif +%if %{with armnn_tf} +BuildRequires: tensorflow-devel +%endif +BuildRequires: valgrind-devel +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +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. + +%package devel +Summary: Development headers and libraries for armnn +Group: Development/Libraries/C and C++ +Requires: %{name} = %{version} +Requires: lib%{name}%{version_major} = %{version} +%if %{with armnn_flatbuffers} +Requires: libarmnnSerializer%{version_major} = %{version} +%endif + +%description devel +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 development libraries and headers for armnn. + +%package -n lib%{name}%{version_major} +Summary: lib%{name} from armnn +Group: Development/Libraries/C and C++ + +%description -n lib%{name}%{version_major} +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 libarmnn library from armnn. + +%if %{with armnn_flatbuffers} +%package -n libarmnnSerializer%{version_major} +Summary: libarmnnSerializer from armnn +Group: Development/Libraries/C and C++ + +%description -n libarmnnSerializer%{version_major} +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 libarmnnSerializer library from armnn. + +%endif + +%prep +%setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +# Boost fixes for dynamic linking +sed -i 's/add_definitions("-DBOOST_ALL_NO_LIB")/add_definitions("-DBOOST_ALL_DYN_LINK")/' ./cmake/GlobalConfig.cmake +sed -i 's/set(Boost_USE_STATIC_LIBS ON)/set(Boost_USE_STATIC_LIBS OFF)/' ./cmake/GlobalConfig.cmake +sed -i 's/find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem log program_options)/find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem log thread program_options)/' ./cmake/GlobalConfig.cmake +# Build fix +sed -i 's/-Wsign-conversion//' ./cmake/GlobalConfig.cmake + +%build +%cmake \ + -DGENERIC_LIB_VERSION=%{version} \ + -DGENERIC_LIB_SOVERSION=%{version_major} \ +%if %{with armnn_tf} + -DCMAKE_CXX_FLAGS:STRING="%{optflags} -pthread -ltensorflow_cc -ltensorflow_framework" \ +%else + -DCMAKE_CXX_FLAGS:STRING="%{optflags} -pthread" \ +%endif + -DBOOST_LIBRARYDIR=%{_libdir} \ +%if %{with armnn_caffe} + -DBUILD_CAFFE_PARSER=ON \ +%else + -DBUILD_CAFFE_PARSER=OFF \ +%endif + -DCAFFE_GENERATED_SOURCES=%{_includedir}/ \ + -DBUILD_ONNX_PARSER=OFF \ +%if %{with armnn_flatbuffers} + -DBUILD_ARMNN_SERIALIZER=ON \ + -DFLATC_DIR=%{_bindir} \ + -DFLATBUFFERS_INCLUDE_PATH=%{_includedir} \ + -DBUILD_ARMNN_QUANTIZER=ON \ +%else + -DBUILD_ARMNN_SERIALIZER=OFF \ + -DBUILD_ARMNN_QUANTIZER=OFF \ +%endif +%if %{with armnn_tf} + -DBUILD_TF_PARSER=ON \ + -DTF_GENERATED_SOURCES=%{python3_sitelib}/tensorflow/include/ \ +%else + -DBUILD_TF_PARSER=OFF \ +%endif +%if %{with compute_neon} || %{with compute_cl} + -DARMCOMPUTE_INCLUDE=%{_includedir} \ + -DHALF_INCLUDE=%{_includedir}/half \ + -DARMCOMPUTE_BUILD_DIR=%{_libdir} \ + -DARMCOMPUTE_ROOT=/usr \ +%endif +%if %{with compute_neon} + -DARMCOMPUTENEON=ON \ +%else + -DARMCOMPUTENEON=OFF \ +%endif +%if %{with compute_cl} + -DARMCOMPUTECL=ON \ + -DOPENCL_INCLUDE=%{_includedir} \ +%else + -DARMCOMPUTECL=OFF \ +%endif + -DTHIRD_PARTY_INCLUDE_DIRS=%{_includedir} \ +%if %{with armnn_flatbuffers} + -DBUILD_SAMPLE_APP=ON \ +%else + -DBUILD_SAMPLE_APP=OFF \ +%endif +%if %{with armnn_tests} + -DBUILD_UNIT_TESTS=ON \ + -DBUILD_TESTS=ON +%else + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_TESTS=OFF +%endif +%if %{suse_version} > 1500 +%cmake_build +%else +%make_jobs +%endif +%if %{with armnn_tests} +pushd tests/ +%if %{suse_version} > 1500 +%cmake_build +%else +%make_jobs +%endif +popd +%endif + +%install +%cmake_install +%if %{with armnn_tests} +# Install tests manually +install -d %{buildroot}%{_bindir} +CP_ARGS="-Prf --preserve=mode,timestamps --no-preserve=ownership" \ +find ./build/tests -maxdepth 1 -type f -executable -exec cp $CP_ARGS {} %{buildroot}%{_bindir} \; +%endif +%if %{with armnn_flatbuffers} +# Install Sample app +cp $CP_ARGS ./build/samples/SimpleSample %{buildroot}%{_bindir} +%endif + +%if %{with armnn_tests} +%check +# Run tests +LD_LIBRARY_PATH="$(pwd)/build/" \ +./build/UnitTests +%endif + +%post -n lib%{name}%{version_major} -p /sbin/ldconfig +%postun -n lib%{name}%{version_major} -p /sbin/ldconfig + +%if %{with armnn_flatbuffers} +%post -n libarmnnSerializer%{version_major} -p /sbin/ldconfig +%postun -n libarmnnSerializer%{version_major} -p /sbin/ldconfig +%endif + +%files +%defattr(-,root,root) +%doc README.md +%license LICENSE +%if %{with armnn_tests} +%{_bindir}/ExecuteNetwork +%endif +%if %{with armnn_flatbuffers} +%{_bindir}/SimpleSample +%endif + +%files -n lib%{name}%{version_major} +/usr/lib/lib%{name}.so.* + +%if %{with armnn_flatbuffers} +%files -n libarmnnSerializer%{version_major} +/usr/lib/libarmnnSerializer.so.* +%endif + +%files devel +%defattr(-,root,root) +%dir %{_includedir}/armnn/ +%{_includedir}/armnn/*.hpp +%dir %{_includedir}/armnnCaffeParser/ +%{_includedir}/armnnCaffeParser/ICaffeParser.hpp +%dir %{_includedir}/armnnOnnxParser/ +%{_includedir}/armnnOnnxParser/IOnnxParser.hpp +%dir %{_includedir}/armnnTfLiteParser/ +%{_includedir}/armnnTfLiteParser/ITfLiteParser.hpp +%dir %{_includedir}/armnnTfParser/ +%{_includedir}/armnnTfParser/ITfParser.hpp +%dir %{_includedir}/armnnDeserializer/ +%{_includedir}/armnnDeserializer/IDeserializer.hpp +%dir %{_includedir}/armnnSerializer/ +%{_includedir}/armnnSerializer/ISerializer.hpp +/usr/lib/libarmnn.so +%if %{with armnn_flatbuffers} +/usr/lib/libarmnnSerializer.so +%endif + +%changelog