# Tests by default. No tests: rpm -ba --define 'dotests 0' *.spec %{!?dotests: %define dotests 0} %global __tar /opt/freeware/bin/tar %global patchbin /usr/opt/rpm/bin/patch %global name onnxruntime %global version 1.14.1 %global release 1 %global buildtype RelWithDebInfo #python related configs %global py_major 3.9 %global py_minor 16 %global python_major python%{py_major} %global python3_sitearch %(%{python_major} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(0))") %global python3_sitearch64 %(%{python_major} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") Summary: ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator. Name: %{name} Version: %{version} Release: %{release}_beta License: MIT Group: Development/Libraries URL: https://github.com/microsoft/onnxruntime Source0: https://github.com/microsoft/onnxruntime/archive/refs/tags/v%{version}.tar.gz Source100: onnx-helper.patch Source101: flatbuffers-strtol.patch Source102: re2-disable-thread.patch Source103: googletest-CMakeList.patch Patch1: 0001-merged-changes-to-1.14-release.patch Patch2: 0002-merge-changes-from-tvkaibranch4-to-rel-1.14.1.patch Patch3: 0003-merged-changes-to-1.14-release.patch Patch4: 0004-merge-fixed.patch Patch5: 0005-onnxruntime_customopregistration_test-segfault-fix-a.patch Patch6: 0006-AIX-support-for-GatherToSplitFusion-ApplyImpl.patch Patch7: 0007-testcase-fixes.patch Patch8: onnxruntime_1.14.1_eigen_version.patch Patch9: onnxruntime_1.14.1_onnxruntime_cmake.patch Patch10: onnxruntime-1.14.1_python_setup.patch Patch11: onnxruntime-1.14.1_python_cmake.patch BuildRequires: gcc >= 10 BuildRequires: gcc-c++ >= 10 BuildRequires: cmake >= 3.24 BuildRequires: zlib-devel >= 1.2.13 Requires: libstdc++ >= 10 Requires: libgcc >= 10 Requires: zlib >= 1.2.13 Requires: onnx-python3 >= 1.13.0 Requires: libiconv >= 1.17 %description ONNX Runtime is a cross-platform inference and training machine-learning accelerator. ONNX Runtime inference can enable faster customer experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with different hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. This package internally uses some of the pacakge listed in https://github.com/microsoft/onnxruntime/blob/rel-%{version}/cmake/deps.txt. Used package list: date,flatbuffers,google_nsync,googletest,gsl,boost,nlohmann_json,onnx,protobuf,pybind11,re2,safeint,eigen %package devel Summary: Header files, libraries and development documentation for %{name} Group: Development/Libraries/C and C++ Requires: libstdc++ >= 10 Requires: libgcc >= 10 Requires: zlib >= 1.2.13 Requires: onnx-python3 >= 1.13.0 Requires: libiconv >= 1.17 Requires: %{name} >= %{version} %description devel This package contains the Header files, libraries and development documentation for %{name}. %package python3 Summary: Python 3 bindings for %{name} Group: Development/Libraries/Python BuildRequires: %{python_major}-devel >= %{py_major}.%{py_minor} BuildRequires: %{python_major}-setuptools >= 65.2.0 BuildRequires: %{python_major}-packaging >= 19.2 Requires: %{python_major} >= %{py_major}.%{py_minor} Requires: %{python_major}-six >= 1.13.0 Requires: libstdc++ >= 10 Requires: libgcc >= 10 Requires: zlib >= 1.2.13 Requires: onnx-python3 >= 1.13.0 Requires: libiconv >= 1.17 Requires: %{name} >= %{version} %description python3 This package contains the Python 3 bindings for %{name}. %prep %setup -n onnxruntime-%{version} %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 %patch6 -p1 %patch7 -p1 %patch8 -p1 %patch9 -p1 %patch10 -p1 %patch11 -p1 %build #env exports export OBJECT_MODE=64 export CC="/opt/freeware/bin/gcc -pthread -maix64 " export CXX="/opt/freeware/bin/g++ -pthread -maix64 " export CPPFLAGS="-I/opt/freeware/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/pybind11_project-src/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/gsl-src/include/" export CFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" export CXXFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" export LDFLAGS="-L/opt/freeware/lib/pthread -L/opt/freeware/lib64 -L/opt/freeware/lib -lpthread -l%{python_major}" #Build process includes three stages. #1. First run build.sh which will download the required Open Source Software ./build.sh \ --config %{buildtype}\ --build_shared_lib \ --skip_submodule_sync \ --enable_pybind \ --skip_tests \ --cmake_extra_defines onnxruntime_DISABLE_ABSEIL=ON \ --cmake_extra_defines CMAKE_INSTALL_PREFIX=%{_prefix} || true #2. Apply the patches applicable to OSS used internally by onnxruntime. %{patchbin} --no-backup-if-mismatch -p1 --fuzz=0 < %{SOURCE100} %{patchbin} --no-backup-if-mismatch -p1 --fuzz=0 < %{SOURCE101} %{patchbin} --no-backup-if-mismatch -p1 --fuzz=0 < %{SOURCE102} %{patchbin} --no-backup-if-mismatch -p1 --fuzz=0 < %{SOURCE103} #3. Cleanup and Re-run build.sh rm -r ${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/CMakeFiles rm -r ${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/CMakeCache.txt ./build.sh \ --config %{buildtype}\ --build_shared_lib \ --skip_submodule_sync \ --enable_pybind \ --skip_tests \ --cmake_extra_defines onnxruntime_DISABLE_ABSEIL=ON \ --cmake_extra_defines CMAKE_INSTALL_PREFIX=%{_prefix} #python package building cd ${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype} %{python_major} ${RPM_BUILD_DIR}/%{name}-%{version}/setup.py build %install #env exports export OBJECT_MODE=64 export CC="/opt/freeware/bin/gcc -pthread -maix64 " export CXX="/opt/freeware/bin/g++ -pthread -maix64 " export CPPFLAGS="-I/opt/freeware/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/pybind11_project-src/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/gsl-src/include/" export CFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" export CXXFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" export LDFLAGS="-L/opt/freeware/lib/pthread -L/opt/freeware/lib64 -L/opt/freeware/lib -lpthread -l%{python_major}" cd ${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype} make DESTDIR=$RPM_BUILD_ROOT install prefix=%{_prefix} cp libonnxruntime_providers_shared.so $RPM_BUILD_ROOT/%{_libdir}/libonnxruntime_providers_shared.so %{python_major} ${RPM_BUILD_DIR}/%{name}-%{version}/setup.py install \ --prefix=%{_prefix} \ --install-data=$RPM_BUILD_ROOT \ --root $RPM_BUILD_ROOT \ --record=INSTALLED_FILES %check #export OBJECT_MODE=64 #export CC="/opt/freeware/bin/gcc -pthread -maix64 " #export CXX="/opt/freeware/bin/g++ -pthread -maix64 " #export CPPFLAGS="-I/opt/freeware/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/pybind11_project-src/include -I${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/gsl-src/include/" #export CFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" #export CXXFLAGS="${CPPFLAGS} -maltivec -mvsx -Wl,-bbigtoc -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wl,-berok" #export LDFLAGS="-L/opt/freeware/lib/pthread -L/opt/freeware/lib64 -L/opt/freeware/lib -lpthread -l%{python_major}" #export LIBPATH=${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype} #export PYTHONPATH=${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype}/_deps/onnx-build:${RPM_BUILD_DIR}/%{name}-%{version}/build/Linux/%{buildtype} #./build.sh \ # --config %{buildtype}\ # --build_shared_lib \ # --skip_submodule_sync \ # --enable_pybind \ # --cmake_extra_defines onnxruntime_DISABLE_ABSEIL=ON \ # --cmake_extra_defines CMAKE_INSTALL_PREFIX=%{_prefix} %files %defattr(-, root, system,-) %doc ThirdPartyNotices.txt README.md VERSION_NUMBER LICENSE %{_bindir}/onnx_test_runner %{_libdir}/libonnxruntime.a %{_libdir}/libonnxruntime_providers_shared.so %files devel %defattr(-, root, system,-) %dir %{_includedir}/onnxruntime/ %{_includedir}/onnxruntime/* %{_libdir}/pkgconfig/libonnxruntime.pc %doc docs/* %files python3 %defattr(-, root, system,-) %doc ThirdPartyNotices.txt README.md VERSION_NUMBER LICENSE %{_bindir}/onnxruntime_test %{python3_sitearch64}/* %clean #[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %changelog * Tue May 9 2023 Ranjit Ranjan 1.14.1-1 - Port on AIX