commit:     ee206a9be4541beb3e60a8f3cbccb00ab0ac9e46
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 14 20:07:11 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 20:13:25 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ee206a9b

sci-libs/caffe2: fix xnnpack use, add deps and other

Closes: https://bugs.gentoo.org/943501
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 ...{caffe2-2.5.1.ebuild => caffe2-2.5.1-r1.ebuild} | 42 +++++++++++++++-------
 .../caffe2/files/caffe2-2.5.1-cpp-httplib.patch    | 13 -------
 2 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/sci-libs/caffe2/caffe2-2.5.1.ebuild 
b/sci-libs/caffe2/caffe2-2.5.1-r1.ebuild
similarity index 90%
rename from sci-libs/caffe2/caffe2-2.5.1.ebuild
rename to sci-libs/caffe2/caffe2-2.5.1-r1.ebuild
index 81e3a916f3b3..393000c79567 100644
--- a/sci-libs/caffe2/caffe2-2.5.1.ebuild
+++ b/sci-libs/caffe2/caffe2-2.5.1-r1.ebuild
@@ -38,9 +38,10 @@ RDEPEND="
        dev-cpp/abseil-cpp:=
        dev-cpp/gflags:=
        >=dev-cpp/glog-0.5.0
+       dev-cpp/nlohmann_json
+       dev-cpp/opentelemetry-cpp
        dev-libs/cpuinfo
        dev-libs/libfmt
-       dev-cpp/opentelemetry-cpp
        dev-libs/protobuf:=
        dev-libs/pthreadpool
        dev-libs/sleef[cpu_flags_x86_avx512f(+),cpu_flags_x86_avx(+)]
@@ -95,6 +96,7 @@ RDEPEND="
        mkl? ( sci-libs/mkl )
        openblas? ( sci-libs/openblas )
 "
+
 DEPEND="
        ${RDEPEND}
        cuda? ( >=dev-libs/cutlass-3.4.1 )
@@ -118,7 +120,7 @@ PATCHES=(
        "${FILESDIR}"/${P}-fix-functorch-install.patch
        "${FILESDIR}"/${P}-cudnn_include_fix.patch
        "${FILESDIR}"/${P}-gentoo.patch
-       "${FILESDIR}"/${P}-cpp-httplib.patch
+       "${FILESDIR}"/${PN}-2.4.0-cpp-httplib.patch
        "${FILESDIR}"/${P}-glog-0.6.0.patch
 )
 
@@ -132,6 +134,7 @@ src_prepare() {
                cmake/Dependencies.cmake \
                torch/CMakeLists.txt \
                || die
+
        # Drop third_party from CMake tree
        sed -i \
                -e '/add_subdirectory.*third_party/d' \
@@ -140,10 +143,12 @@ src_prepare() {
                cmake/ProtoBuf.cmake \
                aten/src/ATen/CMakeLists.txt \
                || die
+
        cmake_src_prepare
        pushd torch/csrc/jit/serialization || die
        flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
        popd
+
        # prefixify the hardcoded paths, after all patches are applied
        hprefixify \
                aten/CMakeLists.txt \
@@ -186,6 +191,7 @@ src_configure() {
        fi
 
        local mycmakeargs=(
+               -DBUILD_CUSTOM_PROTOBUF=OFF
                -DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
                -DPython_EXECUTABLE="${PYTHON}"
                -DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
@@ -213,7 +219,18 @@ src_configure() {
                -DUSE_PYTORCH_QNNPACK=$(usex qnnpack)
                -DUSE_PYTORCH_METAL=OFF
                -DUSE_ROCM=$(usex rocm)
-               -DUSE_SYSTEM_LIBS=ON
+               -DUSE_SYSTEM_CPUINFO=ON
+               -DUSE_SYSTEM_EIGEN_INSTALL=ON
+               -DUSE_SYSTEM_FP16=ON
+               -DUSE_SYSTEM_FXDIV=ON
+               -DUSE_SYSTEM_GLOO=ON
+               -DUSE_SYSTEM_ONNX=ON
+               -DUSE_SYSTEM_PSIMD=ON
+               -DUSE_SYSTEM_PSIMD=ON
+               -DUSE_SYSTEM_PTHREADPOOL=ON
+               -DUSE_SYSTEM_PYBIND11=ON
+               -DUSE_SYSTEM_SLEEF=ON
+               -DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
                -DUSE_TENSORPIPE=$(usex distributed)
                -DUSE_UCC=OFF
                -DUSE_VALGRIND=OFF
@@ -286,20 +303,19 @@ src_install() {
        cp torch/version.py python/torch/ || die
        python_domodule python/torch
 
-       dodir $(python_get_sitedir)/torch/bin
-       dodir $(python_get_sitedir)/torch/lib
-       dodir $(python_get_sitedir)/torch/include
+       mkdir "${D}"$(python_get_sitedir)/torch/bin || die
+       mkdir "${D}"$(python_get_sitedir)/torch/lib || die
+       mkdir "${D}"$(python_get_sitedir)/torch/include || die
 
        ln -s ../../../../../include/torch \
                "${D}$(python_get_sitedir)"/torch/include/torch || die # bug 
923269
 
+       mv "${D}"/usr/bin/torch_shm_manager \
+               "${D}"/$(python_get_sitedir)/torch/bin/ || die
 
-       mv "${ED}"/usr/bin/torch_shm_manager \
-               "${ED}"/$(python_get_sitedir)/torch/bin/ || die
-
-       mv "${ED}"/usr/$(get_libdir)/libtorch_global_deps.so \
-               "${ED}"/$(python_get_sitedir)/torch/lib/ || die
+       mv "${D}"/usr/$(get_libdir)/libtorch_global_deps.so \
+               "${D}"/$(python_get_sitedir)/torch/lib/ || die
 
-       mv "${ED}"/usr/lib/libc10*.so \
-               "${ED}"/usr/$(get_libdir)/ || die
+       mv "${D}"/usr/lib/libc10*.so \
+               "${D}"/usr/$(get_libdir)/ || die
 }

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-cpp-httplib.patch 
b/sci-libs/caffe2/files/caffe2-2.5.1-cpp-httplib.patch
deleted file mode 100644
index 5d684a4a4738..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.5.1-cpp-httplib.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- a/torch/lib/libshm/CMakeLists.txt  2024-09-04 06:09:51.943752841 +0200
-+++ b/torch/lib/libshm/CMakeLists.txt  2024-09-04 06:10:52.243821438 +0200
-@@ -24,6 +24,10 @@
-   CXX_STANDARD 17)
- target_link_libraries(shm PRIVATE ${TORCH_CPU_LIB})
- 
-+if (USE_DISTRIBUTED)
-+  target_link_libraries(shm PRIVATE cpp-httplib)
-+endif()
-+
- if(UNIX AND NOT APPLE)
-   include(CheckLibraryExists)
-   find_package(Threads REQUIRED)

Reply via email to