Skip to content

Commit

Permalink
Merge pull request #5743 from cms-sw/update_onnxruntime_ppc
Browse files Browse the repository at this point in the history
[ONNX runtime] Update for powerpc
  • Loading branch information
cmsbuild authored Apr 27, 2020
2 parents 01700b9 + ae3d561 commit ade07ff
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 26 deletions.
2 changes: 0 additions & 2 deletions cmssw-tool-conf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ Requires: valgrind-toolfile
Requires: cmsswdata-toolfile
Requires: zstd-toolfile
Requires: hls-toolfile
%ifnarch ppc64le
Requires: onnxruntime-toolfile
%endif

Requires: hdf5-toolfile
Requires: rivet-toolfile
Expand Down
13 changes: 13 additions & 0 deletions eigen-altivec-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h
index 9464264..eda73ec 100755
--- a/Eigen/src/Core/arch/AltiVec/PacketMath.h
+++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h
@@ -452,7 +452,7 @@ template<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, con
template<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, vec_nor(b, b)); }

template<> EIGEN_STRONG_INLINE Packet4f pselect(const Packet4f& mask, const Packet4f& a, const Packet4f& b) {
- return vec_sel(b, a, mask);
+ return vec_sel(b, a, reinterpret_cast<Packet4ui>(mask));
}

template<> EIGEN_STRONG_INLINE Packet4f pround<Packet4f>(const Packet4f& a) { return vec_round(a); }
2 changes: 2 additions & 0 deletions eigen.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
%define source_prefix eigen-git-mirror-%{tag}
Source: %{source0}
BuildRequires: cmake
Patch0: eigen-altivec-fix

%prep
%setup -n %{source_prefix}
%patch0 -p1

%build
mkdir build
Expand Down
17 changes: 6 additions & 11 deletions onnxruntime.spec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### RPM external onnxruntime 1.0.0
### RPM external onnxruntime 1.2.0
## INITENV +PATH PYTHON3PATH %{i}/${PYTHON3_LIB_SITE_PACKAGES}
%define tag 0f048da7774428d5fb2c4c808fc5820809ab24b8
%define branch cms/v1.0.0_pb380
%define tag 8679719d81d0d77762d642d00717b189990b4a88
%define branch cms/v1.2.0_plus_ppc_update_pb31130
%define github_user cms-externals
Source: git+https://github.com/%{github_user}/%{n}.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz

BuildRequires: cmake ninja
Requires: protobuf py3-numpy py2-onnx zlib libpng
Requires: protobuf py3-numpy py2-wheel py2-onnx zlib libpng py2-pybind11

%prep
%setup -n %{n}-%{realversion}
Expand All @@ -19,16 +19,12 @@ cmake ../%{n}-%{realversion}/cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="%{i}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-Donnxruntime_BUILD_UNIT_TESTS=ON \
-Donnxruntime_ENABLE_PYTHON=ON \
-Donnxruntime_BUILD_SHARED_LIB=ON \
-Donnxruntime_USE_CUDA=OFF \
-Donnxruntime_USE_NSYNC=OFF \
-Donnxruntime_BUILD_CSHARP=OFF \
-Donnxruntime_USE_AUTOML=OFF \
-Donnxruntime_USE_EIGEN_FOR_BLAS=ON \
-Donnxruntime_USE_OPENBLAS=OFF \
-Donnxruntime_USE_MKLDNN=OFF \
-Donnxruntime_USE_MKLML=OFF \
-Donnxruntime_USE_NGRAPH=OFF \
-Donnxruntime_USE_OPENMP=OFF \
Expand All @@ -37,14 +33,13 @@ cmake ../%{n}-%{realversion}/cmake -GNinja \
-Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF \
-Donnxruntime_USE_BRAINSLICE=OFF \
-Donnxruntime_USE_NUPHAR=OFF \
-Donnxruntime_USE_EIGEN_THREADPOOL=OFF \
-Donnxruntime_USE_TENSORRT=OFF \
-Donnxruntime_CROSS_COMPILING=OFF \
-Donnxruntime_USE_FULL_PROTOBUF=ON \
-Donnxruntime_DISABLE_CONTRIB_OPS=OFF \
-Donnxruntime_USE_PREINSTALLED_PROTOBUF=ON \
-Dprotobuf_INSTALL_PATH=${PROTOBUF_ROOT} \
-DCMAKE_PREFIX_PATH="${ZLIB_ROOT};${LIBPNG_ROOT}"
-Donnxruntime_PREFER_SYSTEM_LIB=ON \
-DCMAKE_PREFIX_PATH="${ZLIB_ROOT};${LIBPNG_ROOT};${PROTOBUF_ROOT};${PY2_PYBIND11_ROOT}"

ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN)
python3 ../%{n}-%{realversion}/setup.py build
Expand Down
5 changes: 3 additions & 2 deletions pip/onnx.file
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Requires: cmake py2-numpy protobuf py2-protobuf py2-six py2-typing_extensions
Requires: py3-numpy py2-pytest-runner
Requires: cmake py2-numpy protobuf py2-protobuf py2-six py2-typing_extensions py3-numpy py2-pytest-runner
Patch0: py2-onnx

%define PipPreBuild export ONNX_ML=1
%define RelocatePython %{i}/bin/*
31 changes: 20 additions & 11 deletions protobuf.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### RPM external protobuf 3.8.0
### RPM external protobuf 3.11.3
## INITENV SETV PROTOBUF_SOURCE %{source0}
## INITENV SETV PROTOBUF_STRIP_PREFIX %{source_prefix}
#============= IMPORTANT NOTE ========================#
Expand All @@ -17,22 +17,31 @@

Source: %{source0}
Requires: zlib
BuildRequires: autotools
BuildRequires: cmake ninja

%prep
%setup -n %{source_prefix}

%build
./autogen.sh
rm -rf ../build
mkdir ../build
cd ../build

./configure --prefix %{i} \
--disable-static \
--disable-dependency-tracking \
CXXFLAGS="-I${ZLIB_ROOT}/include" \
CFLAGS="-I${ZLIB_ROOT}/include" \
LDFLAGS="-L${ZLIB_ROOT}/lib"
make %{makeprocesses}
cmake ../%{n}-%{realversion}/cmake \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="%{i}" \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS="-I${ZLIB_ROOT}/include" \
-DCMAKE_C_FLAGS="-I${ZLIB_ROOT}/include" \
-DCMAKE_SHARED_LINKER_FLAGS="-L${ZLIB_ROOT}/lib" \
-DCMAKE_PREFIX_PATH="${ZLIB_ROOT}"

ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN)

%install
make install

cd ../build
ninja -v %{makeprocesses} -l $(getconf _NPROCESSORS_ONLN) install
rm -rf %{i}/lib/pkgconfig
13 changes: 13 additions & 0 deletions py2-onnx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8351a52..613ea76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,7 +226,7 @@ function(RELATIVE_PROTOBUF_GENERATE_CPP NAME SRCS HDRS ROOT_DIR DEPEND)
${ONNX_DLLEXPORT_STR}${CMAKE_CURRENT_BINARY_DIR})
if(BUILD_ONNX_PYTHON)
list(APPEND PROTOC_ARGS --python_out
- ${ONNX_DLLEXPORT_STR}${CMAKE_CURRENT_BINARY_DIR})
+ ${CMAKE_CURRENT_BINARY_DIR})
if(ONNX_GEN_PB_TYPE_STUBS)
# Haven't figured out how to generate mypy stubs on Windows yet
if(NOT WIN32)

0 comments on commit ade07ff

Please sign in to comment.