commit:     e4f62deb1b127d32fc9845d5e90d21a0c090bf53
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  1 22:22:08 2022 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sat Jul  2 11:03:44 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4f62deb

sci-libs/caffe2: add XNNPACK usage

Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 .../{caffe2-1.11.0.ebuild => caffe2-1.11.0-r1.ebuild} |  7 ++++++-
 sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch      | 19 +++++++++++++++++++
 sci-libs/caffe2/metadata.xml                          |  3 +++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/sci-libs/caffe2/caffe2-1.11.0.ebuild 
b/sci-libs/caffe2/caffe2-1.11.0-r1.ebuild
similarity index 92%
rename from sci-libs/caffe2/caffe2-1.11.0.ebuild
rename to sci-libs/caffe2/caffe2-1.11.0-r1.ebuild
index e0f6d0d772f2..137c5df60ebe 100644
--- a/sci-libs/caffe2/caffe2-1.11.0.ebuild
+++ b/sci-libs/caffe2/caffe2-1.11.0-r1.ebuild
@@ -18,6 +18,7 @@ LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
 RESTRICT="test"
+IUSE="xnnpack"
 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 RDEPEND="
@@ -29,6 +30,7 @@ RDEPEND="
        sci-libs/lapack
        sci-libs/onnx
        sci-libs/foxi
+       xnnpack? ( sci-libs/XNNPACK )
 "
 DEPEND="${RDEPEND}
        dev-libs/FP16
@@ -53,7 +55,7 @@ src_configure() {
        python_setup
        local mycmakeargs=(
                -DUSE_KINETO=OFF
-               -DUSE_XNNPACK=OFF
+               -DUSE_XNNPACK=$(usex xnnpack ON OFF)
                -DUSE_SYSTEM_SLEEF=ON
                -DUSE_BREAKPAD=OFF
                -DUSE_SYSTEM_ONNX=ON
@@ -76,6 +78,9 @@ src_configure() {
                -DTORCH_INSTALL_LIB_DIR=/usr/$(get_libdir)
                -DLIBSHM_INSTALL_LIB_SUBDIR=/usr/$(get_libdir)
                -DUSE_CCACHE=OFF
+               -DUSE_SYSTEM_PTHREADPOOL=ON
+               -DUSE_SYSTEM_XNNPACK=ON
+               -DUSE_SYSTEM_FXDIV=ON
        )
        cmake_src_configure
 }

diff --git a/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch 
b/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch
index ac74edadab35..f34216ea0970 100644
--- a/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch
+++ b/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch
@@ -91,3 +91,22 @@
  install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
          DESTINATION include
          FILES_MATCHING PATTERN "*.h")
+--- a/caffe2/CMakeLists.txt    2022-07-01 21:56:49.643490049 +0200
++++ b/caffe2/CMakeLists.txt    2022-07-01 21:57:17.091489479 +0200
+@@ -109,7 +109,7 @@
+ # Note: the folders that are being commented out have not been properly
+ # addressed yet.
+ 
+-if(NOT MSVC AND USE_XNNPACK)
++if(FALSE)
+   if(NOT TARGET fxdiv)
+     set(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
+     set(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
+@@ -967,7 +967,6 @@
+ endif()
+ 
+ if(NOT MSVC AND USE_XNNPACK)
+-  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
+ endif()
+ 
+ # ==========================================================

diff --git a/sci-libs/caffe2/metadata.xml b/sci-libs/caffe2/metadata.xml
index d12749aa5c21..bdd11115f0fe 100644
--- a/sci-libs/caffe2/metadata.xml
+++ b/sci-libs/caffe2/metadata.xml
@@ -5,6 +5,9 @@
                <email>[email protected]</email>
                <name>Tupone Alfredo</name>
        </maintainer>
+       <use>
+               <flag name="xnnpack">Use XNNPACK</flag>
+       </use>
        <upstream>
                <remote-id type="github">pytorch/pytorch</remote-id>
        </upstream>

Reply via email to