2019-04-23 15:38:58 +02:00
#
# 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/
#
2019-09-05 15:03:11 +02:00
# Disable LTO until lto link is fixed - https://github.com/ARM-software/armnn/issues/251
%define _lto_cflags %{nil}
2019-04-23 15:38:58 +02:00
# 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
2019-06-05 18:12:07 +02:00
# stb-devel is available on Leap 15.1+
%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150000 && 0%{?is_opensuse}
2019-04-23 15:38:58 +02:00
%bcond_without armnn_tests
%else
%bcond_with armnn_tests
2019-06-05 18:12:07 +02:00
%endif
# flatbuffers-devel is available on TW only
%if 0%{?suse_version} > 1500
%bcond_without armnn_flatbuffers
%else
2019-04-23 15:38:58 +02:00
%bcond_with armnn_flatbuffers
%endif
2019-05-28 16:53:17 +02:00
# Enable CAFFE
%bcond_without armnn_caffe
2019-04-23 15:38:58 +02:00
2019-09-05 15:03:11 +02:00
# Disable TensorFlow as on 15.1+ only x86_64 succeed and on TW we have incompatibility with protobuf (3.8.0 in TW for Caffe and Tensorflow uses 3.6.1)
2019-04-23 15:38:58 +02:00
%bcond_with armnn_tf
%define version_major 19
2019-09-05 15:03:11 +02:00
%define version_minor 08
2019-04-23 15:38:58 +02:00
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
# 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
2019-09-05 15:03:11 +02:00
Patch2 : armnn-generate-versioned-library.patch
2019-04-23 15:38:58 +02:00
# 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
2019-09-05 15:03:11 +02:00
Patch3 : 0007-enable-use-of-arm-compute-shared-library.patch
# https://github.com/ARM-software/armnn/issues/207
# FIXME: remove this patch once *.pb.cc files are packaged properly in tensorflow-devel
Patch100 : armnn-fix_tensorflow_link.patch
2019-04-23 15:38:58 +02:00
%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
2019-09-05 15:03:11 +02:00
BuildRequires : ComputeLibrary-devel >= 19.08
2019-04-23 15:38:58 +02:00
BuildRequires : gcc-c++
%if %{with armnn_flatbuffers}
BuildRequires : flatbuffers-devel
2019-06-05 18:12:07 +02:00
BuildRequires : tensorflow-lite-devel
2019-04-23 15:38:58 +02:00
%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
2019-05-28 16:53:17 +02:00
%if %{with armnn_caffe}
Requires : libarmnnCaffeParser%{version_major} = %{version}
%endif
2019-04-23 15:38:58 +02:00
%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.
2019-06-05 18:12:07 +02:00
%package -n libarmnnTfLiteParser%{version_major}
Summary : libarmnnTfLiteParser from armnn
Group : Development/Libraries/C and C++
%description -n libarmnnTfLiteParser%{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 libarmnnTfLiteParser library from armnn.
2019-05-28 16:53:17 +02:00
%endif
2019-09-05 15:03:11 +02:00
%if %{with armnn_tf}
%package -n libarmnnTfParser%{version_major}
Summary : libarmnnTfParser from armnn
Group : Development/Libraries/C and C++
%description -n libarmnnTfParser%{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 libarmnnTfParser library from armnn.
%endif
2019-05-28 16:53:17 +02:00
%if %{with armnn_caffe}
%package -n libarmnnCaffeParser%{version_major}
Summary : libarmnnCaffeParser from armnn
Group : Development/Libraries/C and C++
%description -n libarmnnCaffeParser%{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.
2019-04-23 15:38:58 +02:00
2019-05-28 16:53:17 +02:00
This package contains the libarmnnCaffeParser library from armnn.
2019-04-23 15:38:58 +02:00
%endif
%prep
%setup -q
%patch1 -p1
2019-09-05 15:03:11 +02:00
%patch2 -p1
2019-04-23 15:38:58 +02:00
%patch3 -p1
2019-09-05 15:03:11 +02:00
%patch100 -p1
2019-04-23 15:38:58 +02:00
# 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} \
-DCMAKE_CXX_FLAGS:STRING=" %{optflags} - p t h r e a d " \
-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 \
2019-06-05 18:12:07 +02:00
-DBUILD_TF_LITE_PARSER=ON \
-DTF_LITE_SCHEMA_INCLUDE_PATH=%{_includedir} /tensorflow/lite/schema/ \
2019-04-23 15:38:58 +02:00
%else
-DBUILD_ARMNN_SERIALIZER=OFF \
-DBUILD_ARMNN_QUANTIZER=OFF \
2019-06-05 18:12:07 +02:00
-DBUILD_TF_LITE_PARSER=OFF \
2019-04-23 15:38:58 +02:00
%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=" - P r f - - p r e s e r v e = m o d e , t i m e s t a m p s - - n o - p r e s e r v e = o w n e r s h i p " \
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
2019-09-05 15:03:11 +02:00
%if %{with armnn_tests}
2019-04-23 15:38:58 +02:00
%check
# Run tests
LD_LIBRARY_PATH=" $ ( p w d ) / b u i l d / " \
./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
2019-06-05 18:12:07 +02:00
%post -n libarmnnTfLiteParser%{version_major} -p /sbin/ldconfig
%postun -n libarmnnTfLiteParser%{version_major} -p /sbin/ldconfig
2019-04-23 15:38:58 +02:00
%endif
2019-09-05 15:03:11 +02:00
%if %{with armnn_tf}
%post -n libarmnnTfParser%{version_major} -p /sbin/ldconfig
%postun -n libarmnnTfParser%{version_major} -p /sbin/ldconfig
%endif
2019-05-29 10:13:46 +02:00
%if %{with armnn_caffe}
%post -n libarmnnCaffeParser%{version_major} -p /sbin/ldconfig
%postun -n libarmnnCaffeParser%{version_major} -p /sbin/ldconfig
%endif
2019-06-05 18:12:07 +02:00
2019-04-23 15:38:58 +02:00
%files
%defattr (-,root,root)
%doc README.md
%license LICENSE
2019-06-05 18:12:07 +02:00
%if %{with armnn_flatbuffers}
%{_bindir} /TfLite*-Armnn
%{_bindir} /Image*Generator
%endif
2019-09-05 15:03:11 +02:00
%if %{with armnn_tf}
%{_bindir} /Tf*-Armnn
%endif
2019-04-23 15:38:58 +02:00
%if %{with armnn_tests}
%{_bindir} /ExecuteNetwork
2019-05-28 16:53:17 +02:00
%if %{with armnn_caffe}
%{_bindir} /Caffe*-Armnn
%{_bindir} /MultipleNetworksCifar10
%endif
2019-04-23 15:38:58 +02:00
%endif
%if %{with armnn_flatbuffers}
%{_bindir} /SimpleSample
%endif
%files -n lib%{name}%{version_major}
2019-09-05 15:03:11 +02:00
%{_libdir} /lib%{name} .so.*
2019-04-23 15:38:58 +02:00
%if %{with armnn_flatbuffers}
%files -n libarmnnSerializer%{version_major}
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnnSerializer.so.*
2019-06-05 18:12:07 +02:00
%files -n libarmnnTfLiteParser%{version_major}
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnnTfLiteParser.so.*
%endif
%if %{with armnn_tf}
%files -n libarmnnTfParser%{version_major}
%{_libdir} /libarmnnTfParser.so.*
2019-04-23 15:38:58 +02:00
%endif
2019-05-28 16:53:17 +02:00
%if %{with armnn_caffe}
%files -n libarmnnCaffeParser%{version_major}
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnnCaffeParser.so.*
2019-05-28 16:53:17 +02:00
%endif
2019-04-23 15:38:58 +02:00
%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
2019-06-05 18:12:07 +02:00
%dir %{_includedir} /armnnQuantizer
%{_includedir} /armnnQuantizer/INetworkQuantizer.hpp
2019-04-23 15:38:58 +02:00
%dir %{_includedir} /armnnSerializer/
%{_includedir} /armnnSerializer/ISerializer.hpp
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnn.so
2019-04-23 15:38:58 +02:00
%if %{with armnn_flatbuffers}
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnnSerializer.so
%{_libdir} /libarmnnTfLiteParser.so
%endif
%if %{with armnn_tf}
%{_libdir} /libarmnnTfParser.so
2019-04-23 15:38:58 +02:00
%endif
2019-05-28 16:53:17 +02:00
%if %{with armnn_caffe}
2019-09-05 15:03:11 +02:00
%{_libdir} /libarmnnCaffeParser.so
2019-05-28 16:53:17 +02:00
%endif
2019-04-23 15:38:58 +02:00
%changelog