public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2023-05-06 17:29 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2023-05-06 17:29 UTC (permalink / raw
  To: gentoo-commits

commit:     d8ee6c1a21bd0be7cc254b7539f544083347c34c
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Fri May  5 20:19:16 2023 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sat May  6 17:27:39 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8ee6c1a

sci-libs/caffe2: fix fbgemm use and add gloo

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 ...e2-1.13.1-r4.ebuild => caffe2-1.13.1-r5.ebuild} | 13 +++--
 ...ffe2-2.0.0-r2.ebuild => caffe2-2.0.0-r3.ebuild} | 10 +++-
 sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch   | 61 ++++++++++++++--------
 sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch    | 61 ++++++++++++++--------
 sci-libs/caffe2/metadata.xml                       |  1 +
 5 files changed, 95 insertions(+), 51 deletions(-)

diff --git a/sci-libs/caffe2/caffe2-1.13.1-r4.ebuild b/sci-libs/caffe2/caffe2-1.13.1-r5.ebuild
similarity index 93%
rename from sci-libs/caffe2/caffe2-1.13.1-r4.ebuild
rename to sci-libs/caffe2/caffe2-1.13.1-r5.ebuild
index efb497856e53..7fc257acd3ab 100644
--- a/sci-libs/caffe2/caffe2-1.13.1-r4.ebuild
+++ b/sci-libs/caffe2/caffe2-1.13.1-r5.ebuild
@@ -17,13 +17,14 @@ SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="cuda distributed ffmpeg mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
+IUSE="cuda distributed fbgemm ffmpeg gloo mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
 RESTRICT="test"
 REQUIRED_USE="
 	${PYTHON_REQUIRED_USE}
 	ffmpeg? ( opencv )
 	mpi? ( distributed )
 	tensorpipe? ( distributed )
+	gloo? ( distributed )
 " # ?? ( cuda rocm )
 
 # CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
@@ -44,7 +45,9 @@ RDEPEND="
 		dev-libs/cudnn-frontend:0/8
 		<dev-util/nvidia-cuda-toolkit-12:=[profiler]
 	)
+	fbgemm? ( dev-libs/FBGEMM )
 	ffmpeg? ( media-video/ffmpeg:= )
+	gloo? ( sci-libs/gloo )
 	mpi? ( sys-cluster/openmpi )
 	nnpack? ( sci-libs/NNPACK )
 	numpy? ( $(python_gen_cond_dep '
@@ -84,6 +87,10 @@ PATCHES=(
 
 src_prepare() {
 	filter-lto #bug 862672
+	sed -i \
+		-e "/third_party\/gloo/d" \
+		cmake/Dependencies.cmake \
+		|| die
 	cmake_src_prepare
 	pushd torch/csrc/jit/serialization || die
 	flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
@@ -116,11 +123,11 @@ src_configure() {
 		-DUSE_DISTRIBUTED=$(usex distributed)
 		-DUSE_MPI=$(usex mpi)
 		-DUSE_FAKELOWP=OFF
-		-DUSE_FBGEMM=OFF # TODO
+		-DUSE_FBGEMM=$(usex fbgemm)
 		-DUSE_FFMPEG=$(usex ffmpeg)
 		-DUSE_GFLAGS=ON
 		-DUSE_GLOG=ON
-		-DUSE_GLOO=OFF
+		-DUSE_GLOO=$(usex gloo)
 		-DUSE_KINETO=OFF # TODO
 		-DUSE_LEVELDB=OFF
 		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma

diff --git a/sci-libs/caffe2/caffe2-2.0.0-r2.ebuild b/sci-libs/caffe2/caffe2-2.0.0-r3.ebuild
similarity index 95%
rename from sci-libs/caffe2/caffe2-2.0.0-r2.ebuild
rename to sci-libs/caffe2/caffe2-2.0.0-r3.ebuild
index 7667c7bbee17..42b8dae69229 100644
--- a/sci-libs/caffe2/caffe2-2.0.0-r2.ebuild
+++ b/sci-libs/caffe2/caffe2-2.0.0-r3.ebuild
@@ -17,13 +17,14 @@ SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="cuda distributed fbgemm ffmpeg mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
+IUSE="cuda distributed fbgemm ffmpeg gloo mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
 RESTRICT="test"
 REQUIRED_USE="
 	${PYTHON_REQUIRED_USE}
 	ffmpeg? ( opencv )
 	mpi? ( distributed )
 	tensorpipe? ( distributed )
+	gloo? ( distributed )
 " # ?? ( cuda rocm )
 
 # CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
@@ -46,6 +47,7 @@ RDEPEND="
 	)
 	fbgemm? ( dev-libs/FBGEMM )
 	ffmpeg? ( media-video/ffmpeg:= )
+	gloo? ( sci-libs/gloo )
 	mpi? ( sys-cluster/openmpi )
 	nnpack? ( sci-libs/NNPACK )
 	numpy? ( $(python_gen_cond_dep '
@@ -86,6 +88,10 @@ PATCHES=(
 
 src_prepare() {
 	filter-lto #bug 862672
+	sed -i \
+		-e "/third_party\/gloo/d" \
+		cmake/Dependencies.cmake \
+		|| die
 	cmake_src_prepare
 	pushd torch/csrc/jit/serialization || die
 	flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
@@ -123,7 +129,7 @@ src_configure() {
 		-DUSE_FFMPEG=$(usex ffmpeg)
 		-DUSE_GFLAGS=ON
 		-DUSE_GLOG=ON
-		-DUSE_GLOO=OFF
+		-DUSE_GLOO=$(usex gloo)
 		-DUSE_KINETO=OFF # TODO
 		-DUSE_LEVELDB=OFF
 		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma

diff --git a/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
index a2771e3319d8..f72d44f475fa 100644
--- a/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
+++ b/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
@@ -1,6 +1,41 @@
 --- a/cmake/Dependencies.cmake
 +++ b/cmake/Dependencies.cmake
-@@ -1557,7 +1557,6 @@
+@@ -481,7 +481,7 @@ endif()
+ list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
+ 
+ # ---[ QNNPACK
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+ 
+   if(NOT DEFINED QNNPACK_SOURCE_DIR)
+@@ -537,7 +537,7 @@ if(USE_QNNPACK)
+ endif()
+ 
+ # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
+@@ -789,7 +789,7 @@
+ endif()
+ 
+ # ---[ FBGEMM
+-if(USE_FBGEMM)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   if(NOT DEFINED FBGEMM_SOURCE_DIR)
+     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
+@@ -834,6 +834,7 @@
+ endif()
+ 
+ if(USE_FBGEMM)
++  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
+   caffe2_update_option(USE_FBGEMM ON)
+ else()
+   caffe2_update_option(USE_FBGEMM OFF)
+@@ -1557,7 +1558,6 @@
    if(NOT USE_SYSTEM_ONNX)
      add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx EXCLUDE_FROM_ALL)
    endif()
@@ -8,7 +43,7 @@
  
    add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
    if(NOT USE_SYSTEM_ONNX)
-@@ -1850,7 +1849,6 @@
+@@ -1850,7 +1850,6 @@
  #
  set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
  set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
@@ -16,7 +51,7 @@
  
  # Disable compiler feature checks for `fmt`.
  #
-@@ -1859,9 +1857,7 @@
+@@ -1859,9 +1858,7 @@
  # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
  # `fmt` is compatible with a superset of the compilers that PyTorch is, it
  # shouldn't be too bad to just disable the checks.
@@ -168,26 +203,6 @@
      if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
        set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
      endif()
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -481,7 +481,7 @@ endif()
- list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
- 
- # ---[ QNNPACK
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
- 
-   if(NOT DEFINED QNNPACK_SOURCE_DIR)
-@@ -537,7 +537,7 @@ if(USE_QNNPACK)
- endif()
- 
- # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
 --- a/torch/csrc/Exceptions.cpp	2023-02-13 12:46:54.447013004 +0100
 +++ b/torch/csrc/Exceptions.cpp	2023-02-13 12:50:18.433791791 +0100
 @@ -1,11 +1,10 @@

diff --git a/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch
index 021a06e343e4..fce7a395023e 100644
--- a/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch
+++ b/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch
@@ -1,6 +1,41 @@
 --- a/cmake/Dependencies.cmake
 +++ b/cmake/Dependencies.cmake
-@@ -1554,7 +1554,6 @@
+@@ -486,7 +486,7 @@ endif()
+ list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
+ 
+ # ---[ QNNPACK
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+ 
+   if(NOT DEFINED QNNPACK_SOURCE_DIR)
+@@ -542,7 +542,7 @@ if(USE_QNNPACK)
+ endif()
+ 
+ # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
+@@ -802,7 +802,7 @@
+ endif()
+ 
+ # ---[ FBGEMM
+-if(USE_FBGEMM)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   if(NOT DEFINED FBGEMM_SOURCE_DIR)
+     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
+@@ -847,6 +847,7 @@
+ endif()
+ 
+ if(USE_FBGEMM)
++  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
+   caffe2_update_option(USE_FBGEMM ON)
+ else()
+   caffe2_update_option(USE_FBGEMM OFF)
+@@ -1554,7 +1555,6 @@
        set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
      endif()
    endif()
@@ -8,7 +43,7 @@
  
    add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
    if(NOT USE_SYSTEM_ONNX)
-@@ -1819,7 +1818,6 @@
+@@ -1819,7 +1819,6 @@
  #
  set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
  set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
@@ -16,7 +51,7 @@
  
  # Disable compiler feature checks for `fmt`.
  #
-@@ -1828,9 +1826,7 @@
+@@ -1828,9 +1827,7 @@
  # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
  # `fmt` is compatible with a superset of the compilers that PyTorch is, it
  # shouldn't be too bad to just disable the checks.
@@ -167,23 +202,3 @@
      if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
        set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
      endif()
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -486,7 +486,7 @@ endif()
- list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
- 
- # ---[ QNNPACK
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
- 
-   if(NOT DEFINED QNNPACK_SOURCE_DIR)
-@@ -542,7 +542,7 @@ if(USE_QNNPACK)
- endif()
- 
- # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")

diff --git a/sci-libs/caffe2/metadata.xml b/sci-libs/caffe2/metadata.xml
index f58d3b5e97ab..703eedf5322a 100644
--- a/sci-libs/caffe2/metadata.xml
+++ b/sci-libs/caffe2/metadata.xml
@@ -14,6 +14,7 @@
 		<flag name="distributed">Support distributed applications</flag>
 		<flag name="fbgemm">Use FBGEMM</flag>
 		<flag name="ffmpeg">Add support for video processing operators</flag>
+		<flag name="gloo">Use sci-libs/gloo</flag>
 		<flag name="nnpack">Use NNPACK</flag>
 		<flag name="numpy">Add support for math operations through numpy</flag>
 		<flag name="opencl">Use OpenCL</flag>


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-11-14 10:00 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-11-14 10:00 UTC (permalink / raw
  To: gentoo-commits

commit:     123bc9bdc2cc52cb0d56a13d6d5f2c711e7c688f
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 14 09:53:46 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 09:56:12 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=123bc9bd

sci-libs/caffe2: add 2.5.1

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 +
 sci-libs/caffe2/caffe2-2.5.1.ebuild                | 305 +++++++++++++++++++++
 .../caffe2/files/caffe2-2.5.1-cpp-httplib.patch    |  13 +
 .../files/caffe2-2.5.1-cudnn_include_fix.patch     |  11 +
 .../files/caffe2-2.5.1-exclude-aotriton.patch      |  22 ++
 .../files/caffe2-2.5.1-fix-functorch-install.patch |   8 +
 sci-libs/caffe2/files/caffe2-2.5.1-gentoo.patch    | 127 +++++++++
 .../caffe2/files/caffe2-2.5.1-glog-0.6.0.patch     |  29 ++
 .../caffe2/files/caffe2-2.5.1-install-dirs.patch   |  11 +
 .../caffe2/files/caffe2-2.5.1-unbundle_fmt.patch   |  10 +
 .../files/caffe2-2.5.1-unbundle_kineto.patch       |  22 ++
 11 files changed, 559 insertions(+)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index 1bdb2764edd1..7f0b51661b1b 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,3 +1,4 @@
 DIST caffe2-patches-20240809.tar.gz 15242 BLAKE2B 77503c61487e7d85cca5afcab9a6e638f9833a70861845638cf1b62bc492d7b6650e6db81d53ebb2f39c6313509250d339f725f04d03ec6dd23dd0cf70843d8c SHA512 74b3b0b6671b655ecac93f7436c4ed7cb0157a83aafbf6afcc0811e11cef341cd8f638db1a111bcbb01e1a6dd4daf3a36b96d7a8ce90f04c2fa091bd6e3a142b
 DIST pytorch-2.4.0.tar.gz 115031093 BLAKE2B d206477963977011627df284efa01482fbf57e9fcb5f58f51d679c742b8e5dde6aa6affd8745ab817fcd09477d129a81e74e07be576b5d3585eaca1c735b8e01 SHA512 804d25944035f33de6591fd942fbda44d3de037717a4397d38a97474b01775d30eaf93d16dd708a832c0119050d24d73b90990fd3e3773be79d26ada25244d22
 DIST pytorch-2.4.1.tar.gz 115029469 BLAKE2B c2909ff27d527bc57cba56b780d3b8cd07a043ab045caa6c6b27857a16f9ad10aaab2116b26226b1e46ee08ffb44007965d914464418e4ae14ca48c3f3f383bb SHA512 7e9b4485e242eaf0d648765c6621d73d95e7107b766646a098175436d1ab2e2b864badd0757a3bab6b7c318233f2120bad9ac07b39bb9e357897919580c87631
+DIST pytorch-2.5.1.tar.gz 116091366 BLAKE2B 7838b17562b94ffc7d798031348689db607dd5eae2a3c35be365972e2b52a2c1b12067068d5aca5ab00cf0977d9c2c3c9ae5337d69534c864c732e6256cbeef6 SHA512 a913a466324a65fa3d79c5e9ad4d605fc7976f0134fda2f81aaa3cea29d56926604999b8a238759646d211e63b47bbb446cdffa86ca8defd8159f11e30301289

diff --git a/sci-libs/caffe2/caffe2-2.5.1.ebuild b/sci-libs/caffe2/caffe2-2.5.1.ebuild
new file mode 100644
index 000000000000..81e3a916f3b3
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-2.5.1.ebuild
@@ -0,0 +1,305 @@
+# Copyright 2022-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+ROCM_VERSION=6.1
+inherit python-single-r1 cmake cuda flag-o-matic prefix rocm toolchain-funcs
+
+MYPN=pytorch
+MYP=${MYPN}-${PV}
+
+DESCRIPTION="A deep learning framework"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
+	-> ${MYP}.tar.gz"
+
+S="${WORKDIR}"/${MYP}
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="cuda distributed fbgemm flash gloo mkl mpi nnpack +numpy onednn openblas opencl openmp qnnpack rocm xnnpack"
+RESTRICT="test"
+REQUIRED_USE="
+	${PYTHON_REQUIRED_USE}
+	mpi? ( distributed )
+	gloo? ( distributed )
+	?? ( cuda rocm )
+	rocm? (
+		|| ( ${ROCM_REQUIRED_USE} )
+		!flash
+	)
+"
+
+RDEPEND="
+	${PYTHON_DEPS}
+	dev-cpp/abseil-cpp:=
+	dev-cpp/gflags:=
+	>=dev-cpp/glog-0.5.0
+	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(+)]
+	dev-libs/sleef[cpu_flags_x86_sse3(+),cpu_flags_x86_ssse3(+)]
+	dev-libs/sleef[cpu_flags_x86_sse4_1(+),cpu_flags_x86_sse4_2(+)]
+	virtual/lapack
+	sci-libs/onnx
+	sci-libs/foxi
+	cuda? (
+		dev-libs/cudnn
+		>=dev-libs/cudnn-frontend-1.0.3:0/8
+		<dev-util/nvidia-cuda-toolkit-12.5:=[profiler]
+	)
+	fbgemm? ( >=dev-libs/FBGEMM-2023.12.01 )
+	gloo? ( sci-libs/gloo[cuda?] )
+	mpi? ( virtual/mpi )
+	nnpack? ( sci-libs/NNPACK )
+	numpy? ( $(python_gen_cond_dep '
+		dev-python/numpy[${PYTHON_USEDEP}]
+		') )
+	onednn? ( dev-libs/oneDNN )
+	opencl? ( virtual/opencl )
+	qnnpack? (
+		!sci-libs/QNNPACK
+		dev-cpp/gemmlowp
+	)
+	rocm? (
+		=dev-util/hip-6.1*
+		=dev-libs/rccl-6.1*[${ROCM_USEDEP}]
+		=sci-libs/rocThrust-6.1*[${ROCM_USEDEP}]
+		=sci-libs/rocPRIM-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipBLAS-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipFFT-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipSPARSE-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipRAND-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipCUB-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipSOLVER-6.1*[${ROCM_USEDEP}]
+		=sci-libs/miopen-6.1*[${ROCM_USEDEP}]
+		=dev-util/roctracer-6.1*[${ROCM_USEDEP}]
+
+		=sci-libs/hipBLASLt-6.1*
+		amdgpu_targets_gfx90a? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx90a] )
+		amdgpu_targets_gfx940? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx940] )
+		amdgpu_targets_gfx941? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx941] )
+		amdgpu_targets_gfx942? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx942] )
+	)
+	distributed? (
+		sci-libs/tensorpipe[cuda?]
+		dev-cpp/cpp-httplib
+	)
+	xnnpack? ( >=sci-libs/XNNPACK-2024.02.29 )
+	mkl? ( sci-libs/mkl )
+	openblas? ( sci-libs/openblas )
+"
+DEPEND="
+	${RDEPEND}
+	cuda? ( >=dev-libs/cutlass-3.4.1 )
+	onednn? ( sci-libs/ideep )
+	dev-libs/psimd
+	dev-libs/FP16
+	dev-libs/FXdiv
+	dev-libs/pocketfft
+	dev-libs/flatbuffers
+	>=sci-libs/kineto-0.4.0_p20240525
+	$(python_gen_cond_dep '
+		dev-python/pyyaml[${PYTHON_USEDEP}]
+		dev-python/pybind11[${PYTHON_USEDEP}]
+		dev-python/typing-extensions[${PYTHON_USEDEP}]
+	')
+"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-unbundle_fmt.patch
+	"${FILESDIR}"/${P}-unbundle_kineto.patch
+	"${FILESDIR}"/${P}-fix-functorch-install.patch
+	"${FILESDIR}"/${P}-cudnn_include_fix.patch
+	"${FILESDIR}"/${P}-gentoo.patch
+	"${FILESDIR}"/${P}-cpp-httplib.patch
+	"${FILESDIR}"/${P}-glog-0.6.0.patch
+)
+
+src_prepare() {
+	filter-lto #bug 862672
+
+	# Unbundle fmt
+	sed -i \
+		-e 's|::fmt-header-only||' \
+		c10/CMakeLists.txt \
+		cmake/Dependencies.cmake \
+		torch/CMakeLists.txt \
+		|| die
+	# Drop third_party from CMake tree
+	sed -i \
+		-e '/add_subdirectory.*third_party/d' \
+		CMakeLists.txt \
+		cmake/Dependencies.cmake \
+		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 \
+		caffe2/CMakeLists.txt \
+		cmake/Metal.cmake \
+		cmake/Modules/*.cmake \
+		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
+		cmake/public/LoadHIP.cmake \
+		cmake/public/cuda.cmake \
+		cmake/Dependencies.cmake \
+		torch/CMakeLists.txt \
+		CMakeLists.txt
+
+	if use rocm; then
+		sed -e "s:/opt/rocm:/usr:" \
+			-e "s:lib/cmake:$(get_libdir)/cmake:g" \
+			-e "s/HIP 1.0/HIP 1.0 REQUIRED/" \
+			-i cmake/public/LoadHIP.cmake || die
+
+		ebegin "HIPifying cuda sources"
+		${EPYTHON} tools/amd_build/build_amd.py || die
+		eend $?
+	fi
+}
+
+src_configure() {
+	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
+		ewarn "These may not be optimal for your GPU."
+		ewarn ""
+		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
+		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
+		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
+		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
+		ewarn ""
+		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
+		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
+	fi
+
+	local mycmakeargs=(
+		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
+		-DPython_EXECUTABLE="${PYTHON}"
+		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
+		-DUSE_CCACHE=OFF
+		-DUSE_CUDA=$(usex cuda)
+		-DUSE_DISTRIBUTED=$(usex distributed)
+		-DUSE_FAKELOWP=OFF
+		-DUSE_FBGEMM=$(usex fbgemm)
+		-DUSE_FLASH_ATTENTION=$(usex flash)
+		-DUSE_GFLAGS=ON
+		-DUSE_GLOG=ON
+		-DUSE_GLOO=$(usex gloo)
+		-DUSE_ITT=OFF
+		-DUSE_KINETO=OFF # TODO
+		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
+		-DUSE_MEM_EFF_ATTENTION=OFF
+		-DUSE_MKLDNN=$(usex onednn)
+		-DUSE_MPI=$(usex mpi)
+		-DUSE_NCCL=OFF
+		-DUSE_NNPACK=$(usex nnpack)
+		-DUSE_NUMA=OFF
+		-DUSE_NUMPY=$(usex numpy)
+		-DUSE_OPENCL=$(usex opencl)
+		-DUSE_OPENMP=$(usex openmp)
+		-DUSE_PYTORCH_QNNPACK=$(usex qnnpack)
+		-DUSE_PYTORCH_METAL=OFF
+		-DUSE_ROCM=$(usex rocm)
+		-DUSE_SYSTEM_LIBS=ON
+		-DUSE_TENSORPIPE=$(usex distributed)
+		-DUSE_UCC=OFF
+		-DUSE_VALGRIND=OFF
+		-DUSE_XNNPACK=$(usex xnnpack)
+		-DUSE_XPU=OFF
+		-Wno-dev
+	)
+
+	if use mkl; then
+		mycmakeargs+=(-DBLAS=MKL)
+	elif use openblas; then
+		mycmakeargs+=(-DBLAS=OpenBLAS)
+	else
+		mycmakeargs+=(-DBLAS=Generic -DBLAS_LIBRARIES=)
+	fi
+
+	if use cuda; then
+		addpredict "/dev/nvidiactl" # bug 867706
+		addpredict "/dev/char"
+		addpredict "/proc/self/task" # bug 926116
+
+		mycmakeargs+=(
+			-DUSE_CUDNN=ON
+			-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
+			-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
+			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
+		)
+	elif use rocm; then
+		export PYTORCH_ROCM_ARCH="$(get_amdgpu_flags)"
+
+		mycmakeargs+=(
+			-DUSE_NCCL=ON
+			-DUSE_SYSTEM_NCCL=ON
+		)
+
+		# ROCm libraries produce too much warnings
+		append-cxxflags -Wno-deprecated-declarations -Wno-unused-result
+
+		if tc-is-clang; then
+			# fix mangling in LLVM: https://github.com/llvm/llvm-project/issues/85656
+			append-cxxflags -fclang-abi-compat=17
+		fi
+	fi
+
+	if use onednn; then
+		mycmakeargs+=(
+			-DMKLDNN_FOUND=ON
+			-DMKLDNN_LIBRARIES=dnnl
+			-DMKLDNN_INCLUDE_DIR="${ESYSROOT}/usr/include/oneapi/dnnl"
+		)
+	fi
+
+	cmake_src_configure
+}
+
+src_compile() {
+	PYTORCH_BUILD_VERSION=${PV} \
+	PYTORCH_BUILD_NUMBER=0 \
+	cmake_src_compile
+}
+
+src_install() {
+	cmake_src_install
+
+	insinto "/var/lib/${PN}"
+	doins "${BUILD_DIR}"/CMakeCache.txt
+
+	rm -rf python
+	mkdir -p python/torch || die
+	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
+
+	ln -s ../../../../../include/torch \
+		"${D}$(python_get_sitedir)"/torch/include/torch || die # bug 923269
+
+
+	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 "${ED}"/usr/lib/libc10*.so \
+		"${ED}"/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
new file mode 100644
index 000000000000..5d684a4a4738
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-cpp-httplib.patch
@@ -0,0 +1,13 @@
+--- 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)

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-cudnn_include_fix.patch b/sci-libs/caffe2/files/caffe2-2.5.1-cudnn_include_fix.patch
new file mode 100644
index 000000000000..77905dbd1ac8
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-cudnn_include_fix.patch
@@ -0,0 +1,11 @@
+--- a/cmake/Dependencies.cmake	2024-04-29 18:37:34.005639858 +0200
++++ b/cmake/Dependencies.cmake	2024-04-29 18:39:29.126587738 +0200
+@@ -1235,7 +1235,7 @@
+   if(CUDNN_VERSION VERSION_LESS 8.5)
+     message(FATAL_ERROR "PyTorch needs CuDNN-8.5 or above, but found ${CUDNN_VERSION}. Builds are still possible with `USE_CUDNN=0`")
+   endif()
+-  set(CUDNN_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../third_party/cudnn_frontend/include)
++  set(CUDNN_FRONTEND_INCLUDE_DIR /opt/cuda/include)
+   target_include_directories(torch::cudnn INTERFACE ${CUDNN_FRONTEND_INCLUDE_DIR})
+ endif()
+ 

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-exclude-aotriton.patch b/sci-libs/caffe2/files/caffe2-2.5.1-exclude-aotriton.patch
new file mode 100644
index 000000000000..340d6e45c95a
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-exclude-aotriton.patch
@@ -0,0 +1,22 @@
+Disables aotriton download when both USE_FLASH_ATTENTION and USE_MEM_EFF_ATTENTION cmake flags are OFF
+Backports upstream PR to 2.3.0: https://github.com/pytorch/pytorch/pull/130197
+--- a/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
++++ b/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
+@@ -659,7 +659,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
+       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
+   constexpr auto less_than_sm80_mem_efficient_dtypes =
+       array_of<at::ScalarType>(at::kHalf, at::kFloat);
+-#ifdef USE_ROCM
++#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
+   constexpr auto aotriton_mem_efficient_dtypes =
+       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
+ #endif
+@@ -709,7 +709,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
+     }
+   }
+ 
+-#ifdef USE_ROCM
++#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
+   return check_tensor_dtype(params, aotriton_mem_efficient_dtypes, debug);
+ #else
+   auto dprop = at::cuda::getCurrentDeviceProperties();

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-fix-functorch-install.patch b/sci-libs/caffe2/files/caffe2-2.5.1-fix-functorch-install.patch
new file mode 100644
index 000000000000..ffce0028a556
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-fix-functorch-install.patch
@@ -0,0 +1,8 @@
+--- a/functorch/CMakeLists.txt	2024-11-10 11:18:29.151992840 +0100
++++ b/functorch/CMakeLists.txt	2024-11-10 11:20:19.642389982 +0100
+@@ -42,4 +42,4 @@
+ if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
+   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
+ endif()
+-install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
++install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.5.1-gentoo.patch
new file mode 100644
index 000000000000..f923b6746a4b
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-gentoo.patch
@@ -0,0 +1,127 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -986,12 +986,11 @@ endif()
+ # third_party/FBGEMM
+ include(cmake/public/utils.cmake)
+ if(NOT MSVC)
+-  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
++  string(APPEND CMAKE_CXX_FLAGS " -O2")
+   # Eigen fails to build with some versions, so convert this to a warning
+   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
+   string(APPEND CMAKE_CXX_FLAGS " -Wall")
+   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
+-  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
+@@ -1085,7 +1084,6 @@ if(NOT MSVC)
+   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
+   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
+-  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
+ else()
+   # skip unwanted includes from windows.h
+   add_compile_definitions(WIN32_LEAN_AND_MEAN)
+--- a/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
++++ b/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
+@@ -324,16 +324,8 @@ set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/pytorch_q
+ set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/qnnpack_func.h)
+ 
+ # ---[ Configure clog
+-if(NOT TARGET clog)
+-  set(CLOG_BUILD_TESTS OFF CACHE BOOL "")
+-  set(CLOG_RUNTIME_TYPE "${CPUINFO_RUNTIME_TYPE}" CACHE STRING "")
+-  add_subdirectory(
+-    "${CLOG_SOURCE_DIR}"
+-    "${CONFU_DEPENDENCIES_BINARY_DIR}/clog")
+-  # We build static version of clog but a dynamic library may indirectly depend on it
+-  set_property(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)
+-endif()
+-target_link_libraries(pytorch_qnnpack PUBLIC clog)
++find_library(CLOG_LIBRARY NAMES clog REQUIRED)
++target_link_libraries(pytorch_qnnpack PUBLIC ${CLOG_LIBRARY})
+ 
+ # ---[ Configure cpuinfo
+ if(NOT TARGET cpuinfo AND USE_SYSTEM_CPUINFO)
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -87,7 +87,7 @@ endif()
+ # 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 "")
+@@ -1081,7 +1081,6 @@ if(USE_XPU)
+ endif()
+ 
+ if(NOT MSVC AND USE_XNNPACK)
+-  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
+ endif()
+ 
+ # ==========================================================
+--- a/cmake/Codegen.cmake
++++ b/cmake/Codegen.cmake
+@@ -57,7 +57,7 @@ if(INTERN_BUILD_ATEN_OPS)
+   if(MSVC)
+     set(OPT_FLAG "/fp:strict ")
+   else(MSVC)
+-    set(OPT_FLAG "-O3 ")
++    set(OPT_FLAG " ")
+     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
+       set(OPT_FLAG " ")
+     endif()
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -473,7 +473,9 @@ if(USE_PYTORCH_QNNPACK)
+       set_property(TARGET pytorch_qnnpack PROPERTY POSITION_INDEPENDENT_CODE ON)
+       set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
+       # QNNPACK depends on gemmlowp headers
+-      target_include_directories(pytorch_qnnpack PRIVATE "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
++      find_package(gemmlowp REQUIRED)
++      get_target_property(GEMMLOWP_INCLUDE_DIRS gemmlowp::gemmlowp INTERFACE_INCLUDE_DIRECTORIES)
++      target_include_directories(pytorch_qnnpack PRIVATE ${GEMMLOWP_INCLUDE_DIRS})
+ 
+       if(PYTORCH_QNNPACK_CUSTOM_THREADPOOL)
+         target_compile_definitions(
+@@ -710,7 +712,7 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
+ endif()
+ 
+ # ---[ FBGEMM
+-if(USE_FBGEMM)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   if(NOT DEFINED FBGEMM_SOURCE_DIR)
+     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
+@@ -758,6 +760,7 @@ if(USE_FBGEMM)
+ endif()
+ 
+ if(USE_FBGEMM)
++  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
+   caffe2_update_option(USE_FBGEMM ON)
+ else()
+   caffe2_update_option(USE_FBGEMM OFF)
+--- a/cmake/External/nnpack.cmake
++++ b/cmake/External/nnpack.cmake
+@@ -56,7 +56,7 @@ if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAM
+   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
+   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
+ 
+-  if(NOT TARGET nnpack)
++  if(FALSE)
+     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
+       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
+     endif()
+--- a/cmake/public/utils.cmake
++++ b/cmake/public/utils.cmake
+@@ -422,8 +422,6 @@ function(torch_compile_options libname)
+   endif()
+ 
+   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
+-  target_compile_options(${libname} PRIVATE
+-      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
+ 
+ endfunction()
+ 

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-glog-0.6.0.patch b/sci-libs/caffe2/files/caffe2-2.5.1-glog-0.6.0.patch
new file mode 100644
index 000000000000..6c06d2cca654
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-glog-0.6.0.patch
@@ -0,0 +1,29 @@
+https://github.com/pytorch/pytorch/issues/58054
+
+--- a/c10/util/Logging.cpp
++++ b/c10/util/Logging.cpp
+@@ -192,23 +192,13 @@
+     google::GLOG_WARNING,
+     "The minimum log level that caffe2 will output.");
+ 
+-// Google glog's api does not have an external function that allows one to check
+-// if glog is initialized or not. It does have an internal function - so we are
+-// declaring it here. This is a hack but has been used by a bunch of others too
+-// (e.g. Torch).
+-namespace google {
+-namespace glog_internal_namespace_ {
+-bool IsGoogleLoggingInitialized();
+-} // namespace glog_internal_namespace_
+-} // namespace google
+-
+ namespace c10 {
+ namespace {
+ 
+ void initGoogleLogging(char const* name) {
+ #if !defined(_MSC_VER)
+   // This trick can only be used on UNIX platforms
+-  if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
++  if (!::google::IsGoogleLoggingInitialized())
+ #endif
+   {
+     ::google::InitGoogleLogging(name);

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-install-dirs.patch b/sci-libs/caffe2/files/caffe2-2.5.1-install-dirs.patch
new file mode 100644
index 000000000000..e99b7e59cb5b
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-install-dirs.patch
@@ -0,0 +1,11 @@
+--- a/c10/CMakeLists.txt
++++ b/c10/CMakeLists.txt
+@@ -162,7 +162,7 @@ if(NOT BUILD_LIBTORCHLESS)
+   # Note: for now, we will put all export path into one single Caffe2Targets group
+   # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
+   # individual libraries like libc10.so and libcaffe2.so are still self-contained.
+-  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION lib)
++  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ 
+ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_fmt.patch b/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_fmt.patch
new file mode 100644
index 000000000000..2594a56b36a5
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_fmt.patch
@@ -0,0 +1,10 @@
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -1522,7 +1522,6 @@
+ # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
+ # `fmt` is compatible with a superset of the compilers that PyTorch is, it
+ # shouldn't be too bad to just disable the checks.
+-set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
+ 
+ list(APPEND Caffe2_DEPENDENCY_LIBS fmt)
+ set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)

diff --git a/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_kineto.patch b/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_kineto.patch
new file mode 100644
index 000000000000..ebe931bc49b6
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.5.1-unbundle_kineto.patch
@@ -0,0 +1,22 @@
+--- a/torch/CMakeLists.txt	2024-11-09 20:50:21.806784527 +0100
++++ b/torch/CMakeLists.txt	2024-11-09 20:52:56.303892418 +0100
+@@ -67,7 +67,7 @@
+     ${TORCH_ROOT}/third_party/gloo
+     ${TORCH_ROOT}/third_party/onnx
+     ${TORCH_ROOT}/third_party/flatbuffers/include
+-    ${TORCH_ROOT}/third_party/kineto/libkineto/include
++    "/usr/include/kineto"
+     ${TORCH_ROOT}/third_party/cpp-httplib
+     ${TORCH_ROOT}/third_party/nlohmann/include
+ 
+--- a/caffe2/CMakeLists.txt	2024-11-09 20:58:37.698085144 +0100
++++ b/caffe2/CMakeLists.txt	2024-11-09 20:59:15.771391643 +0100
+@@ -1185,7 +1185,7 @@
+   ${TORCH_ROOT}/third_party/miniz-2.1.0)
+ 
+ target_include_directories(torch_cpu PRIVATE
+-  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
++  "/usr/include/kineto")
+ 
+ if(USE_KINETO)
+   target_include_directories(torch_cpu PRIVATE


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-09-05  7:10 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-09-05  7:10 UTC (permalink / raw
  To: gentoo-commits

commit:     f3d19697e96e0ce4d32484dc6ebf88c139ac710c
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Thu Sep  5 07:06:30 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Thu Sep  5 07:07:06 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f3d19697

sci-libs/caffe2: fix for gcc-15

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

 sci-libs/caffe2/caffe2-2.4.0-r1.ebuild           |  1 +
 sci-libs/caffe2/files/caffe2-2.4.0-cstdint.patch | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/sci-libs/caffe2/caffe2-2.4.0-r1.ebuild b/sci-libs/caffe2/caffe2-2.4.0-r1.ebuild
index d8e42de52185..e990c18926b2 100644
--- a/sci-libs/caffe2/caffe2-2.4.0-r1.ebuild
+++ b/sci-libs/caffe2/caffe2-2.4.0-r1.ebuild
@@ -126,6 +126,7 @@ PATCHES=(
 	../patches/${PN}-2.3.0-fix-libcpp.patch
 	"${FILESDIR}"/${PN}-2.4.0-libfmt-11.patch
 	"${FILESDIR}"/${P}-cpp-httplib.patch
+	"${FILESDIR}"/${P}-cstdint.patch
 )
 
 src_prepare() {

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-cstdint.patch b/sci-libs/caffe2/files/caffe2-2.4.0-cstdint.patch
new file mode 100644
index 000000000000..f248ab031eb0
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-cstdint.patch
@@ -0,0 +1,10 @@
+--- a/caffe2/utils/string_utils.cc	2024-09-05 08:29:06.930438069 +0200
++++ b/caffe2/utils/string_utils.cc	2024-09-05 08:29:28.398137596 +0200
+@@ -3,6 +3,7 @@
+ #include <algorithm>
+ #include <sstream>
+ #include <vector>
++#include <cstdint>
+ 
+ namespace caffe2 {
+ 


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-08-25 16:10 Sam James
  0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2024-08-25 16:10 UTC (permalink / raw
  To: gentoo-commits

commit:     3eb644344c81572ed7a50f6e7a9c10db689dcd2c
Author:     Alfred Wingate <parona <AT> protonmail <DOT> com>
AuthorDate: Mon Aug 19 18:28:49 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 25 16:08:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3eb64434

sci-libs/caffe2: fix build against libfmt-11

Signed-off-by: Alfred Wingate <parona <AT> protonmail.com>
Closes: https://github.com/gentoo/gentoo/pull/38210
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sci-libs/caffe2/caffe2-2.4.0.ebuild                |  1 +
 sci-libs/caffe2/files/caffe2-2.4.0-libfmt-11.patch | 44 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/sci-libs/caffe2/caffe2-2.4.0.ebuild b/sci-libs/caffe2/caffe2-2.4.0.ebuild
index 524dafcaacef..81a8906ea669 100644
--- a/sci-libs/caffe2/caffe2-2.4.0.ebuild
+++ b/sci-libs/caffe2/caffe2-2.4.0.ebuild
@@ -121,6 +121,7 @@ PATCHES=(
 	../patches/${PN}-2.4.0-exclude-aotriton.patch
 	../patches/${PN}-2.3.0-fix-rocm-gcc14-clamp.patch
 	../patches/${PN}-2.3.0-fix-libcpp.patch
+	"${FILESDIR}"/${PN}-2.4.0-libfmt-11.patch
 )
 
 src_prepare() {

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-libfmt-11.patch b/sci-libs/caffe2/files/caffe2-2.4.0-libfmt-11.patch
new file mode 100644
index 000000000000..9f6740a07f1f
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-libfmt-11.patch
@@ -0,0 +1,44 @@
+Fix build against libfmt-11
+
+https://github.com/pytorch/pytorch/commit/83eedf66b9e7f52323d9f45c5dfaa64472452595
+https://github.com/pytorch/pytorch/pull/130628
+
+From 83eedf66b9e7f52323d9f45c5dfaa64472452595 Mon Sep 17 00:00:00 2001
+From: Aaron Gokaslan <aaronGokaslan@gmail.com>
+Date: Tue, 16 Jul 2024 06:12:08 +0000
+Subject: [PATCH] Update libfmt submodule to 11.0.1 (#130628)
+
+Update libfmt to 11.0.1 reopen of https://github.com/pytorch/pytorch/pull/129962. Requires a kineto update and moves fmt::join into a separate include so added it where necessary.
+
+Pull Request resolved: https://github.com/pytorch/pytorch/pull/130628
+Approved by: https://github.com/aaronenyeshi
+--- a/torch/csrc/distributed/c10d/socket.cpp
++++ b/torch/csrc/distributed/c10d/socket.cpp
+@@ -32,6 +32,7 @@ C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wdeprecated")
+ #include <fmt/chrono.h>
+ C10_DIAGNOSTIC_POP()
+ #include <fmt/format.h>
++#include <fmt/ranges.h>
+ 
+ #include <torch/csrc/distributed/c10d/error.h>
+ #include <torch/csrc/distributed/c10d/exception.h>
+--- a/torch/csrc/profiler/standalone/execution_trace_observer.cpp
++++ b/torch/csrc/profiler/standalone/execution_trace_observer.cpp
+@@ -10,6 +10,7 @@
+ #endif // _WIN32
+ 
+ #include <fmt/format.h>
++#include <fmt/ranges.h>
+ #include <chrono>
+ #include <cmath>
+ #include <fstream>
+--- a/torch/csrc/profiler/util.cpp
++++ b/torch/csrc/profiler/util.cpp
+@@ -5,6 +5,7 @@
+ #include <c10/util/ArrayRef.h>
+ #include <c10/util/irange.h>
+ #include <fmt/format.h>
++#include <fmt/ranges.h>
+ 
+ #ifdef USE_KINETO
+ #include <libkineto.h>


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-08-09 15:37 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-08-09 15:37 UTC (permalink / raw
  To: gentoo-commits

commit:     81a12cf2fbf6fea73d91928f6362599f7bc4741f
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  9 15:29:59 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Fri Aug  9 15:34:12 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=81a12cf2

sci-libs/caffe2: update SRC_URI

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 +
 sci-libs/caffe2/caffe2-2.4.0.ebuild                |  27 +--
 .../files/caffe2-2.4.0-exclude-aotriton.patch      |  65 -------
 .../files/caffe2-2.4.0-fix-openmp-link.patch       |  14 --
 sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch    | 211 ---------------------
 .../caffe2/files/caffe2-2.4.0-install-dirs.patch   |  70 -------
 .../files/caffe2-2.4.0-rocm-fix-std-cpp17.patch    |  50 -----
 7 files changed, 15 insertions(+), 423 deletions(-)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index f34355be2e16..0ab8e6d1b824 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,3 +1,4 @@
+DIST caffe2-20240809.tar.gz 15242 BLAKE2B 77503c61487e7d85cca5afcab9a6e638f9833a70861845638cf1b62bc492d7b6650e6db81d53ebb2f39c6313509250d339f725f04d03ec6dd23dd0cf70843d8c SHA512 74b3b0b6671b655ecac93f7436c4ed7cb0157a83aafbf6afcc0811e11cef341cd8f638db1a111bcbb01e1a6dd4daf3a36b96d7a8ce90f04c2fa091bd6e3a142b
 DIST pytorch-2.2.2.tar.gz 116367503 BLAKE2B 0be22f2ec4b9aac6f5e976664cae01facf07929a32565cd57d7cc5b2d9888e9ae71ca301853752fe8f31d174d04c9974eb9ed2f3d452360a50ccf024f200726a SHA512 7990e0f9484038c3458c0bda2c863bf2b19e56edab81fc5938c6e0f08b17558287f853bb67350e8cca8f42bec0f1d4ba0e94e50a145db8da44bdd4bd703d91d0
 DIST pytorch-2.3.0.tar.gz 117029829 BLAKE2B 8f9c0d71ee0a9219b495eddccdcc65107f7ad537c43c68100b229f3d27b0e6c01ccb1659c7fffc356a48d80f2adc0a10361305dc8f1df20446de837d380f89f6 SHA512 67f7e9a096c3ffb952206ebf9105bedebb68c24ad82456083adf1d1d210437fcaa9dd52b68484cfc97d408c9eebc9541c76868c34a7c9982494dc3f424cfb07c
 DIST pytorch-2.3.1.tar.gz 117035696 BLAKE2B d419d7fa1342f1fb317ffce09ec9dc1447414627cc83d36578fe60f68c283c620b2b4d49f414cd206d537b90b16432a06cd1941662720db05d5e2b6c493325f5 SHA512 e1bcae44f9939fc7ccb1360a9b1970d92426f25e5de73e36964df3dd15ad5d8d9f5bd2f9a7dda6b8f64e2bba3674005bd869f542489cc442ad0125a02676f587

diff --git a/sci-libs/caffe2/caffe2-2.4.0.ebuild b/sci-libs/caffe2/caffe2-2.4.0.ebuild
index b4384eb7df11..730ea4d365f2 100644
--- a/sci-libs/caffe2/caffe2-2.4.0.ebuild
+++ b/sci-libs/caffe2/caffe2-2.4.0.ebuild
@@ -13,7 +13,8 @@ MYP=${MYPN}-${PV}
 DESCRIPTION="A deep learning framework"
 HOMEPAGE="https://pytorch.org/"
 SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
-	-> ${MYP}.tar.gz"
+	-> ${MYP}.tar.gz
+	https://dev.gentoo.org/~tupone/distfiles/caffe2-20240809.tar.gz"
 
 S="${WORKDIR}"/${MYP}
 
@@ -108,18 +109,18 @@ DEPEND="
 "
 
 PATCHES=(
-	"${FILESDIR}"/${PN}-2.4.0-gentoo.patch
-	"${FILESDIR}"/${PN}-2.4.0-install-dirs.patch
-	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
-	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
-	"${FILESDIR}"/${PN}-2.3.0-cudnn_include_fix.patch
-	"${FILESDIR}"/${PN}-2.1.2-fix-rpath.patch
-	"${FILESDIR}"/${PN}-2.4.0-fix-openmp-link.patch
-	"${FILESDIR}"/${PN}-2.4.0-rocm-fix-std-cpp17.patch
-	"${FILESDIR}"/${PN}-2.2.2-musl.patch
-	"${FILESDIR}"/${PN}-2.4.0-exclude-aotriton.patch
-	"${FILESDIR}"/${PN}-2.3.0-fix-rocm-gcc14-clamp.patch
-	"${FILESDIR}"/${PN}-2.3.0-fix-libcpp.patch
+	../patches/${PN}-2.4.0-gentoo.patch
+	../patches/${PN}-2.4.0-install-dirs.patch
+	../patches/${PN}-1.12.0-glog-0.6.0.patch
+	../patches/${PN}-1.13.1-tensorpipe.patch
+	../patches/${PN}-2.3.0-cudnn_include_fix.patch
+	../patches/${PN}-2.1.2-fix-rpath.patch
+	../patches/${PN}-2.4.0-fix-openmp-link.patch
+	../patches/${PN}-2.4.0-rocm-fix-std-cpp17.patch
+	../patches/${PN}-2.2.2-musl.patch
+	../patches/${PN}-2.4.0-exclude-aotriton.patch
+	../patches/${PN}-2.3.0-fix-rocm-gcc14-clamp.patch
+	../patches/${PN}-2.3.0-fix-libcpp.patch
 )
 
 src_prepare() {

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch b/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch
deleted file mode 100644
index 72ab792b2278..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-Disables aotriton download when both USE_FLASH_ATTENTION and USE_MEM_EFF_ATTENTION cmake flags are OFF
-Backports upstream PR to 2.3.0: https://github.com/pytorch/pytorch/pull/130197
---- a/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
-+++ b/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
-@@ -24,7 +24,7 @@
- #include <c10/core/SymInt.h>
- #include <c10/util/string_view.h>
- 
--#if USE_ROCM
-+#if defined(USE_ROCM) && (defined(USE_MEM_EFF_ATTENTION) || defined(USE_FLASH_ATTENTION))
- #include <aotriton/flash.h>
- #endif
- 
-@@ -207,7 +207,7 @@ bool check_flash_attention_hardware_support(sdp_params const& params, bool debug
-   // Check that the gpu is capable of running flash attention
-   using sm80 = SMVersion<8, 0>;
-   using sm90 = SMVersion<9, 0>;
--#if USE_ROCM
-+#if defined(USE_ROCM) && defined(USE_FLASH_ATTENTION)
-   auto stream = at::cuda::getCurrentCUDAStream().stream();
-   if (hipSuccess != aotriton::v2::flash::check_gpu(stream)) {
-       auto dprops = at::cuda::getCurrentDeviceProperties();
-@@ -238,7 +238,7 @@ bool check_mem_efficient_hardware_support(sdp_params const& params, bool debug)
-   // Mem Efficient attention supports hardware in the range [sm_50, sm_90]
-   using sm50 = SMVersion<5, 0>;
-   using sm90 = SMVersion<9, 0>;
--#if USE_ROCM
-+#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
-   auto stream = at::cuda::getCurrentCUDAStream().stream();
-   if (hipSuccess != aotriton::v2::flash::check_gpu(stream)) {
-       auto dprops = at::cuda::getCurrentDeviceProperties();
-@@ -623,7 +623,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
-       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
-   constexpr auto less_than_sm80_mem_efficient_dtypes =
-       array_of<at::ScalarType>(at::kHalf, at::kFloat);
--#ifdef USE_ROCM
-+#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
-   constexpr auto aotriton_mem_efficient_dtypes =
-       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
- #endif
-@@ -668,7 +668,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
-     }
-   }
- 
--#ifdef USE_ROCM
-+#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
-   return check_tensor_dtype(params, aotriton_mem_efficient_dtypes, debug);
- #else
-   auto dprop = at::cuda::getCurrentDeviceProperties();
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -1095,10 +1095,12 @@ if(USE_ROCM)
-       message(STATUS "Disabling Kernel Assert for ROCm")
-     endif()
- 
--    include(${CMAKE_CURRENT_LIST_DIR}/External/aotriton.cmake)
-     if(USE_CUDA)
-       caffe2_update_option(USE_MEM_EFF_ATTENTION OFF)
-     endif()
-+    if(USE_FLASH_ATTENTION OR USE_MEM_EFF_ATTENTION)
-+      include(${CMAKE_CURRENT_LIST_DIR}/External/aotriton.cmake)
-+    endif()
-   else()
-     caffe2_update_option(USE_ROCM OFF)
-   endif()

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch b/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch
deleted file mode 100644
index 9b0fe0b97c0f..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-Fix "undefined symbol: omp_get_max_active_levels" in mkl + <nothing else> builds
-https://github.com/pytorch/pytorch/issues/116576
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -1643,6 +1643,9 @@ if(BUILD_SHARED_LIBS)
-   if(CAFFE2_USE_MKL)
-     target_link_libraries(torch_global_deps caffe2::mkl)
-   endif()
-+  if(USE_OPENMP)
-+    target_link_libraries(torch_global_deps OpenMP::OpenMP_CXX)
-+  endif()
-   # The CUDA libraries are linked here for a different reason: in some
-   # cases we load these libraries with ctypes, and if they weren't opened
-   # with RTLD_GLOBAL, we'll do the "normal" search process again (and

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch
deleted file mode 100644
index d592a346386b..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch
+++ /dev/null
@@ -1,211 +0,0 @@
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -966,12 +966,11 @@ endif()
- # third_party/FBGEMM
- include(cmake/public/utils.cmake)
- if(NOT MSVC)
--  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
-+  string(APPEND CMAKE_CXX_FLAGS " -O2")
-   # Eigen fails to build with some versions, so convert this to a warning
-   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
-   string(APPEND CMAKE_CXX_FLAGS " -Wall")
-   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
--  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
-@@ -1074,7 +1073,6 @@ if(NOT MSVC)
-   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
-   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
- else()
-   # skip unwanted includes from windows.h
-   add_compile_definitions(WIN32_LEAN_AND_MEAN)
---- a/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
-+++ b/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
-@@ -324,16 +324,8 @@ set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/pytorch_q
- set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/qnnpack_func.h)
- 
- # ---[ Configure clog
--if(NOT TARGET clog)
--  set(CLOG_BUILD_TESTS OFF CACHE BOOL "")
--  set(CLOG_RUNTIME_TYPE "${CPUINFO_RUNTIME_TYPE}" CACHE STRING "")
--  add_subdirectory(
--    "${CLOG_SOURCE_DIR}"
--    "${CONFU_DEPENDENCIES_BINARY_DIR}/clog")
--  # We build static version of clog but a dynamic library may indirectly depend on it
--  set_property(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)
--endif()
--target_link_libraries(pytorch_qnnpack PUBLIC clog)
-+find_library(CLOG_LIBRARY NAMES clog REQUIRED)
-+target_link_libraries(pytorch_qnnpack PUBLIC ${CLOG_LIBRARY})
- 
- # ---[ Configure cpuinfo
- if(NOT TARGET cpuinfo AND USE_SYSTEM_CPUINFO)
---- a/c10/CMakeLists.txt
-+++ b/c10/CMakeLists.txt
-@@ -94,7 +94,7 @@ if(NOT BUILD_LIBTORCHLESS)
-   if(C10_USE_GLOG)
-     target_link_libraries(c10 PUBLIC glog::glog)
-   endif()
--  target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
-+  target_link_libraries(c10 PRIVATE fmt)
- 
-   if(C10_USE_NUMA)
-     message(STATUS "NUMA paths:")
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -87,7 +87,7 @@ endif()
- # 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 "")
-@@ -1075,7 +1075,6 @@ if(USE_XPU)
- endif()
- 
- if(NOT MSVC AND USE_XNNPACK)
--  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
- endif()
- 
- # ==========================================================
-@@ -1178,8 +1177,7 @@ target_include_directories(torch_cpu PRIVATE
- target_include_directories(torch_cpu PRIVATE
-   ${TORCH_ROOT}/third_party/miniz-2.1.0)
- 
--target_include_directories(torch_cpu PRIVATE
--  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
-+target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
- 
- if(USE_KINETO)
-   target_include_directories(torch_cpu PRIVATE
---- a/cmake/Codegen.cmake
-+++ b/cmake/Codegen.cmake
-@@ -57,7 +57,7 @@ if(INTERN_BUILD_ATEN_OPS)
-   if(MSVC)
-     set(OPT_FLAG "/fp:strict ")
-   else(MSVC)
--    set(OPT_FLAG "-O3 ")
-+    set(OPT_FLAG " ")
-     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
-       set(OPT_FLAG " ")
-     endif()
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -466,7 +466,9 @@ if(USE_PYTORCH_QNNPACK)
-       set_property(TARGET pytorch_qnnpack PROPERTY POSITION_INDEPENDENT_CODE ON)
-       set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
-       # QNNPACK depends on gemmlowp headers
--      target_include_directories(pytorch_qnnpack PRIVATE "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-+      find_package(gemmlowp REQUIRED)
-+      get_target_property(GEMMLOWP_INCLUDE_DIRS gemmlowp::gemmlowp INTERFACE_INCLUDE_DIRECTORIES)
-+      target_include_directories(pytorch_qnnpack PRIVATE ${GEMMLOWP_INCLUDE_DIRS})
- 
-       if(PYTORCH_QNNPACK_CUSTOM_THREADPOOL)
-         target_compile_definitions(
-@@ -705,7 +707,7 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
- endif()
- 
- # ---[ FBGEMM
--if(USE_FBGEMM)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   if(NOT DEFINED FBGEMM_SOURCE_DIR)
-     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
-@@ -753,6 +755,7 @@ if(USE_FBGEMM)
- endif()
- 
- if(USE_FBGEMM)
-+  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
-   caffe2_update_option(USE_FBGEMM ON)
- else()
-   caffe2_update_option(USE_FBGEMM OFF)
-@@ -1288,7 +1291,6 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
-       set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
-     endif()
-   endif()
--  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
- 
-   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
-   if(NOT USE_SYSTEM_ONNX)
-@@ -1530,7 +1532,6 @@ endif()
- #
- set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
- set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
--add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
- 
- # Disable compiler feature checks for `fmt`.
- #
-@@ -1539,9 +1540,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
- # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
- # `fmt` is compatible with a superset of the compilers that PyTorch is, it
- # shouldn't be too bad to just disable the checks.
--set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
- 
--list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
- set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
- 
- # ---[ Kineto
---- a/cmake/External/nnpack.cmake
-+++ b/cmake/External/nnpack.cmake
-@@ -56,7 +56,7 @@ if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAM
-   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
-   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
- 
--  if(NOT TARGET nnpack)
-+  if(FALSE)
-     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
-       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
-     endif()
---- a/cmake/public/utils.cmake
-+++ b/cmake/public/utils.cmake
-@@ -483,8 +483,6 @@ function(torch_compile_options libname)
-   endif()
- 
-   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
--  target_compile_options(${libname} PRIVATE
--      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
- 
- endfunction()
- 
---- a/functorch/CMakeLists.txt
-+++ b/functorch/CMakeLists.txt
-@@ -42,4 +42,4 @@ endif()
- if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
-   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
- endif()
--install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
-+install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
---- a/torch/CMakeLists.txt
-+++ b/torch/CMakeLists.txt
-@@ -59,16 +59,8 @@ set(TORCH_PYTHON_INCLUDE_DIRECTORIES
-     ${CMAKE_BINARY_DIR}
-     ${CMAKE_BINARY_DIR}/aten/src
-     ${CMAKE_BINARY_DIR}/caffe2/aten/src
--    ${CMAKE_BINARY_DIR}/third_party
--    ${CMAKE_BINARY_DIR}/third_party/onnx
--
--    ${TORCH_ROOT}/third_party/valgrind-headers
--
--    ${TORCH_ROOT}/third_party/gloo
--    ${TORCH_ROOT}/third_party/onnx
--    ${TORCH_ROOT}/third_party/flatbuffers/include
--    ${TORCH_ROOT}/third_party/kineto/libkineto/include
--    ${TORCH_ROOT}/third_party/cpp-httplib
-+    
-+    /usr/include/kineto
- 
-     ${TORCH_SRC_DIR}/csrc
-     ${TORCH_SRC_DIR}/csrc/api/include
-@@ -83,7 +75,6 @@ set(TORCH_PYTHON_LINK_LIBRARIES
-     opentelemetry::api
-     httplib
-     shm
--    fmt::fmt-header-only
-     ATEN_CPU_FILES_GEN_LIB)
- 
- if(USE_ASAN AND TARGET Sanitizer::address)

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch b/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch
deleted file mode 100644
index ee6e8fb91562..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch
+++ /dev/null
@@ -1,70 +0,0 @@
---- a/c10/CMakeLists.txt
-+++ b/c10/CMakeLists.txt
-@@ -157,7 +157,7 @@ if(NOT BUILD_LIBTORCHLESS)
-   # Note: for now, we will put all export path into one single Caffe2Targets group
-   # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
-   # individual libraries like libc10.so and libcaffe2.so are still self-contained.
--  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION lib)
-+  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
- endif()
- 
- install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
---- a/c10/cuda/CMakeLists.txt
-+++ b/c10/cuda/CMakeLists.txt
-@@ -82,7 +82,7 @@ if(NOT BUILD_LIBTORCHLESS)
- # Note: for now, we will put all export path into one single Caffe2Targets group
- # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
- # individual libraries like libc10.so and libcaffe2.so are still self-contained.
--install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION lib)
-+install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
- 
- endif()
- 
---- a/c10/hip/CMakeLists.txt
-+++ b/c10/hip/CMakeLists.txt
-@@ -57,7 +57,7 @@ if(NOT BUILD_LIBTORCHLESS)
-       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
-       $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
-       $<INSTALL_INTERFACE:include>)
--  install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION lib)
-+  install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
-   set(C10_HIP_LIB c10_hip)
- endif()
- 
---- a/c10/xpu/CMakeLists.txt
-+++ b/c10/xpu/CMakeLists.txt
-@@ -45,7 +45,7 @@ target_include_directories(
-     $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
-     $<INSTALL_INTERFACE:include>
-     )
--  install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION lib)
-+  install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
-   set(C10_XPU_LIB c10_xpu)
-   add_subdirectory(test)
- endif()
---- a/test/cpp/c10d/CMakeLists.txt
-+++ b/test/cpp/c10d/CMakeLists.txt
-@@ -64,7 +64,7 @@ if(USE_CUDA)
-       torch_cpu c10d_cuda_test gtest_main __caffe2_ucc)
-     if(INSTALL_TEST)
-       install(TARGETS ProcessGroupUCCTest DESTINATION bin)
--      install(TARGETS c10d_cuda_test DESTINATION lib)
-+      install(TARGETS c10d_cuda_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
-     endif()
-   endif()
- else()
---- a/test/cpp/jit/CMakeLists.txt
-+++ b/test/cpp/jit/CMakeLists.txt
-@@ -32,9 +32,9 @@ endif()
- target_link_libraries(backend_with_compiler torch)
- 
- if(INSTALL_TEST)
--  install(TARGETS torchbind_test DESTINATION lib)
--  install(TARGETS jitbackend_test DESTINATION lib)
--  install(TARGETS backend_with_compiler DESTINATION lib)
-+  install(TARGETS torchbind_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
-+  install(TARGETS jitbackend_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
-+  install(TARGETS backend_with_compiler DESTINATION ${CMAKE_INSTALL_LIBDIR})
- endif()
- 
- # Build the cpp gtest binary containing the cpp-only tests.

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch b/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch
deleted file mode 100644
index 3612c3db1a0b..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-Fix for error: invalid argument '-std=c++17' not allowed with 'C'
-https://github.com/pytorch/pytorch/issues/103222
---- a/c10/hip/CMakeLists.txt
-+++ b/c10/hip/CMakeLists.txt
-@@ -36,6 +36,7 @@ if(NOT BUILD_LIBTORCHLESS)
- 
-   # Propagate HIP_CXX_FLAGS that were set from Dependencies.cmake
-   target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})
-+  set_target_properties(c10_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
- 
-   # caffe2_hip adds a bunch of dependencies like rocsparse, but c10/hip is supposed to be
-   # minimal.  I'm not sure if we need hip_hcc or not; for now leave it out
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -1670,6 +1670,7 @@ if(USE_ROCM)
- 
-   # Since PyTorch files contain HIP headers, these flags are required for the necessary definitions to be added.
-   target_compile_options(torch_hip PUBLIC ${HIP_CXX_FLAGS})  # experiment
-+  set_target_properties(torch_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
- 
-   target_link_libraries(torch_hip PUBLIC c10_hip)
- 
-@@ -1867,6 +1868,7 @@ if(BUILD_TEST)
-       target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
-       target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
-       target_compile_options(${test_name} PRIVATE ${HIP_CXX_FLAGS})
-+      set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
-       add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
-       if(INSTALL_TEST)
-         install(TARGETS ${test_name} DESTINATION test)
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -1050,7 +1050,6 @@ if(USE_ROCM)
-     list(APPEND HIP_CXX_FLAGS -Wno-duplicate-decl-specifier)
-     list(APPEND HIP_CXX_FLAGS -DCAFFE2_USE_MIOPEN)
-     list(APPEND HIP_CXX_FLAGS -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP)
--    list(APPEND HIP_CXX_FLAGS -std=c++17)
-     list(APPEND HIP_CXX_FLAGS -DHIPBLAS_V2)
-     if(HIP_NEW_TYPE_ENUMS)
-       list(APPEND HIP_CXX_FLAGS -DHIP_NEW_TYPE_ENUMS)
---- a/cmake/public/utils.cmake
-+++ b/cmake/public/utils.cmake
-@@ -332,6 +332,7 @@ function(caffe2_hip_binary_target target_name_or_src)
-   caffe2_binary_target(${target_name_or_src})
- 
-   target_compile_options(${__target} PRIVATE ${HIP_CXX_FLAGS})
-+  set_target_properties(${__target} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
-   target_include_directories(${__target} PRIVATE ${Caffe2_HIP_INCLUDE})
- endfunction()
- 


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-08-08 16:27 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-08-08 16:27 UTC (permalink / raw
  To: gentoo-commits

commit:     7354afd9d872a15c6bdf1ee831db7f7f131fca01
Author:     Sv. Lockal <lockalsash <AT> gmail <DOT> com>
AuthorDate: Thu Aug  8 03:44:50 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Thu Aug  8 16:22:28 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7354afd9

sci-libs/caffe2: add 2.4.0

Changes:
* This version has no integration with ffmpeg/opencv anymore
* qnnpack ceased to exist as a separate library. Now it is a part of c10 sources. Splitting it to sci-libs/QNNPACK would require some major effort, while it is very unlikely that some non-pytorch project would use it. Therefore it is now bundled and sci-libs/QNNPACK added as a conflicting library (to be sunset in the future).
* sci-libs/hipBLASLt "is optional" patch was dropped, as it is now deeply integrated with caffe2. However it should not be a problem as sci-libs/hipBLASLt has "no kernels" mode where it compiles as a stub library (useful for all non-server GPUs)
* sci-libs/XNNPACK bumped; old xnnpack is not compatible
* sci-libs/kineto bumped; old kineto is not compatible
* no new patches, but 5 old patches require manual conflict resolution
* '-fclang-abi-compat=17' patch in previous release was incomplete; new version should handle clang+hipcc combination

Signed-off-by: Sv. Lockal <lockalsash <AT> gmail.com>
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 +
 sci-libs/caffe2/caffe2-2.4.0.ebuild                | 289 +++++++++++++++++++++
 .../files/caffe2-2.4.0-exclude-aotriton.patch      |  65 +++++
 .../files/caffe2-2.4.0-fix-openmp-link.patch       |  14 +
 sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch    | 211 +++++++++++++++
 .../caffe2/files/caffe2-2.4.0-install-dirs.patch   |  70 +++++
 .../files/caffe2-2.4.0-rocm-fix-std-cpp17.patch    |  50 ++++
 7 files changed, 700 insertions(+)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index 246ab4d21a1a..f34355be2e16 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,3 +1,4 @@
 DIST pytorch-2.2.2.tar.gz 116367503 BLAKE2B 0be22f2ec4b9aac6f5e976664cae01facf07929a32565cd57d7cc5b2d9888e9ae71ca301853752fe8f31d174d04c9974eb9ed2f3d452360a50ccf024f200726a SHA512 7990e0f9484038c3458c0bda2c863bf2b19e56edab81fc5938c6e0f08b17558287f853bb67350e8cca8f42bec0f1d4ba0e94e50a145db8da44bdd4bd703d91d0
 DIST pytorch-2.3.0.tar.gz 117029829 BLAKE2B 8f9c0d71ee0a9219b495eddccdcc65107f7ad537c43c68100b229f3d27b0e6c01ccb1659c7fffc356a48d80f2adc0a10361305dc8f1df20446de837d380f89f6 SHA512 67f7e9a096c3ffb952206ebf9105bedebb68c24ad82456083adf1d1d210437fcaa9dd52b68484cfc97d408c9eebc9541c76868c34a7c9982494dc3f424cfb07c
 DIST pytorch-2.3.1.tar.gz 117035696 BLAKE2B d419d7fa1342f1fb317ffce09ec9dc1447414627cc83d36578fe60f68c283c620b2b4d49f414cd206d537b90b16432a06cd1941662720db05d5e2b6c493325f5 SHA512 e1bcae44f9939fc7ccb1360a9b1970d92426f25e5de73e36964df3dd15ad5d8d9f5bd2f9a7dda6b8f64e2bba3674005bd869f542489cc442ad0125a02676f587
+DIST pytorch-2.4.0.tar.gz 115031093 BLAKE2B d206477963977011627df284efa01482fbf57e9fcb5f58f51d679c742b8e5dde6aa6affd8745ab817fcd09477d129a81e74e07be576b5d3585eaca1c735b8e01 SHA512 804d25944035f33de6591fd942fbda44d3de037717a4397d38a97474b01775d30eaf93d16dd708a832c0119050d24d73b90990fd3e3773be79d26ada25244d22

diff --git a/sci-libs/caffe2/caffe2-2.4.0.ebuild b/sci-libs/caffe2/caffe2-2.4.0.ebuild
new file mode 100644
index 000000000000..b4384eb7df11
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-2.4.0.ebuild
@@ -0,0 +1,289 @@
+# Copyright 2022-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+ROCM_VERSION=6.1
+inherit python-single-r1 cmake cuda flag-o-matic prefix rocm toolchain-funcs
+
+MYPN=pytorch
+MYP=${MYPN}-${PV}
+
+DESCRIPTION="A deep learning framework"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
+	-> ${MYP}.tar.gz"
+
+S="${WORKDIR}"/${MYP}
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="cuda distributed fbgemm flash gloo mkl mpi nnpack +numpy onednn openblas opencl openmp qnnpack rocm xnnpack"
+RESTRICT="test"
+REQUIRED_USE="
+	${PYTHON_REQUIRED_USE}
+	mpi? ( distributed )
+	gloo? ( distributed )
+	?? ( cuda rocm )
+	rocm? (
+		|| ( ${ROCM_REQUIRED_USE} )
+		!flash
+	)
+"
+
+# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
+RDEPEND="
+	${PYTHON_DEPS}
+	dev-cpp/gflags:=
+	>=dev-cpp/glog-0.5.0
+	dev-libs/cpuinfo
+	dev-libs/libfmt
+	dev-cpp/opentelemetry-cpp
+	dev-libs/protobuf:=
+	dev-libs/pthreadpool
+	dev-libs/sleef
+	virtual/lapack
+	sci-libs/onnx
+	sci-libs/foxi
+	cuda? (
+		dev-libs/cudnn
+		>=dev-libs/cudnn-frontend-1.0.3:0/8
+		<dev-util/nvidia-cuda-toolkit-12.4.0:=[profiler]
+	)
+	fbgemm? ( >=dev-libs/FBGEMM-2023.12.01 )
+	gloo? ( sci-libs/gloo[cuda?] )
+	mpi? ( virtual/mpi )
+	nnpack? ( sci-libs/NNPACK )
+	numpy? ( $(python_gen_cond_dep '
+		dev-python/numpy[${PYTHON_USEDEP}]
+		') )
+	onednn? ( dev-libs/oneDNN )
+	opencl? ( virtual/opencl )
+	qnnpack? (
+		!sci-libs/QNNPACK
+		dev-cpp/gemmlowp
+	)
+	rocm? (
+		=dev-util/hip-6.1*
+		=dev-libs/rccl-6.1*[${ROCM_USEDEP}]
+		=sci-libs/rocThrust-6.1*[${ROCM_USEDEP}]
+		=sci-libs/rocPRIM-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipBLAS-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipFFT-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipSPARSE-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipRAND-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipCUB-6.1*[${ROCM_USEDEP}]
+		=sci-libs/hipSOLVER-6.1*[${ROCM_USEDEP}]
+		=sci-libs/miopen-6.1*[${ROCM_USEDEP}]
+		=dev-util/roctracer-6.1*[${ROCM_USEDEP}]
+
+		=sci-libs/hipBLASLt-6.1*
+		amdgpu_targets_gfx90a? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx90a] )
+		amdgpu_targets_gfx940? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx940] )
+		amdgpu_targets_gfx941? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx941] )
+		amdgpu_targets_gfx942? ( =sci-libs/hipBLASLt-6.1*[amdgpu_targets_gfx942] )
+	)
+	distributed? ( sci-libs/tensorpipe[cuda?] )
+	xnnpack? ( >=sci-libs/XNNPACK-2024.02.29 )
+	mkl? ( sci-libs/mkl )
+	openblas? ( sci-libs/openblas )
+"
+DEPEND="
+	${RDEPEND}
+	cuda? ( >=dev-libs/cutlass-3.4.1 )
+	onednn? ( sci-libs/ideep )
+	dev-libs/psimd
+	dev-libs/FP16
+	dev-libs/FXdiv
+	dev-libs/pocketfft
+	dev-libs/flatbuffers
+	>=sci-libs/kineto-0.4.0_p20240525
+	$(python_gen_cond_dep '
+		dev-python/pyyaml[${PYTHON_USEDEP}]
+		dev-python/pybind11[${PYTHON_USEDEP}]
+		dev-python/typing-extensions[${PYTHON_USEDEP}]
+	')
+"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-2.4.0-gentoo.patch
+	"${FILESDIR}"/${PN}-2.4.0-install-dirs.patch
+	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
+	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
+	"${FILESDIR}"/${PN}-2.3.0-cudnn_include_fix.patch
+	"${FILESDIR}"/${PN}-2.1.2-fix-rpath.patch
+	"${FILESDIR}"/${PN}-2.4.0-fix-openmp-link.patch
+	"${FILESDIR}"/${PN}-2.4.0-rocm-fix-std-cpp17.patch
+	"${FILESDIR}"/${PN}-2.2.2-musl.patch
+	"${FILESDIR}"/${PN}-2.4.0-exclude-aotriton.patch
+	"${FILESDIR}"/${PN}-2.3.0-fix-rocm-gcc14-clamp.patch
+	"${FILESDIR}"/${PN}-2.3.0-fix-libcpp.patch
+)
+
+src_prepare() {
+	filter-lto #bug 862672
+	sed -i \
+		-e "/third_party\/gloo/d" \
+		cmake/Dependencies.cmake \
+		|| 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 \
+		caffe2/CMakeLists.txt \
+		cmake/Metal.cmake \
+		cmake/Modules/*.cmake \
+		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
+		cmake/public/LoadHIP.cmake \
+		cmake/public/cuda.cmake \
+		cmake/Dependencies.cmake \
+		torch/CMakeLists.txt \
+		CMakeLists.txt
+
+	if use rocm; then
+		sed -e "s:/opt/rocm:/usr:" \
+			-e "s:lib/cmake:$(get_libdir)/cmake:g" \
+			-e "s/HIP 1.0/HIP 1.0 REQUIRED/" \
+			-i cmake/public/LoadHIP.cmake || die
+
+		ebegin "HIPifying cuda sources"
+		${EPYTHON} tools/amd_build/build_amd.py || die
+		eend $?
+	fi
+}
+
+src_configure() {
+	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
+		ewarn "These may not be optimal for your GPU."
+		ewarn ""
+		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
+		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
+		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
+		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
+		ewarn ""
+		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
+		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
+	fi
+
+	local mycmakeargs=(
+		-DBUILD_CUSTOM_PROTOBUF=OFF
+		-DBUILD_SHARED_LIBS=ON
+
+		-DUSE_CCACHE=OFF
+		-DUSE_CUDA=$(usex cuda)
+		-DUSE_DISTRIBUTED=$(usex distributed)
+		-DUSE_MPI=$(usex mpi)
+		-DUSE_FAKELOWP=OFF
+		-DUSE_FBGEMM=$(usex fbgemm)
+		-DUSE_FLASH_ATTENTION=$(usex flash)
+		-DUSE_MEM_EFF_ATTENTION=OFF
+		-DUSE_GFLAGS=ON
+		-DUSE_GLOG=ON
+		-DUSE_GLOO=$(usex gloo)
+		-DUSE_KINETO=OFF # TODO
+		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
+		-DUSE_MKLDNN=$(usex onednn)
+		-DUSE_NNPACK=$(usex nnpack)
+		-DUSE_XNNPACK=$(usex xnnpack)
+		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
+		-DUSE_TENSORPIPE=$(usex distributed)
+		-DUSE_PYTORCH_QNNPACK=$(usex qnnpack)
+		-DUSE_NUMPY=$(usex numpy)
+		-DUSE_OPENCL=$(usex opencl)
+		-DUSE_OPENMP=$(usex openmp)
+		-DUSE_ROCM=$(usex rocm)
+		-DUSE_SYSTEM_CPUINFO=ON
+		-DUSE_SYSTEM_PYBIND11=ON
+		-DUSE_UCC=OFF
+		-DUSE_VALGRIND=OFF
+		-DPython_EXECUTABLE="${PYTHON}"
+		-DUSE_ITT=OFF
+		-DUSE_SYSTEM_PTHREADPOOL=ON
+		-DUSE_SYSTEM_PSIMD=ON
+		-DUSE_SYSTEM_FXDIV=ON
+		-DUSE_SYSTEM_FP16=ON
+		-DUSE_SYSTEM_GLOO=ON
+		-DUSE_SYSTEM_ONNX=ON
+		-DUSE_SYSTEM_SLEEF=ON
+		-DUSE_PYTORCH_METAL=OFF
+		-DUSE_XPU=OFF
+
+		-Wno-dev
+		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
+		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
+	)
+
+	if use mkl; then
+		mycmakeargs+=(-DBLAS=MKL)
+	elif use openblas; then
+		mycmakeargs+=(-DBLAS=OpenBLAS)
+	else
+		mycmakeargs+=(-DBLAS=Generic -DBLAS_LIBRARIES=)
+	fi
+
+	if use cuda; then
+		addpredict "/dev/nvidiactl" # bug 867706
+		addpredict "/dev/char"
+		addpredict "/proc/self/task" # bug 926116
+
+		mycmakeargs+=(
+			-DUSE_CUDNN=ON
+			-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
+			-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
+			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
+		)
+	elif use rocm; then
+		export PYTORCH_ROCM_ARCH="$(get_amdgpu_flags)"
+
+		mycmakeargs+=(
+			-DUSE_NCCL=ON
+			-DUSE_SYSTEM_NCCL=ON
+		)
+
+		# ROCm libraries produce too much warnings
+		append-cxxflags -Wno-deprecated-declarations -Wno-unused-result
+
+		if tc-is-clang; then
+			# fix mangling in LLVM: https://github.com/llvm/llvm-project/issues/85656
+			append-cxxflags -fclang-abi-compat=17
+		fi
+	fi
+
+	if use onednn; then
+		mycmakeargs+=(
+			-DUSE_MKLDNN=ON
+			-DMKLDNN_FOUND=ON
+			-DMKLDNN_LIBRARIES=dnnl
+			-DMKLDNN_INCLUDE_DIR="${ESYSROOT}/usr/include/oneapi/dnnl"
+		)
+	fi
+
+	cmake_src_configure
+
+	# do not rerun cmake and the build process in src_install
+	sed '/RERUN/,+1d' -i "${BUILD_DIR}"/build.ninja || die
+}
+
+src_install() {
+	cmake_src_install
+
+	insinto "/var/lib/${PN}"
+	doins "${BUILD_DIR}"/CMakeCache.txt
+
+	rm -rf python
+	mkdir -p python/torch/include || die
+	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
+	cp torch/version.py python/torch/ || die
+	python_domodule python/caffe2
+	python_domodule python/torch
+	ln -s ../../../../../include/torch \
+		"${D}$(python_get_sitedir)"/torch/include/torch || die # bug 923269
+}

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch b/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch
new file mode 100644
index 000000000000..72ab792b2278
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-exclude-aotriton.patch
@@ -0,0 +1,65 @@
+Disables aotriton download when both USE_FLASH_ATTENTION and USE_MEM_EFF_ATTENTION cmake flags are OFF
+Backports upstream PR to 2.3.0: https://github.com/pytorch/pytorch/pull/130197
+--- a/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
++++ b/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
+@@ -24,7 +24,7 @@
+ #include <c10/core/SymInt.h>
+ #include <c10/util/string_view.h>
+ 
+-#if USE_ROCM
++#if defined(USE_ROCM) && (defined(USE_MEM_EFF_ATTENTION) || defined(USE_FLASH_ATTENTION))
+ #include <aotriton/flash.h>
+ #endif
+ 
+@@ -207,7 +207,7 @@ bool check_flash_attention_hardware_support(sdp_params const& params, bool debug
+   // Check that the gpu is capable of running flash attention
+   using sm80 = SMVersion<8, 0>;
+   using sm90 = SMVersion<9, 0>;
+-#if USE_ROCM
++#if defined(USE_ROCM) && defined(USE_FLASH_ATTENTION)
+   auto stream = at::cuda::getCurrentCUDAStream().stream();
+   if (hipSuccess != aotriton::v2::flash::check_gpu(stream)) {
+       auto dprops = at::cuda::getCurrentDeviceProperties();
+@@ -238,7 +238,7 @@ bool check_mem_efficient_hardware_support(sdp_params const& params, bool debug)
+   // Mem Efficient attention supports hardware in the range [sm_50, sm_90]
+   using sm50 = SMVersion<5, 0>;
+   using sm90 = SMVersion<9, 0>;
+-#if USE_ROCM
++#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
+   auto stream = at::cuda::getCurrentCUDAStream().stream();
+   if (hipSuccess != aotriton::v2::flash::check_gpu(stream)) {
+       auto dprops = at::cuda::getCurrentDeviceProperties();
+@@ -623,7 +623,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
+       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
+   constexpr auto less_than_sm80_mem_efficient_dtypes =
+       array_of<at::ScalarType>(at::kHalf, at::kFloat);
+-#ifdef USE_ROCM
++#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
+   constexpr auto aotriton_mem_efficient_dtypes =
+       array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
+ #endif
+@@ -668,7 +668,7 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
+     }
+   }
+ 
+-#ifdef USE_ROCM
++#if defined(USE_ROCM) && defined(USE_MEM_EFF_ATTENTION)
+   return check_tensor_dtype(params, aotriton_mem_efficient_dtypes, debug);
+ #else
+   auto dprop = at::cuda::getCurrentDeviceProperties();
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -1095,10 +1095,12 @@ if(USE_ROCM)
+       message(STATUS "Disabling Kernel Assert for ROCm")
+     endif()
+ 
+-    include(${CMAKE_CURRENT_LIST_DIR}/External/aotriton.cmake)
+     if(USE_CUDA)
+       caffe2_update_option(USE_MEM_EFF_ATTENTION OFF)
+     endif()
++    if(USE_FLASH_ATTENTION OR USE_MEM_EFF_ATTENTION)
++      include(${CMAKE_CURRENT_LIST_DIR}/External/aotriton.cmake)
++    endif()
+   else()
+     caffe2_update_option(USE_ROCM OFF)
+   endif()

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch b/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch
new file mode 100644
index 000000000000..9b0fe0b97c0f
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-fix-openmp-link.patch
@@ -0,0 +1,14 @@
+Fix "undefined symbol: omp_get_max_active_levels" in mkl + <nothing else> builds
+https://github.com/pytorch/pytorch/issues/116576
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -1643,6 +1643,9 @@ if(BUILD_SHARED_LIBS)
+   if(CAFFE2_USE_MKL)
+     target_link_libraries(torch_global_deps caffe2::mkl)
+   endif()
++  if(USE_OPENMP)
++    target_link_libraries(torch_global_deps OpenMP::OpenMP_CXX)
++  endif()
+   # The CUDA libraries are linked here for a different reason: in some
+   # cases we load these libraries with ctypes, and if they weren't opened
+   # with RTLD_GLOBAL, we'll do the "normal" search process again (and

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch
new file mode 100644
index 000000000000..d592a346386b
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-gentoo.patch
@@ -0,0 +1,211 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -966,12 +966,11 @@ endif()
+ # third_party/FBGEMM
+ include(cmake/public/utils.cmake)
+ if(NOT MSVC)
+-  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
++  string(APPEND CMAKE_CXX_FLAGS " -O2")
+   # Eigen fails to build with some versions, so convert this to a warning
+   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
+   string(APPEND CMAKE_CXX_FLAGS " -Wall")
+   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
+-  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
+@@ -1074,7 +1073,6 @@ if(NOT MSVC)
+   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
+   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
+-  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
+ else()
+   # skip unwanted includes from windows.h
+   add_compile_definitions(WIN32_LEAN_AND_MEAN)
+--- a/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
++++ b/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
+@@ -324,16 +324,8 @@ set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/pytorch_q
+ set_target_properties(pytorch_qnnpack PROPERTIES PUBLIC_HEADER include/qnnpack_func.h)
+ 
+ # ---[ Configure clog
+-if(NOT TARGET clog)
+-  set(CLOG_BUILD_TESTS OFF CACHE BOOL "")
+-  set(CLOG_RUNTIME_TYPE "${CPUINFO_RUNTIME_TYPE}" CACHE STRING "")
+-  add_subdirectory(
+-    "${CLOG_SOURCE_DIR}"
+-    "${CONFU_DEPENDENCIES_BINARY_DIR}/clog")
+-  # We build static version of clog but a dynamic library may indirectly depend on it
+-  set_property(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)
+-endif()
+-target_link_libraries(pytorch_qnnpack PUBLIC clog)
++find_library(CLOG_LIBRARY NAMES clog REQUIRED)
++target_link_libraries(pytorch_qnnpack PUBLIC ${CLOG_LIBRARY})
+ 
+ # ---[ Configure cpuinfo
+ if(NOT TARGET cpuinfo AND USE_SYSTEM_CPUINFO)
+--- a/c10/CMakeLists.txt
++++ b/c10/CMakeLists.txt
+@@ -94,7 +94,7 @@ if(NOT BUILD_LIBTORCHLESS)
+   if(C10_USE_GLOG)
+     target_link_libraries(c10 PUBLIC glog::glog)
+   endif()
+-  target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
++  target_link_libraries(c10 PRIVATE fmt)
+ 
+   if(C10_USE_NUMA)
+     message(STATUS "NUMA paths:")
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -87,7 +87,7 @@ endif()
+ # 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 "")
+@@ -1075,7 +1075,6 @@ if(USE_XPU)
+ endif()
+ 
+ if(NOT MSVC AND USE_XNNPACK)
+-  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
+ endif()
+ 
+ # ==========================================================
+@@ -1178,8 +1177,7 @@ target_include_directories(torch_cpu PRIVATE
+ target_include_directories(torch_cpu PRIVATE
+   ${TORCH_ROOT}/third_party/miniz-2.1.0)
+ 
+-target_include_directories(torch_cpu PRIVATE
+-  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
++target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
+ 
+ if(USE_KINETO)
+   target_include_directories(torch_cpu PRIVATE
+--- a/cmake/Codegen.cmake
++++ b/cmake/Codegen.cmake
+@@ -57,7 +57,7 @@ if(INTERN_BUILD_ATEN_OPS)
+   if(MSVC)
+     set(OPT_FLAG "/fp:strict ")
+   else(MSVC)
+-    set(OPT_FLAG "-O3 ")
++    set(OPT_FLAG " ")
+     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
+       set(OPT_FLAG " ")
+     endif()
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -466,7 +466,9 @@ if(USE_PYTORCH_QNNPACK)
+       set_property(TARGET pytorch_qnnpack PROPERTY POSITION_INDEPENDENT_CODE ON)
+       set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
+       # QNNPACK depends on gemmlowp headers
+-      target_include_directories(pytorch_qnnpack PRIVATE "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
++      find_package(gemmlowp REQUIRED)
++      get_target_property(GEMMLOWP_INCLUDE_DIRS gemmlowp::gemmlowp INTERFACE_INCLUDE_DIRECTORIES)
++      target_include_directories(pytorch_qnnpack PRIVATE ${GEMMLOWP_INCLUDE_DIRS})
+ 
+       if(PYTORCH_QNNPACK_CUSTOM_THREADPOOL)
+         target_compile_definitions(
+@@ -705,7 +707,7 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
+ endif()
+ 
+ # ---[ FBGEMM
+-if(USE_FBGEMM)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   if(NOT DEFINED FBGEMM_SOURCE_DIR)
+     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
+@@ -753,6 +755,7 @@ if(USE_FBGEMM)
+ endif()
+ 
+ if(USE_FBGEMM)
++  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
+   caffe2_update_option(USE_FBGEMM ON)
+ else()
+   caffe2_update_option(USE_FBGEMM OFF)
+@@ -1288,7 +1291,6 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
+       set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
+     endif()
+   endif()
+-  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
+ 
+   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
+   if(NOT USE_SYSTEM_ONNX)
+@@ -1530,7 +1532,6 @@ endif()
+ #
+ set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
+-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
+ 
+ # Disable compiler feature checks for `fmt`.
+ #
+@@ -1539,9 +1540,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
+ # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
+ # `fmt` is compatible with a superset of the compilers that PyTorch is, it
+ # shouldn't be too bad to just disable the checks.
+-set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
+ 
+-list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
+ set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
+ 
+ # ---[ Kineto
+--- a/cmake/External/nnpack.cmake
++++ b/cmake/External/nnpack.cmake
+@@ -56,7 +56,7 @@ if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAM
+   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
+   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
+ 
+-  if(NOT TARGET nnpack)
++  if(FALSE)
+     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
+       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
+     endif()
+--- a/cmake/public/utils.cmake
++++ b/cmake/public/utils.cmake
+@@ -483,8 +483,6 @@ function(torch_compile_options libname)
+   endif()
+ 
+   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
+-  target_compile_options(${libname} PRIVATE
+-      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
+ 
+ endfunction()
+ 
+--- a/functorch/CMakeLists.txt
++++ b/functorch/CMakeLists.txt
+@@ -42,4 +42,4 @@ endif()
+ if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
+   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
+ endif()
+-install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
++install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+--- a/torch/CMakeLists.txt
++++ b/torch/CMakeLists.txt
+@@ -59,16 +59,8 @@ set(TORCH_PYTHON_INCLUDE_DIRECTORIES
+     ${CMAKE_BINARY_DIR}
+     ${CMAKE_BINARY_DIR}/aten/src
+     ${CMAKE_BINARY_DIR}/caffe2/aten/src
+-    ${CMAKE_BINARY_DIR}/third_party
+-    ${CMAKE_BINARY_DIR}/third_party/onnx
+-
+-    ${TORCH_ROOT}/third_party/valgrind-headers
+-
+-    ${TORCH_ROOT}/third_party/gloo
+-    ${TORCH_ROOT}/third_party/onnx
+-    ${TORCH_ROOT}/third_party/flatbuffers/include
+-    ${TORCH_ROOT}/third_party/kineto/libkineto/include
+-    ${TORCH_ROOT}/third_party/cpp-httplib
++    
++    /usr/include/kineto
+ 
+     ${TORCH_SRC_DIR}/csrc
+     ${TORCH_SRC_DIR}/csrc/api/include
+@@ -83,7 +75,6 @@ set(TORCH_PYTHON_LINK_LIBRARIES
+     opentelemetry::api
+     httplib
+     shm
+-    fmt::fmt-header-only
+     ATEN_CPU_FILES_GEN_LIB)
+ 
+ if(USE_ASAN AND TARGET Sanitizer::address)

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch b/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch
new file mode 100644
index 000000000000..ee6e8fb91562
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-install-dirs.patch
@@ -0,0 +1,70 @@
+--- a/c10/CMakeLists.txt
++++ b/c10/CMakeLists.txt
+@@ -157,7 +157,7 @@ if(NOT BUILD_LIBTORCHLESS)
+   # Note: for now, we will put all export path into one single Caffe2Targets group
+   # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
+   # individual libraries like libc10.so and libcaffe2.so are still self-contained.
+-  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION lib)
++  install(TARGETS c10 EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ 
+ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+--- a/c10/cuda/CMakeLists.txt
++++ b/c10/cuda/CMakeLists.txt
+@@ -82,7 +82,7 @@ if(NOT BUILD_LIBTORCHLESS)
+ # Note: for now, we will put all export path into one single Caffe2Targets group
+ # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
+ # individual libraries like libc10.so and libcaffe2.so are still self-contained.
+-install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION lib)
++install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ 
+ endif()
+ 
+--- a/c10/hip/CMakeLists.txt
++++ b/c10/hip/CMakeLists.txt
+@@ -57,7 +57,7 @@ if(NOT BUILD_LIBTORCHLESS)
+       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
+       $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
+       $<INSTALL_INTERFACE:include>)
+-  install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION lib)
++  install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+   set(C10_HIP_LIB c10_hip)
+ endif()
+ 
+--- a/c10/xpu/CMakeLists.txt
++++ b/c10/xpu/CMakeLists.txt
+@@ -45,7 +45,7 @@ target_include_directories(
+     $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
+     $<INSTALL_INTERFACE:include>
+     )
+-  install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION lib)
++  install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+   set(C10_XPU_LIB c10_xpu)
+   add_subdirectory(test)
+ endif()
+--- a/test/cpp/c10d/CMakeLists.txt
++++ b/test/cpp/c10d/CMakeLists.txt
+@@ -64,7 +64,7 @@ if(USE_CUDA)
+       torch_cpu c10d_cuda_test gtest_main __caffe2_ucc)
+     if(INSTALL_TEST)
+       install(TARGETS ProcessGroupUCCTest DESTINATION bin)
+-      install(TARGETS c10d_cuda_test DESTINATION lib)
++      install(TARGETS c10d_cuda_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
+     endif()
+   endif()
+ else()
+--- a/test/cpp/jit/CMakeLists.txt
++++ b/test/cpp/jit/CMakeLists.txt
+@@ -32,9 +32,9 @@ endif()
+ target_link_libraries(backend_with_compiler torch)
+ 
+ if(INSTALL_TEST)
+-  install(TARGETS torchbind_test DESTINATION lib)
+-  install(TARGETS jitbackend_test DESTINATION lib)
+-  install(TARGETS backend_with_compiler DESTINATION lib)
++  install(TARGETS torchbind_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
++  install(TARGETS jitbackend_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
++  install(TARGETS backend_with_compiler DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ 
+ # Build the cpp gtest binary containing the cpp-only tests.

diff --git a/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch b/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch
new file mode 100644
index 000000000000..3612c3db1a0b
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.4.0-rocm-fix-std-cpp17.patch
@@ -0,0 +1,50 @@
+Fix for error: invalid argument '-std=c++17' not allowed with 'C'
+https://github.com/pytorch/pytorch/issues/103222
+--- a/c10/hip/CMakeLists.txt
++++ b/c10/hip/CMakeLists.txt
+@@ -36,6 +36,7 @@ if(NOT BUILD_LIBTORCHLESS)
+ 
+   # Propagate HIP_CXX_FLAGS that were set from Dependencies.cmake
+   target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})
++  set_target_properties(c10_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+ 
+   # caffe2_hip adds a bunch of dependencies like rocsparse, but c10/hip is supposed to be
+   # minimal.  I'm not sure if we need hip_hcc or not; for now leave it out
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -1670,6 +1670,7 @@ if(USE_ROCM)
+ 
+   # Since PyTorch files contain HIP headers, these flags are required for the necessary definitions to be added.
+   target_compile_options(torch_hip PUBLIC ${HIP_CXX_FLAGS})  # experiment
++  set_target_properties(torch_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+ 
+   target_link_libraries(torch_hip PUBLIC c10_hip)
+ 
+@@ -1867,6 +1868,7 @@ if(BUILD_TEST)
+       target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
+       target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
+       target_compile_options(${test_name} PRIVATE ${HIP_CXX_FLAGS})
++      set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+       add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
+       if(INSTALL_TEST)
+         install(TARGETS ${test_name} DESTINATION test)
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -1050,7 +1050,6 @@ if(USE_ROCM)
+     list(APPEND HIP_CXX_FLAGS -Wno-duplicate-decl-specifier)
+     list(APPEND HIP_CXX_FLAGS -DCAFFE2_USE_MIOPEN)
+     list(APPEND HIP_CXX_FLAGS -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP)
+-    list(APPEND HIP_CXX_FLAGS -std=c++17)
+     list(APPEND HIP_CXX_FLAGS -DHIPBLAS_V2)
+     if(HIP_NEW_TYPE_ENUMS)
+       list(APPEND HIP_CXX_FLAGS -DHIP_NEW_TYPE_ENUMS)
+--- a/cmake/public/utils.cmake
++++ b/cmake/public/utils.cmake
+@@ -332,6 +332,7 @@ function(caffe2_hip_binary_target target_name_or_src)
+   caffe2_binary_target(${target_name_or_src})
+ 
+   target_compile_options(${__target} PRIVATE ${HIP_CXX_FLAGS})
++  set_target_properties(${__target} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+   target_include_directories(${__target} PRIVATE ${Caffe2_HIP_INCLUDE})
+ endfunction()
+ 


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-05-26 15:19 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-05-26 15:19 UTC (permalink / raw
  To: gentoo-commits

commit:     b9b308ff9ae9f292fb81531b4cfff1569c4a2193
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Sun May 26 15:16:29 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sun May 26 15:18:13 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9b308ff

sci-libs/caffe2: drop 2.1.2-r7

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 -
 sci-libs/caffe2/caffe2-2.1.2-r7.ebuild             | 283 ---------------------
 sci-libs/caffe2/files/caffe2-2.1.1-cudaExtra.patch |  28 --
 sci-libs/caffe2/files/caffe2-2.1.1-gentoo.patch    | 188 --------------
 sci-libs/caffe2/metadata.xml                       |   1 -
 5 files changed, 501 deletions(-)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index f1df96691729..d70fba8fc67b 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,3 +1,2 @@
-DIST pytorch-2.1.2.tar.gz 116316469 BLAKE2B c5a55ee264bc3477d3556ba6376b5591117e992e56e0dd0c9ba93d12526e2727f7840f6f1e0730a38223b6492c9556840c4ebf22ffd220e97225c2abff303747 SHA512 a8961d78ad785b13c959a0612563a60e0de17a7c8bb9822ddea9a24072796354d07e81c47b6cc8761b21a6448845b088cf80e1661d9e889b0ed5474d3dc76756
 DIST pytorch-2.2.2.tar.gz 116367503 BLAKE2B 0be22f2ec4b9aac6f5e976664cae01facf07929a32565cd57d7cc5b2d9888e9ae71ca301853752fe8f31d174d04c9974eb9ed2f3d452360a50ccf024f200726a SHA512 7990e0f9484038c3458c0bda2c863bf2b19e56edab81fc5938c6e0f08b17558287f853bb67350e8cca8f42bec0f1d4ba0e94e50a145db8da44bdd4bd703d91d0
 DIST pytorch-2.3.0.tar.gz 117029829 BLAKE2B 8f9c0d71ee0a9219b495eddccdcc65107f7ad537c43c68100b229f3d27b0e6c01ccb1659c7fffc356a48d80f2adc0a10361305dc8f1df20446de837d380f89f6 SHA512 67f7e9a096c3ffb952206ebf9105bedebb68c24ad82456083adf1d1d210437fcaa9dd52b68484cfc97d408c9eebc9541c76868c34a7c9982494dc3f424cfb07c

diff --git a/sci-libs/caffe2/caffe2-2.1.2-r7.ebuild b/sci-libs/caffe2/caffe2-2.1.2-r7.ebuild
deleted file mode 100644
index 8198f516b251..000000000000
--- a/sci-libs/caffe2/caffe2-2.1.2-r7.ebuild
+++ /dev/null
@@ -1,283 +0,0 @@
-# Copyright 2022-2024 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-PYTHON_COMPAT=( python3_{10..12} )
-ROCM_VERSION=5.7
-inherit python-single-r1 cmake cuda flag-o-matic prefix rocm
-
-MYPN=pytorch
-MYP=${MYPN}-${PV}
-
-DESCRIPTION="A deep learning framework"
-HOMEPAGE="https://pytorch.org/"
-SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
-	-> ${MYP}.tar.gz"
-
-S="${WORKDIR}"/${MYP}
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64"
-IUSE="cuda distributed fbgemm ffmpeg gloo mkl mpi nnpack +numpy onednn openblas opencl opencv openmp qnnpack rocm tensorpipe xnnpack"
-RESTRICT="test"
-REQUIRED_USE="
-	${PYTHON_REQUIRED_USE}
-	ffmpeg? ( opencv )
-	mpi? ( distributed )
-	tensorpipe? ( distributed )
-	distributed? ( tensorpipe )
-	gloo? ( distributed )
-	?? ( cuda rocm )
-	rocm? ( || ( ${ROCM_REQUIRED_USE} ) )
-"
-
-# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
-RDEPEND="
-	${PYTHON_DEPS}
-	dev-cpp/gflags:=
-	>=dev-cpp/glog-0.5.0
-	dev-libs/cpuinfo
-	dev-libs/libfmt
-	dev-libs/protobuf:=
-	dev-libs/pthreadpool
-	dev-libs/sleef
-	virtual/lapack
-	>=sci-libs/onnx-1.12.0
-	<sci-libs/onnx-1.15.0
-	sci-libs/foxi
-	cuda? (
-		=dev-libs/cudnn-8*
-		>=dev-libs/cudnn-frontend-0.9.2:0/8
-		<dev-util/nvidia-cuda-toolkit-12.4.0:=[profiler]
-	)
-	fbgemm? ( >=dev-libs/FBGEMM-2023.11.02 )
-	ffmpeg? ( media-video/ffmpeg:= )
-	gloo? ( sci-libs/gloo[cuda?] )
-	mpi? ( virtual/mpi )
-	nnpack? ( sci-libs/NNPACK )
-	numpy? ( $(python_gen_cond_dep '
-		dev-python/numpy[${PYTHON_USEDEP}]
-		') )
-	onednn? ( dev-libs/oneDNN )
-	opencl? ( virtual/opencl )
-	opencv? ( media-libs/opencv:= )
-	qnnpack? ( sci-libs/QNNPACK )
-	rocm? (
-		>=dev-util/hip-5.7
-		>=dev-libs/rccl-5.7[${ROCM_USEDEP}]
-		>=sci-libs/rocThrust-5.7[${ROCM_USEDEP}]
-		>=sci-libs/rocPRIM-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipBLAS-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipFFT-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipSPARSE-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipRAND-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipCUB-5.7[${ROCM_USEDEP}]
-		>=sci-libs/hipSOLVER-5.7[${ROCM_USEDEP}]
-		>=sci-libs/miopen-5.7[${ROCM_USEDEP}]
-		>=dev-util/roctracer-5.7[${ROCM_USEDEP}]
-	)
-	tensorpipe? ( sci-libs/tensorpipe[cuda?] )
-	xnnpack? ( >=sci-libs/XNNPACK-2022.12.22 )
-	mkl? ( sci-libs/mkl )
-	openblas? ( sci-libs/openblas )
-"
-DEPEND="
-	${RDEPEND}
-	cuda? ( >=dev-libs/cutlass-3.1.0 )
-	onednn? ( sci-libs/ideep )
-	dev-libs/psimd
-	dev-libs/FP16
-	dev-libs/FXdiv
-	dev-libs/pocketfft
-	dev-libs/flatbuffers
-	>=sci-libs/kineto-0.4.0_p20231031
-	$(python_gen_cond_dep '
-		dev-python/pyyaml[${PYTHON_USEDEP}]
-		dev-python/pybind11[${PYTHON_USEDEP}]
-	')
-"
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-2.1.1-gentoo.patch
-	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
-	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
-	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
-	"${FILESDIR}"/${PN}-2.0.0-gcc13.patch
-	"${FILESDIR}"/${PN}-2.0.0-cudnn_include_fix.patch
-	"${FILESDIR}"/${PN}-2.1.1-cudaExtra.patch
-	"${FILESDIR}"/${PN}-2.1.2-fix-rpath.patch
-	"${FILESDIR}"/${PN}-2.1.2-fix-openmp-link.patch
-	"${FILESDIR}"/${PN}-2.1.2-rocm-fix-std-cpp17.patch
-)
-
-src_prepare() {
-	filter-lto #bug 862672
-	sed -i \
-		-e "/third_party\/gloo/d" \
-		cmake/Dependencies.cmake \
-		|| 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 \
-		caffe2/CMakeLists.txt \
-		cmake/Metal.cmake \
-		cmake/Modules/*.cmake \
-		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
-		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
-		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
-		cmake/public/LoadHIP.cmake \
-		cmake/public/cuda.cmake \
-		cmake/Dependencies.cmake \
-		torch/CMakeLists.txt \
-		CMakeLists.txt
-
-	if use rocm; then
-		sed -e "s:ROCM_PATH /opt/rocm:ROCM_PATH /usr:" \
-			-e "s:HIP_PATH \${ROCM_PATH}/hip:HIP_PATH /usr:" \
-			-e "s:\${HIP_PATH}/cmake:/usr/$(get_libdir)/cmake/hip:g" \
-			-e "s/HIP 1.0/HIP 1.0 REQUIRED/" \
-			-i cmake/public/LoadHIP.cmake || die
-
-		ebegin "HIPifying cuda sources"
-		${EPYTHON} tools/amd_build/build_amd.py || die
-		eend $?
-	fi
-}
-
-src_configure() {
-	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
-		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
-		ewarn "These may not be optimal for your GPU."
-		ewarn ""
-		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
-		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
-		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
-		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
-		ewarn ""
-		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
-		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
-	fi
-
-	local mycmakeargs=(
-		-DBUILD_CUSTOM_PROTOBUF=OFF
-		-DBUILD_SHARED_LIBS=ON
-
-		-DUSE_CCACHE=OFF
-		-DUSE_CUDA=$(usex cuda)
-		-DUSE_DISTRIBUTED=$(usex distributed)
-		-DUSE_MPI=$(usex mpi)
-		-DUSE_FAKELOWP=OFF
-		-DUSE_FBGEMM=$(usex fbgemm)
-		-DUSE_FFMPEG=$(usex ffmpeg)
-		-DUSE_GFLAGS=ON
-		-DUSE_GLOG=ON
-		-DUSE_GLOO=$(usex gloo)
-		-DUSE_KINETO=OFF # TODO
-		-DUSE_LEVELDB=OFF
-		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
-		-DUSE_MKLDNN=$(usex onednn)
-		-DUSE_NNPACK=$(usex nnpack)
-		-DUSE_QNNPACK=$(usex qnnpack)
-		-DUSE_XNNPACK=$(usex xnnpack)
-		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
-		-DUSE_TENSORPIPE=$(usex tensorpipe)
-		-DUSE_PYTORCH_QNNPACK=OFF
-		-DUSE_NUMPY=$(usex numpy)
-		-DUSE_OPENCL=$(usex opencl)
-		-DUSE_OPENCV=$(usex opencv)
-		-DUSE_OPENMP=$(usex openmp)
-		-DUSE_ROCM=$(usex rocm)
-		-DUSE_SYSTEM_CPUINFO=ON
-		-DUSE_SYSTEM_PYBIND11=ON
-		-DUSE_UCC=OFF
-		-DUSE_VALGRIND=OFF
-		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
-		-DPYTHON_EXECUTABLE="${PYTHON}"
-		-DUSE_ITT=OFF
-		-DUSE_SYSTEM_PTHREADPOOL=ON
-		-DUSE_SYSTEM_FXDIV=ON
-		-DUSE_SYSTEM_FP16=ON
-		-DUSE_SYSTEM_GLOO=ON
-		-DUSE_SYSTEM_ONNX=ON
-		-DUSE_SYSTEM_SLEEF=ON
-		-DUSE_METAL=OFF
-
-		-Wno-dev
-		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
-		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
-	)
-
-	if use mkl; then
-		mycmakeargs+=(-DBLAS=MKL)
-	elif use openblas; then
-		mycmakeargs+=(-DBLAS=OpenBLAS)
-	else
-		mycmakeargs+=(-DBLAS=Generic -DBLAS_LIBRARIES=)
-	fi
-
-	if use cuda; then
-		addpredict "/dev/nvidiactl" # bug 867706
-		addpredict "/dev/char"
-
-		mycmakeargs+=(
-			-DUSE_CUDNN=ON
-			-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
-			-DBUILD_NVFUSER=ON
-			-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
-			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
-		)
-	elif use rocm; then
-		export PYTORCH_ROCM_ARCH="$(get_amdgpu_flags)"
-
-		mycmakeargs+=(
-			-DBUILD_NVFUSER=ON
-			-DUSE_NCCL=ON
-			-DUSE_SYSTEM_NCCL=ON
-		)
-	fi
-
-	if use onednn; then
-		mycmakeargs+=(
-			-DUSE_MKLDNN=ON
-			-DMKLDNN_FOUND=ON
-			-DMKLDNN_LIBRARIES=dnnl
-			-DMKLDNN_INCLUDE_DIR="${ESYSROOT}/usr/include/oneapi/dnnl"
-		)
-	fi
-
-	cmake_src_configure
-
-	# do not rerun cmake and the build process in src_install
-	sed '/RERUN/,+1d' -i "${BUILD_DIR}"/build.ninja || die
-}
-
-src_install() {
-	cmake_src_install
-
-	insinto "/var/lib/${PN}"
-	doins "${BUILD_DIR}"/CMakeCache.txt
-
-	rm -rf python
-	mkdir -p python/torch/include || die
-	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
-	if use cuda || use rocm; then
-		mv "${ED}${S}"/nvfuser python/nvfuser || die
-		mv "${ED}"/usr/$(get_libdir)/nvfuser.so python/nvfuser/_C.so || die
-	fi
-	cp torch/version.py python/torch/ || die
-	python_domodule python/caffe2
-	python_domodule python/torch
-	ln -s ../../../../../include/torch \
-		"${D}$(python_get_sitedir)"/torch/include/torch || die # bug 923269
-	if use cuda || use rocm; then
-		python_domodule python/nvfuser
-	fi
-	rm -rf "${ED}${WORKDIR}"
-	find "${ED}" -empty -delete
-}

diff --git a/sci-libs/caffe2/files/caffe2-2.1.1-cudaExtra.patch b/sci-libs/caffe2/files/caffe2-2.1.1-cudaExtra.patch
deleted file mode 100644
index f12623f2068a..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.1.1-cudaExtra.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- a/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:42:07.336946970 +0100
-+++ b/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:46:35.101749250 +0100
-@@ -18,7 +18,7 @@
- set(NVFUSER_ROOT ${PROJECT_SOURCE_DIR})
- set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc")
- set(TORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
--set(TORCH_INSTALL_LIB_DIR ${TORCH_ROOT}/torch/lib)
-+set(TORCH_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
- 
- # --- build nvfuser_codegen library
- 
-@@ -218,7 +218,7 @@
-     message(STATUS "somehow this is happening")
-     set_target_properties(${NVFUSER} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
-   endif()
--  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION ${TORCH_ROOT}/nvfuser/)
-+  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
- 
-   # install nvfuser python files
-   install(DIRECTORY "${NVFUSER_ROOT}/python/"
---- a/functorch/CMakeLists.txt	2023-11-30 20:30:45.805209036 +0100
-+++ b/functorch/CMakeLists.txt	2023-11-30 20:31:13.284766157 +0100
-@@ -35,4 +35,4 @@
- if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
-   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
- endif()
--install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
-+install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")

diff --git a/sci-libs/caffe2/files/caffe2-2.1.1-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.1.1-gentoo.patch
deleted file mode 100644
index 056ac9afe5b3..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.1.1-gentoo.patch
+++ /dev/null
@@ -1,188 +0,0 @@
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -487,7 +487,7 @@ endif()
- list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
- 
- # ---[ QNNPACK
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
- 
-   if(NOT DEFINED QNNPACK_SOURCE_DIR)
-@@ -543,7 +543,7 @@ if(USE_QNNPACK)
- endif()
- 
- # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
-@@ -803,7 +803,7 @@
- endif()
- 
- # ---[ FBGEMM
--if(USE_FBGEMM)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   if(NOT DEFINED FBGEMM_SOURCE_DIR)
-     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
-@@ -848,6 +848,7 @@
- endif()
- 
- if(USE_FBGEMM)
-+  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
-   caffe2_update_option(USE_FBGEMM ON)
- else()
-   caffe2_update_option(USE_FBGEMM OFF)
-@@ -1552,7 +1553,6 @@
-       set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
-     endif()
-   endif()
--  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
- 
-   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
-   if(NOT USE_SYSTEM_ONNX)
-@@ -1831,7 +1831,6 @@
- #
- set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
- set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
--add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
- 
- # Disable compiler feature checks for `fmt`.
- #
-@@ -1840,9 +1839,7 @@
- # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
- # `fmt` is compatible with a superset of the compilers that PyTorch is, it
- # shouldn't be too bad to just disable the checks.
--set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
- 
--list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
- set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
- 
- # ---[ Kineto
---- a/c10/CMakeLists.txt
-+++ b/c10/CMakeLists.txt
-@@ -87,7 +87,7 @@
- if(${USE_GLOG})
-     target_link_libraries(c10 PUBLIC glog::glog)
- endif()
--target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
-+target_link_libraries(c10 PRIVATE fmt)
- 
- find_package(Backtrace)
- if(Backtrace_FOUND)
---- a/torch/CMakeLists.txt
-+++ b/torch/CMakeLists.txt
-@@ -63,15 +63,9 @@
-     ${CMAKE_BINARY_DIR}
-     ${CMAKE_BINARY_DIR}/aten/src
-     ${CMAKE_BINARY_DIR}/caffe2/aten/src
--    ${CMAKE_BINARY_DIR}/third_party
--    ${CMAKE_BINARY_DIR}/third_party/onnx
- 
--    ${TORCH_ROOT}/third_party/valgrind-headers
- 
--    ${TORCH_ROOT}/third_party/gloo
--    ${TORCH_ROOT}/third_party/onnx
--    ${TORCH_ROOT}/third_party/flatbuffers/include
--    ${TORCH_ROOT}/third_party/kineto/libkineto/include
-+    /usr/include/kineto
- 
-     ${TORCH_SRC_DIR}/csrc
-     ${TORCH_SRC_DIR}/csrc/api/include
-@@ -84,7 +78,6 @@
-     python::python
-     pybind::pybind11
-     shm
--    fmt::fmt-header-only
-     ATEN_CPU_FILES_GEN_LIB)
- 
- if(USE_ASAN AND TARGET Sanitizer::address)
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -812,12 +812,11 @@
- 
- # ---[ Build flags
- if(NOT MSVC)
--  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
-+  string(APPEND CMAKE_CXX_FLAGS " -fPIC")
-   # Eigen fails to build with some versions, so convert this to a warning
-   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
-   string(APPEND CMAKE_CXX_FLAGS " -Wall")
-   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
--  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
-@@ -917,8 +916,6 @@
-   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
-   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
- else()
-   # skip unwanted includes from windows.h
-   add_compile_definitions(WIN32_LEAN_AND_MEAN)
---- a/cmake/public/utils.cmake
-+++ b/cmake/public/utils.cmake
-@@ -492,8 +492,6 @@
-   endif()
- 
-   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
--  target_compile_options(${libname} PRIVATE
--      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
- 
- endfunction()
- 
---- a/cmake/Codegen.cmake
-+++ b/cmake/Codegen.cmake
-@@ -57,7 +57,7 @@
-   if(MSVC)
-     set(OPT_FLAG "/fp:strict ")
-   else(MSVC)
--    set(OPT_FLAG "-O3 ")
-+    set(OPT_FLAG " ")
-     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
-       set(OPT_FLAG " ")
-     endif()
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -107,7 +107,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 "")
-@@ -1023,7 +1025,6 @@
- endif()
- 
- if(NOT MSVC AND USE_XNNPACK)
--  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
- endif()
- 
- # ==========================================================
-@@ -1143,8 +1146,7 @@
- target_include_directories(torch_cpu PRIVATE
-   ${TORCH_ROOT}/third_party/miniz-2.1.0)
- 
--target_include_directories(torch_cpu PRIVATE
--  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
-+target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
- 
- if(USE_KINETO)
-   target_include_directories(torch_cpu PRIVATE
---- a/cmake/External/nnpack.cmake
-+++ b/cmake/External/nnpack.cmake
-@@ -58,7 +58,7 @@
-   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
-   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
- 
--  if(NOT TARGET nnpack)
-+  if(FALSE)
-     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
-       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
-     endif()

diff --git a/sci-libs/caffe2/metadata.xml b/sci-libs/caffe2/metadata.xml
index 43aee37ffc47..e99253402e7a 100644
--- a/sci-libs/caffe2/metadata.xml
+++ b/sci-libs/caffe2/metadata.xml
@@ -20,7 +20,6 @@
 		<flag name="openmp">Use OpenMP for parallel code</flag>
 		<flag name="qnnpack">Use QNNPACK</flag>
 		<flag name="rocm">Enable ROCm gpu computing support</flag>
-		<flag name="tensorpipe">Use tensorpipe</flag>
 		<flag name="xnnpack">Use XNNPACK</flag>
 	</use>
 	<upstream>


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-04-30 17:18 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-04-30 17:18 UTC (permalink / raw
  To: gentoo-commits

commit:     b49728b8d6e97c06ec2cbd9d5026f41a147e935e
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 30 17:17:20 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Tue Apr 30 17:17:20 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b49728b8

sci-libs/caffe2: add 2.3.0

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 +
 sci-libs/caffe2/caffe2-2.3.0.ebuild                | 270 +++++++++++++++++++++
 sci-libs/caffe2/files/caffe2-2.2.2-musl.patch      |  13 +
 sci-libs/caffe2/files/caffe2-2.3.0-CMakeFix.patch  |  11 +
 .../files/caffe2-2.3.0-cudnn_include_fix.patch     |  11 +
 .../files/caffe2-2.3.0-rocm-fix-std-cpp17.patch    |  68 ++++++
 6 files changed, 374 insertions(+)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index b72973ca6f63..f1df96691729 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,2 +1,3 @@
 DIST pytorch-2.1.2.tar.gz 116316469 BLAKE2B c5a55ee264bc3477d3556ba6376b5591117e992e56e0dd0c9ba93d12526e2727f7840f6f1e0730a38223b6492c9556840c4ebf22ffd220e97225c2abff303747 SHA512 a8961d78ad785b13c959a0612563a60e0de17a7c8bb9822ddea9a24072796354d07e81c47b6cc8761b21a6448845b088cf80e1661d9e889b0ed5474d3dc76756
 DIST pytorch-2.2.2.tar.gz 116367503 BLAKE2B 0be22f2ec4b9aac6f5e976664cae01facf07929a32565cd57d7cc5b2d9888e9ae71ca301853752fe8f31d174d04c9974eb9ed2f3d452360a50ccf024f200726a SHA512 7990e0f9484038c3458c0bda2c863bf2b19e56edab81fc5938c6e0f08b17558287f853bb67350e8cca8f42bec0f1d4ba0e94e50a145db8da44bdd4bd703d91d0
+DIST pytorch-2.3.0.tar.gz 117029829 BLAKE2B 8f9c0d71ee0a9219b495eddccdcc65107f7ad537c43c68100b229f3d27b0e6c01ccb1659c7fffc356a48d80f2adc0a10361305dc8f1df20446de837d380f89f6 SHA512 67f7e9a096c3ffb952206ebf9105bedebb68c24ad82456083adf1d1d210437fcaa9dd52b68484cfc97d408c9eebc9541c76868c34a7c9982494dc3f424cfb07c

diff --git a/sci-libs/caffe2/caffe2-2.3.0.ebuild b/sci-libs/caffe2/caffe2-2.3.0.ebuild
new file mode 100644
index 000000000000..c69c5e8fdb58
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-2.3.0.ebuild
@@ -0,0 +1,270 @@
+# Copyright 2022-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+ROCM_VERSION=5.7
+inherit python-single-r1 cmake cuda flag-o-matic prefix rocm
+
+MYPN=pytorch
+MYP=${MYPN}-${PV}
+
+DESCRIPTION="A deep learning framework"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
+	-> ${MYP}.tar.gz"
+
+S="${WORKDIR}"/${MYP}
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="cuda distributed fbgemm ffmpeg gloo mkl mpi nnpack +numpy onednn openblas opencl opencv openmp qnnpack rocm xnnpack"
+RESTRICT="test"
+REQUIRED_USE="
+	${PYTHON_REQUIRED_USE}
+	ffmpeg? ( opencv )
+	mpi? ( distributed )
+	gloo? ( distributed )
+	?? ( cuda rocm )
+	rocm? ( || ( ${ROCM_REQUIRED_USE} ) )
+"
+
+# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
+RDEPEND="
+	${PYTHON_DEPS}
+	dev-cpp/gflags:=
+	>=dev-cpp/glog-0.5.0
+	dev-libs/cpuinfo
+	dev-libs/libfmt
+	dev-libs/protobuf:=
+	dev-libs/pthreadpool
+	dev-libs/sleef
+	virtual/lapack
+	>=sci-libs/onnx-1.12.0
+	<sci-libs/onnx-1.15.0
+	sci-libs/foxi
+	cuda? (
+		=dev-libs/cudnn-8*
+		>=dev-libs/cudnn-frontend-1.0.3:0/8
+		<dev-util/nvidia-cuda-toolkit-12.4.0:=[profiler]
+	)
+	fbgemm? ( >=dev-libs/FBGEMM-2023.12.01 )
+	ffmpeg? ( media-video/ffmpeg:= )
+	gloo? ( sci-libs/gloo[cuda?] )
+	mpi? ( virtual/mpi )
+	nnpack? ( sci-libs/NNPACK )
+	numpy? ( $(python_gen_cond_dep '
+		dev-python/numpy[${PYTHON_USEDEP}]
+		') )
+	onednn? ( dev-libs/oneDNN )
+	opencl? ( virtual/opencl )
+	opencv? ( media-libs/opencv:= )
+	qnnpack? ( sci-libs/QNNPACK )
+	rocm? (
+		>=dev-util/hip-5.7
+		>=dev-libs/rccl-5.7[${ROCM_USEDEP}]
+		>=sci-libs/rocThrust-5.7[${ROCM_USEDEP}]
+		>=sci-libs/rocPRIM-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipBLAS-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipFFT-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipSPARSE-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipRAND-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipCUB-5.7[${ROCM_USEDEP}]
+		>=sci-libs/hipSOLVER-5.7[${ROCM_USEDEP}]
+		>=sci-libs/miopen-5.7[${ROCM_USEDEP}]
+		>=dev-util/roctracer-5.7[${ROCM_USEDEP}]
+	)
+	distributed? ( sci-libs/tensorpipe[cuda?] )
+	xnnpack? ( >=sci-libs/XNNPACK-2022.12.22 )
+	mkl? ( sci-libs/mkl )
+	openblas? ( sci-libs/openblas )
+"
+DEPEND="
+	${RDEPEND}
+	cuda? ( >=dev-libs/cutlass-3.4.1 )
+	onednn? ( sci-libs/ideep )
+	dev-libs/psimd
+	dev-libs/FP16
+	dev-libs/FXdiv
+	dev-libs/pocketfft
+	dev-libs/flatbuffers
+	>=sci-libs/kineto-0.4.0_p20231031
+	$(python_gen_cond_dep '
+		dev-python/pyyaml[${PYTHON_USEDEP}]
+		dev-python/pybind11[${PYTHON_USEDEP}]
+	')
+"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-2.2.1-gentoo.patch
+	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
+	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
+	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
+	"${FILESDIR}"/${P}-cudnn_include_fix.patch
+	"${FILESDIR}"/${PN}-2.1.2-fix-rpath.patch
+	"${FILESDIR}"/${PN}-2.1.2-fix-openmp-link.patch
+	"${FILESDIR}"/${P}-rocm-fix-std-cpp17.patch
+	"${FILESDIR}"/${PN}-2.2.2-musl.patch
+	"${FILESDIR}"/${P}-CMakeFix.patch
+)
+
+src_prepare() {
+	filter-lto #bug 862672
+	sed -i \
+		-e "/third_party\/gloo/d" \
+		cmake/Dependencies.cmake \
+		|| 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 \
+		caffe2/CMakeLists.txt \
+		cmake/Metal.cmake \
+		cmake/Modules/*.cmake \
+		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
+		cmake/public/LoadHIP.cmake \
+		cmake/public/cuda.cmake \
+		cmake/Dependencies.cmake \
+		torch/CMakeLists.txt \
+		CMakeLists.txt
+
+	if use rocm; then
+		sed -e "s:/opt/rocm:/usr:" \
+			-e "s:lib/cmake:$(get_libdir)/cmake:g" \
+			-e "s/HIP 1.0/HIP 1.0 REQUIRED/" \
+			-i cmake/public/LoadHIP.cmake || die
+
+		ebegin "HIPifying cuda sources"
+		${EPYTHON} tools/amd_build/build_amd.py || die
+		eend $?
+	fi
+}
+
+src_configure() {
+	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
+		ewarn "These may not be optimal for your GPU."
+		ewarn ""
+		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
+		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
+		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
+		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
+		ewarn ""
+		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
+		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
+	fi
+
+	local mycmakeargs=(
+		-DBUILD_CUSTOM_PROTOBUF=OFF
+		-DBUILD_SHARED_LIBS=ON
+
+		-DUSE_CCACHE=OFF
+		-DUSE_CUDA=$(usex cuda)
+		-DUSE_DISTRIBUTED=$(usex distributed)
+		-DUSE_MPI=$(usex mpi)
+		-DUSE_FAKELOWP=OFF
+		-DUSE_FBGEMM=$(usex fbgemm)
+		-DUSE_FFMPEG=$(usex ffmpeg)
+		-DUSE_GFLAGS=ON
+		-DUSE_GLOG=ON
+		-DUSE_GLOO=$(usex gloo)
+		-DUSE_KINETO=OFF # TODO
+		-DUSE_LEVELDB=OFF
+		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
+		-DUSE_MKLDNN=$(usex onednn)
+		-DUSE_NNPACK=$(usex nnpack)
+		-DUSE_QNNPACK=$(usex qnnpack)
+		-DUSE_XNNPACK=$(usex xnnpack)
+		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
+		-DUSE_TENSORPIPE=$(usex distributed)
+		-DUSE_PYTORCH_QNNPACK=OFF
+		-DUSE_NUMPY=$(usex numpy)
+		-DUSE_OPENCL=$(usex opencl)
+		-DUSE_OPENCV=$(usex opencv)
+		-DUSE_OPENMP=$(usex openmp)
+		-DUSE_ROCM=$(usex rocm)
+		-DUSE_SYSTEM_CPUINFO=ON
+		-DUSE_SYSTEM_PYBIND11=ON
+		-DUSE_UCC=OFF
+		-DUSE_VALGRIND=OFF
+		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
+		-DPYTHON_EXECUTABLE="${PYTHON}"
+		-DUSE_ITT=OFF
+		-DUSE_SYSTEM_PTHREADPOOL=ON
+		-DUSE_SYSTEM_FXDIV=ON
+		-DUSE_SYSTEM_FP16=ON
+		-DUSE_SYSTEM_GLOO=ON
+		-DUSE_SYSTEM_ONNX=ON
+		-DUSE_SYSTEM_SLEEF=ON
+		-DUSE_METAL=OFF
+
+		-Wno-dev
+		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
+		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
+	)
+
+	if use mkl; then
+		mycmakeargs+=(-DBLAS=MKL)
+	elif use openblas; then
+		mycmakeargs+=(-DBLAS=OpenBLAS)
+	else
+		mycmakeargs+=(-DBLAS=Generic -DBLAS_LIBRARIES=)
+	fi
+
+	if use cuda; then
+		addpredict "/dev/nvidiactl" # bug 867706
+		addpredict "/dev/char"
+		addpredict "/proc/self/task" # bug 926116
+
+		mycmakeargs+=(
+			-DUSE_CUDNN=ON
+			-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
+			-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
+			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
+		)
+	elif use rocm; then
+		export PYTORCH_ROCM_ARCH="$(get_amdgpu_flags)"
+
+		mycmakeargs+=(
+			-DUSE_NCCL=ON
+			-DUSE_SYSTEM_NCCL=ON
+		)
+	fi
+
+	if use onednn; then
+		mycmakeargs+=(
+			-DUSE_MKLDNN=ON
+			-DMKLDNN_FOUND=ON
+			-DMKLDNN_LIBRARIES=dnnl
+			-DMKLDNN_INCLUDE_DIR="${ESYSROOT}/usr/include/oneapi/dnnl"
+		)
+	fi
+
+	cmake_src_configure
+
+	# do not rerun cmake and the build process in src_install
+	sed '/RERUN/,+1d' -i "${BUILD_DIR}"/build.ninja || die
+}
+
+src_install() {
+	cmake_src_install
+
+	insinto "/var/lib/${PN}"
+	doins "${BUILD_DIR}"/CMakeCache.txt
+
+	rm -rf python
+	mkdir -p python/torch/include || die
+	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
+	cp torch/version.py python/torch/ || die
+	python_domodule python/caffe2
+	python_domodule python/torch
+	ln -s ../../../../../include/torch \
+		"${D}$(python_get_sitedir)"/torch/include/torch || die # bug 923269
+}

diff --git a/sci-libs/caffe2/files/caffe2-2.2.2-musl.patch b/sci-libs/caffe2/files/caffe2-2.2.2-musl.patch
new file mode 100644
index 000000000000..f63e9f1df332
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.2.2-musl.patch
@@ -0,0 +1,13 @@
+--- a/torch/csrc/profiler/unwind/unwind.cpp	2024-04-29 12:05:40.895667482 +0200
++++ b/torch/csrc/profiler/unwind/unwind.cpp	2024-04-29 12:05:53.099524760 +0200
+@@ -112,8 +112,8 @@
+ }
+ 
+ struct Version {
+-  uint64_t adds_ = LONG_LONG_MAX;
+-  uint64_t subs_ = LONG_LONG_MAX;
++  uint64_t adds_ = LLONG_MAX;
++  uint64_t subs_ = LLONG_MAX;
+ };
+ 
+ struct UnwindCache {

diff --git a/sci-libs/caffe2/files/caffe2-2.3.0-CMakeFix.patch b/sci-libs/caffe2/files/caffe2-2.3.0-CMakeFix.patch
new file mode 100644
index 000000000000..eba37d933cac
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.3.0-CMakeFix.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt	2024-04-29 20:32:26.259716769 +0200
++++ b/CMakeLists.txt	2024-04-29 20:32:35.886384618 +0200
+@@ -50,7 +50,7 @@
+ 
+ # This define is needed to preserve behavior given anticpated changes to cccl/thrust
+ # https://nvidia.github.io/libcudacxx/standard_api/numerics_library/complex.html
+-string(APPEND CMAKE_CUDA_FLAGS "-DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS")
++string(APPEND CMAKE_CUDA_FLAGS " -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS")
+ 
+ if(LINUX)
+   include(cmake/CheckAbi.cmake)

diff --git a/sci-libs/caffe2/files/caffe2-2.3.0-cudnn_include_fix.patch b/sci-libs/caffe2/files/caffe2-2.3.0-cudnn_include_fix.patch
new file mode 100644
index 000000000000..77905dbd1ac8
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.3.0-cudnn_include_fix.patch
@@ -0,0 +1,11 @@
+--- a/cmake/Dependencies.cmake	2024-04-29 18:37:34.005639858 +0200
++++ b/cmake/Dependencies.cmake	2024-04-29 18:39:29.126587738 +0200
+@@ -1235,7 +1235,7 @@
+   if(CUDNN_VERSION VERSION_LESS 8.5)
+     message(FATAL_ERROR "PyTorch needs CuDNN-8.5 or above, but found ${CUDNN_VERSION}. Builds are still possible with `USE_CUDNN=0`")
+   endif()
+-  set(CUDNN_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../third_party/cudnn_frontend/include)
++  set(CUDNN_FRONTEND_INCLUDE_DIR /opt/cuda/include)
+   target_include_directories(torch::cudnn INTERFACE ${CUDNN_FRONTEND_INCLUDE_DIR})
+ endif()
+ 

diff --git a/sci-libs/caffe2/files/caffe2-2.3.0-rocm-fix-std-cpp17.patch b/sci-libs/caffe2/files/caffe2-2.3.0-rocm-fix-std-cpp17.patch
new file mode 100644
index 000000000000..127a31e4b225
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.3.0-rocm-fix-std-cpp17.patch
@@ -0,0 +1,68 @@
+Fix for error: invalid argument '-std=c++17' not allowed with 'C'
+https://github.com/pytorch/pytorch/issues/103222
+--- a/c10/hip/CMakeLists.txt
++++ b/c10/hip/CMakeLists.txt
+@@ -30,6 +30,7 @@ hip_add_library(c10_hip ${C10_HIP_SRCS} ${C10_HIP_HEADERS})
+ 
+ # Propagate HIP_CXX_FLAGS that were set from Dependencies.cmake
+ target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})
++set_target_properties(c10_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+ 
+ # caffe2_hip adds a bunch of dependencies like rocsparse, but c10/hip is supposed to be
+ # minimal.  I'm not sure if we need hip_hcc or not; for now leave it out
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -1712,6 +1712,7 @@ if(USE_ROCM)
+ 
+   # Since PyTorch files contain HIP headers, these flags are required for the necessary definitions to be added.
+   target_compile_options(torch_hip PUBLIC ${HIP_CXX_FLAGS})  # experiment
++  set_target_properties(torch_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+   target_link_libraries(torch_hip PUBLIC c10_hip)
+ 
+   if(NOT INTERN_BUILD_MOBILE)
+@@ -1908,6 +1909,7 @@ if(BUILD_TEST)
+       target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
+       target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
+       target_compile_options(${test_name} PRIVATE ${HIP_CXX_FLAGS})
++      set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+       add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
+       if(INSTALL_TEST)
+         install(TARGETS ${test_name} DESTINATION test)
+@@ -2092,6 +2094,7 @@ if(BUILD_PYTHON)
+     endif()
+     if(NOT MSVC)
+       target_compile_options(caffe2_pybind11_state_hip PRIVATE ${HIP_CXX_FLAGS} -fvisibility=hidden)
++      set_target_properties(caffe2_pybind11_state_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+     endif()
+     set_target_properties(caffe2_pybind11_state_hip PROPERTIES PREFIX "")
+     set_target_properties(caffe2_pybind11_state_hip PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -1278,7 +1278,6 @@
+     list(APPEND HIP_CXX_FLAGS -Wno-duplicate-decl-specifier)
+     list(APPEND HIP_CXX_FLAGS -DCAFFE2_USE_MIOPEN)
+     list(APPEND HIP_CXX_FLAGS -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP)
+-    list(APPEND HIP_CXX_FLAGS -std=c++17)
+     if(ROCM_VERSION_DEV VERSION_GREATER_EQUAL "6.0.0")
+       list(APPEND HIP_CXX_FLAGS -DHIPBLAS_V2)
+     endif()
+--- a/cmake/public/utils.cmake
++++ b/cmake/public/utils.cmake
+@@ -335,6 +335,7 @@ function(caffe2_hip_binary_target target_name_or_src)
+   caffe2_binary_target(${target_name_or_src})
+ 
+   target_compile_options(${__target} PRIVATE ${HIP_CXX_FLAGS})
++  set_target_properties(${__target} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+   target_include_directories(${__target} PRIVATE ${Caffe2_HIP_INCLUDE})
+ endfunction()
+ 
+--- a/modules/detectron/CMakeLists.txt
++++ b/modules/detectron/CMakeLists.txt
+@@ -31,6 +31,7 @@ if(BUILD_CAFFE2_OPS)
+         ${Detectron_CPU_SRCS}
+         ${Detectron_HIP_SRCS})
+     target_compile_options(caffe2_detectron_ops_hip PRIVATE ${HIP_CXX_FLAGS})
++    set_target_properties(caffe2_detectron_ops_hip PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF)
+     if(USE_MKLDNN)
+       target_link_libraries(caffe2_detectron_ops_hip PRIVATE caffe2::mkldnn)
+     endif()


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2024-03-22 20:54 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2024-03-22 20:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1d5ccecbb03d065f91980bce649a4981e2e6cc42
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 20:47:29 2024 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 20:47:29 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d5ccecb

sci-libs/caffe2: drop 1.13.1-r6, 2.0.1-r5

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   2 -
 sci-libs/caffe2/caffe2-1.13.1-r6.ebuild            | 194 -----------------
 sci-libs/caffe2/caffe2-2.0.1-r5.ebuild             | 211 ------------------
 sci-libs/caffe2/files/caffe2-1.12.0-clang.patch    |  42 ----
 sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch   | 239 ---------------------
 sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch    | 204 ------------------
 sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch |  28 ---
 7 files changed, 920 deletions(-)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index 2a63d8018442..09e1f64fbe4c 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,4 +1,2 @@
-DIST pytorch-1.13.1.tar.gz 108279745 BLAKE2B 75de03b74dfdaf8d8fb5ea743fcc0c1b0e408a714ad4160c487921220a7b1755e5fa6e587e6bbc8c9f34dd75e096d2e6dd69c80d24821835fff6c833314434d3 SHA512 f16f89d027efade11d057245cad5b69a390e88b458398310ae30de2dbff7c8fd7f1165be7b8da7ea989c81ac3f5a66c5cb9050610e441a97c83fb8aa28c0bd62
-DIST pytorch-2.0.1.tar.gz 111335778 BLAKE2B 7a10cc2b2d5e2422aef7e060a0c3a62ca5c7460c6e0b9becade9b98939501975c74ed5a175a653731f43ca824d2c9bd31f41d1f633c2b139779ab23d5331e9ce SHA512 2309a22b3be3ccdb36d8d9781a59a7bdcc2fdb8d95ada205702ec77862480f0cbb12cd5d6b8cd3114d01a6e33b7743d0fe9de93debf37138ca5c14403cdb0c43
 DIST pytorch-2.1.2.tar.gz 116316469 BLAKE2B c5a55ee264bc3477d3556ba6376b5591117e992e56e0dd0c9ba93d12526e2727f7840f6f1e0730a38223b6492c9556840c4ebf22ffd220e97225c2abff303747 SHA512 a8961d78ad785b13c959a0612563a60e0de17a7c8bb9822ddea9a24072796354d07e81c47b6cc8761b21a6448845b088cf80e1661d9e889b0ed5474d3dc76756
 DIST pytorch-2.2.1.tar.gz 116370903 BLAKE2B 7d08e80f91bad76fba1751c30a34bebfe7145058b7758c0d47112702263a80666f70687a8860744725c6aa995e854f766a5bfa4644c23e5635e7e08c8d63a6e9 SHA512 f19ebcf59d183c3348946ba7cfcab2bc4ca93785863b8edc39dba5772083a7b0425ccb4f92a8df4dc0d18246c75e8ff812993161467fbf9dc48d7fb28a1e26f1

diff --git a/sci-libs/caffe2/caffe2-1.13.1-r6.ebuild b/sci-libs/caffe2/caffe2-1.13.1-r6.ebuild
deleted file mode 100644
index 1a1184178b12..000000000000
--- a/sci-libs/caffe2/caffe2-1.13.1-r6.ebuild
+++ /dev/null
@@ -1,194 +0,0 @@
-# Copyright 2022-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-PYTHON_COMPAT=( python3_{9..11} )
-inherit python-single-r1 cmake cuda flag-o-matic
-
-MYPN=pytorch
-MYP=${MYPN}-${PV}
-
-DESCRIPTION="A deep learning framework"
-HOMEPAGE="https://pytorch.org/"
-SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
-	-> ${MYP}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64"
-IUSE="cuda distributed fbgemm ffmpeg gloo mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
-RESTRICT="test"
-REQUIRED_USE="
-	${PYTHON_REQUIRED_USE}
-	ffmpeg? ( opencv )
-	mpi? ( distributed )
-	tensorpipe? ( distributed )
-	gloo? ( distributed )
-" # ?? ( cuda rocm )
-
-# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
-RDEPEND="
-	${PYTHON_DEPS}
-	dev-cpp/gflags:=
-	>=dev-cpp/glog-0.5.0
-	dev-libs/cpuinfo
-	dev-libs/libfmt
-	dev-libs/protobuf:=
-	dev-libs/pthreadpool
-	dev-libs/sleef
-	sci-libs/lapack
-	>=sci-libs/onnx-1.12.0
-	<sci-libs/onnx-1.15.0
-	sci-libs/foxi
-	cuda? (
-		=dev-libs/cudnn-8*
-		dev-libs/cudnn-frontend:0/8
-		<dev-util/nvidia-cuda-toolkit-12:=[profiler]
-	)
-	fbgemm? ( dev-libs/FBGEMM )
-	ffmpeg? ( media-video/ffmpeg:= )
-	gloo? ( sci-libs/gloo[cuda?] )
-	mpi? ( sys-cluster/openmpi )
-	nnpack? ( sci-libs/NNPACK )
-	numpy? ( $(python_gen_cond_dep '
-		dev-python/numpy[${PYTHON_USEDEP}]
-		') )
-	opencl? ( virtual/opencl )
-	opencv? ( media-libs/opencv:= )
-	qnnpack? ( sci-libs/QNNPACK )
-	tensorpipe? ( sci-libs/tensorpipe )
-	xnnpack? ( sci-libs/XNNPACK )
-"
-DEPEND="
-	${RDEPEND}
-	dev-cpp/eigen
-	cuda? ( dev-libs/cutlass )
-	dev-libs/psimd
-	dev-libs/FP16
-	dev-libs/FXdiv
-	dev-libs/pocketfft
-	dev-libs/flatbuffers
-	sci-libs/kineto
-	$(python_gen_cond_dep '
-		dev-python/pyyaml[${PYTHON_USEDEP}]
-		dev-python/pybind11[${PYTHON_USEDEP}]
-	')
-"
-
-S="${WORKDIR}"/${MYP}
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-1.13.0-gentoo.patch
-	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
-	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
-	"${FILESDIR}"/${PN}-1.12.0-clang.patch
-	"${FILESDIR}"/${P}-tensorpipe.patch
-)
-
-src_prepare() {
-	filter-lto #bug 862672
-	sed -i \
-		-e "/third_party\/gloo/d" \
-		cmake/Dependencies.cmake \
-		|| die
-	cmake_src_prepare
-	pushd torch/csrc/jit/serialization || die
-	flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
-	popd
-}
-
-src_configure() {
-	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
-		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
-		ewarn "These may not be optimal for your GPU."
-		ewarn ""
-		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
-		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
-		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5,3.5"
-		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
-		ewarn ""
-		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
-		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
-	fi
-
-	local mycmakeargs=(
-		-DBUILD_CUSTOM_PROTOBUF=OFF
-		-DBUILD_SHARED_LIBS=ON
-
-		-DUSE_CCACHE=OFF
-		-DUSE_CUDA=$(usex cuda)
-		-DUSE_CUDNN=$(usex cuda)
-		-DUSE_FAST_NVCC=$(usex cuda)
-		-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
-		-DUSE_DISTRIBUTED=$(usex distributed)
-		-DUSE_MPI=$(usex mpi)
-		-DUSE_FAKELOWP=OFF
-		-DUSE_FBGEMM=$(usex fbgemm)
-		-DUSE_FFMPEG=$(usex ffmpeg)
-		-DUSE_GFLAGS=ON
-		-DUSE_GLOG=ON
-		-DUSE_GLOO=$(usex gloo)
-		-DUSE_KINETO=OFF # TODO
-		-DUSE_LEVELDB=OFF
-		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
-		-DUSE_MKLDNN=OFF
-		-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
-		-DUSE_NNPACK=$(usex nnpack)
-		-DUSE_QNNPACK=$(usex qnnpack)
-		-DUSE_XNNPACK=$(usex xnnpack)
-		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
-		-DUSE_TENSORPIPE=$(usex tensorpipe)
-		-DUSE_PYTORCH_QNNPACK=OFF
-		-DUSE_NUMPY=$(usex numpy)
-		-DUSE_OPENCL=$(usex opencl)
-		-DUSE_OPENCV=$(usex opencv)
-		-DUSE_OPENMP=$(usex openmp)
-		-DUSE_ROCM=OFF # TODO
-		-DUSE_SYSTEM_CPUINFO=ON
-		-DUSE_SYSTEM_PYBIND11=ON
-		-DUSE_UCC=OFF
-		-DUSE_VALGRIND=OFF
-		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
-		-DPYTHON_EXECUTABLE="${PYTHON}"
-		-DUSE_ITT=OFF
-		-DBLAS=Eigen # avoid the use of MKL, if found on the system
-		-DUSE_SYSTEM_EIGEN_INSTALL=ON
-		-DUSE_SYSTEM_PTHREADPOOL=ON
-		-DUSE_SYSTEM_FXDIV=ON
-		-DUSE_SYSTEM_FP16=ON
-		-DUSE_SYSTEM_GLOO=ON
-		-DUSE_SYSTEM_ONNX=ON
-		-DUSE_SYSTEM_SLEEF=ON
-
-		-Wno-dev
-		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
-		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
-	)
-
-	if use cuda; then
-		addpredict "/dev/nvidiactl" # bug 867706
-		addpredict "/dev/char"
-
-		mycmakeargs+=(
-			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
-		)
-	fi
-	cmake_src_configure
-}
-
-src_install() {
-	cmake_src_install
-
-	insinto "/var/lib/${PN}"
-	doins "${BUILD_DIR}"/CMakeCache.txt
-
-	rm -rf python
-	mkdir -p python/torch/include || die
-	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
-	mv "${ED}"/usr/include/torch python/torch/include || die
-	cp torch/version.py python/torch/ || die
-	rm -rf "${ED}"/var/tmp || die
-	python_domodule python/caffe2
-	python_domodule python/torch
-}

diff --git a/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild b/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild
deleted file mode 100644
index ca31c211469b..000000000000
--- a/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild
+++ /dev/null
@@ -1,211 +0,0 @@
-# Copyright 2022-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-PYTHON_COMPAT=( python3_{9..11} )
-inherit python-single-r1 cmake cuda flag-o-matic prefix
-
-MYPN=pytorch
-MYP=${MYPN}-${PV}
-
-DESCRIPTION="A deep learning framework"
-HOMEPAGE="https://pytorch.org/"
-SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
-	-> ${MYP}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64"
-IUSE="cuda distributed fbgemm ffmpeg gloo mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
-RESTRICT="test"
-REQUIRED_USE="
-	${PYTHON_REQUIRED_USE}
-	ffmpeg? ( opencv )
-	mpi? ( distributed )
-	tensorpipe? ( distributed )
-	distributed? ( tensorpipe )
-	gloo? ( distributed )
-" # ?? ( cuda rocm )
-
-# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
-RDEPEND="
-	${PYTHON_DEPS}
-	dev-cpp/gflags:=
-	>=dev-cpp/glog-0.5.0
-	dev-libs/cpuinfo
-	dev-libs/libfmt
-	dev-libs/protobuf:=
-	dev-libs/pthreadpool
-	dev-libs/sleef
-	sci-libs/lapack
-	>=sci-libs/onnx-1.12.0
-	<sci-libs/onnx-1.15.0
-	sci-libs/foxi
-	cuda? (
-		=dev-libs/cudnn-8*
-		dev-libs/cudnn-frontend:0/8
-		<dev-util/nvidia-cuda-toolkit-12:=[profiler]
-	)
-	fbgemm? ( dev-libs/FBGEMM )
-	ffmpeg? ( media-video/ffmpeg:= )
-	gloo? ( sci-libs/gloo[cuda?] )
-	mpi? ( virtual/mpi )
-	nnpack? ( sci-libs/NNPACK )
-	numpy? ( $(python_gen_cond_dep '
-		dev-python/numpy[${PYTHON_USEDEP}]
-		') )
-	opencl? ( virtual/opencl )
-	opencv? ( media-libs/opencv:= )
-	qnnpack? ( sci-libs/QNNPACK )
-	tensorpipe? ( sci-libs/tensorpipe[cuda?] )
-	xnnpack? ( >=sci-libs/XNNPACK-2022.12.22 )
-"
-DEPEND="
-	${RDEPEND}
-	dev-cpp/eigen
-	cuda? ( dev-libs/cutlass )
-	dev-libs/psimd
-	dev-libs/FP16
-	dev-libs/FXdiv
-	dev-libs/pocketfft
-	dev-libs/flatbuffers
-	sci-libs/kineto
-	$(python_gen_cond_dep '
-		dev-python/pyyaml[${PYTHON_USEDEP}]
-		dev-python/pybind11[${PYTHON_USEDEP}]
-	')
-"
-
-S="${WORKDIR}"/${MYP}
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-2.0.0-gentoo.patch
-	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
-	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
-	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
-	"${FILESDIR}"/${PN}-2.0.0-gcc13.patch
-	"${FILESDIR}"/${PN}-2.0.0-cudnn_include_fix.patch
-	"${FILESDIR}"/${P}-cudaExtra.patch
-)
-
-src_prepare() {
-	filter-lto #bug 862672
-	sed -i \
-		-e "/third_party\/gloo/d" \
-		cmake/Dependencies.cmake \
-		|| 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 \
-		caffe2/CMakeLists.txt \
-		cmake/Metal.cmake \
-		cmake/Modules/*.cmake \
-		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
-		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
-		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
-		cmake/public/LoadHIP.cmake \
-		cmake/public/cuda.cmake \
-		cmake/Dependencies.cmake \
-		torch/CMakeLists.txt \
-		CMakeLists.txt
-}
-
-src_configure() {
-	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
-		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
-		ewarn "These may not be optimal for your GPU."
-		ewarn ""
-		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
-		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
-		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
-		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
-		ewarn ""
-		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
-		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
-	fi
-
-	local mycmakeargs=(
-		-DBUILD_CUSTOM_PROTOBUF=OFF
-		-DBUILD_SHARED_LIBS=ON
-
-		-DUSE_CCACHE=OFF
-		-DUSE_CUDA=$(usex cuda)
-		-DUSE_CUDNN=$(usex cuda)
-		-DUSE_FAST_NVCC=$(usex cuda)
-		-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
-		-DBUILD_NVFUSER=$(usex cuda)
-		-DUSE_DISTRIBUTED=$(usex distributed)
-		-DUSE_MPI=$(usex mpi)
-		-DUSE_FAKELOWP=OFF
-		-DUSE_FBGEMM=$(usex fbgemm)
-		-DUSE_FFMPEG=$(usex ffmpeg)
-		-DUSE_GFLAGS=ON
-		-DUSE_GLOG=ON
-		-DUSE_GLOO=$(usex gloo)
-		-DUSE_KINETO=OFF # TODO
-		-DUSE_LEVELDB=OFF
-		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
-		-DUSE_MKLDNN=OFF
-		-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
-		-DUSE_NNPACK=$(usex nnpack)
-		-DUSE_QNNPACK=$(usex qnnpack)
-		-DUSE_XNNPACK=$(usex xnnpack)
-		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
-		-DUSE_TENSORPIPE=$(usex tensorpipe)
-		-DUSE_PYTORCH_QNNPACK=OFF
-		-DUSE_NUMPY=$(usex numpy)
-		-DUSE_OPENCL=$(usex opencl)
-		-DUSE_OPENCV=$(usex opencv)
-		-DUSE_OPENMP=$(usex openmp)
-		-DUSE_ROCM=OFF # TODO
-		-DUSE_SYSTEM_CPUINFO=ON
-		-DUSE_SYSTEM_PYBIND11=ON
-		-DUSE_UCC=OFF
-		-DUSE_VALGRIND=OFF
-		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
-		-DPYTHON_EXECUTABLE="${PYTHON}"
-		-DUSE_ITT=OFF
-		-DBLAS=Eigen # avoid the use of MKL, if found on the system
-		-DUSE_SYSTEM_EIGEN_INSTALL=ON
-		-DUSE_SYSTEM_PTHREADPOOL=ON
-		-DUSE_SYSTEM_FXDIV=ON
-		-DUSE_SYSTEM_FP16=ON
-		-DUSE_SYSTEM_GLOO=ON
-		-DUSE_SYSTEM_ONNX=ON
-		-DUSE_SYSTEM_SLEEF=ON
-
-		-Wno-dev
-		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
-		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
-	)
-
-	if use cuda; then
-		addpredict "/dev/nvidiactl" # bug 867706
-		addpredict "/dev/char"
-
-		mycmakeargs+=(
-			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
-		)
-	fi
-	cmake_src_configure
-}
-
-src_install() {
-	cmake_src_install
-
-	insinto "/var/lib/${PN}"
-	doins "${BUILD_DIR}"/CMakeCache.txt
-
-	rm -rf python
-	mkdir -p python/torch/include || die
-	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
-	mv "${ED}"/usr/include/torch python/torch/include || die
-	cp torch/version.py python/torch/ || die
-	python_domodule python/caffe2
-	python_domodule python/torch
-}

diff --git a/sci-libs/caffe2/files/caffe2-1.12.0-clang.patch b/sci-libs/caffe2/files/caffe2-1.12.0-clang.patch
deleted file mode 100644
index dd43b06a97a1..000000000000
--- a/sci-libs/caffe2/files/caffe2-1.12.0-clang.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From bfdc0358dc37c55af6118fe5d8b6ccd898e003fd Mon Sep 17 00:00:00 2001
-From: Kazuki Sakamoto <kaz@meta.com>
-Date: Wed, 21 Dec 2022 11:19:58 +0000
-Subject: [PATCH] Compile fix for Clang + libc++ (#91212)
-
-Summary:
-LLVM 15 has a compile issue with the deprecated __has_trivial_copy. Update the GCC ifdef logic to exclude Clang + libc++.
-
-```
-caffe2/c10/util/Optional.h:536:13: error: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Werror,-Wdeprecated-builtins]
-            C10_IS_TRIVIALLY_COPYABLE(T) &&
-            ^
-caffe2/c10/macros/Macros.h:438:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
-#define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
-```
-
-Test Plan: CI
-
-Reviewed By: kit1980
-
-Differential Revision: D42180203
-
-Pull Request resolved: https://github.com/pytorch/pytorch/pull/91212
-Approved by: https://github.com/kit1980, https://github.com/soumith
----
- c10/macros/Macros.h | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/c10/macros/Macros.h b/c10/macros/Macros.h
-index 9098a294228f4..09e57ca0a4d6a 100644
---- a/c10/macros/Macros.h
-+++ b/c10/macros/Macros.h
-@@ -434,7 +434,8 @@ __device__ __attribute__((noinline)) __attribute__((weak)) void __assert_fail(
- // Warning: __has_trivial_copy for GCC may not always detect the non-POD
- // correctly. For example, T = std::unique_ptr may evaluate to true and be
- // treated as POD. This can cause unexpected behavior.
--#if defined(__GNUG__) && __GNUC__ < 5
-+#if defined(__GNUG__) && __GNUC__ < 5 && \
-+    !(defined(__clang__) && defined(_LIBCPP_VERSION))
- #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
- #else
- #define C10_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value

diff --git a/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
deleted file mode 100644
index f72d44f475fa..000000000000
--- a/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
+++ /dev/null
@@ -1,239 +0,0 @@
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -481,7 +481,7 @@ endif()
- list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
- 
- # ---[ QNNPACK
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
- 
-   if(NOT DEFINED QNNPACK_SOURCE_DIR)
-@@ -537,7 +537,7 @@ if(USE_QNNPACK)
- endif()
- 
- # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
-@@ -789,7 +789,7 @@
- endif()
- 
- # ---[ FBGEMM
--if(USE_FBGEMM)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   if(NOT DEFINED FBGEMM_SOURCE_DIR)
-     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
-@@ -834,6 +834,7 @@
- endif()
- 
- if(USE_FBGEMM)
-+  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
-   caffe2_update_option(USE_FBGEMM ON)
- else()
-   caffe2_update_option(USE_FBGEMM OFF)
-@@ -1557,7 +1558,6 @@
-   if(NOT USE_SYSTEM_ONNX)
-     add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx EXCLUDE_FROM_ALL)
-   endif()
--  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
- 
-   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
-   if(NOT USE_SYSTEM_ONNX)
-@@ -1850,7 +1850,6 @@
- #
- set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
- set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
--add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
- 
- # Disable compiler feature checks for `fmt`.
- #
-@@ -1859,9 +1858,7 @@
- # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
- # `fmt` is compatible with a superset of the compilers that PyTorch is, it
- # shouldn't be too bad to just disable the checks.
--set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
- 
--list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
- set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
- 
- # ---[ Kineto
---- a/c10/CMakeLists.txt
-+++ b/c10/CMakeLists.txt
-@@ -64,7 +64,7 @@
- if(${USE_GLOG})
-     target_link_libraries(c10 PUBLIC glog::glog)
- endif()
--target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
-+target_link_libraries(c10 PRIVATE fmt)
- 
- find_package(Backtrace)
- if(Backtrace_FOUND)
---- a/torch/CMakeLists.txt
-+++ b/torch/CMakeLists.txt
-@@ -66,15 +66,9 @@
-     ${CMAKE_BINARY_DIR}
-     ${CMAKE_BINARY_DIR}/aten/src
-     ${CMAKE_BINARY_DIR}/caffe2/aten/src
--    ${CMAKE_BINARY_DIR}/third_party
--    ${CMAKE_BINARY_DIR}/third_party/onnx
- 
--    ${TORCH_ROOT}/third_party/valgrind-headers
- 
--    ${TORCH_ROOT}/third_party/gloo
--    ${TORCH_ROOT}/third_party/onnx
--    ${TORCH_ROOT}/third_party/flatbuffers/include
--    ${TORCH_ROOT}/third_party/kineto/libkineto/include
-+    /usr/include/kineto
- 
-     ${TORCH_SRC_DIR}/csrc
-     ${TORCH_SRC_DIR}/csrc/api/include
-@@ -87,7 +81,6 @@
-     python::python
-     pybind::pybind11
-     shm
--    fmt::fmt-header-only
-     ATEN_CPU_FILES_GEN_LIB)
- 
- set(TORCH_PYTHON_COMPILE_DEFINITIONS)
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -817,13 +817,12 @@
- 
- # ---[ Build flags
- if(NOT MSVC)
--  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
-+  string(APPEND CMAKE_CXX_FLAGS " -fPIC")
-   string(APPEND CMAKE_CXX_FLAGS " -Wno-narrowing")
-   # Eigen fails to build with some versions, so convert this to a warning
-   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
-   string(APPEND CMAKE_CXX_FLAGS " -Wall")
-   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
--  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Wno-missing-field-initializers" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Wno-type-limits" CMAKE_CXX_FLAGS)
-@@ -925,8 +924,6 @@
-   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
-   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
-   check_cxx_compiler_flag("-Werror=sign-compare" HAS_WERROR_SIGN_COMPARE)
-   # This doesn't work globally so we use the test on specific
-   # target_compile_options
---- a/cmake/public/utils.cmake
-+++ b/cmake/public/utils.cmake
-@@ -507,8 +507,6 @@
-   endif()
- 
-   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
--  target_compile_options(${libname} PRIVATE
--      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
- 
- endfunction()
- 
---- a/cmake/Codegen.cmake
-+++ b/cmake/Codegen.cmake
-@@ -57,7 +57,7 @@
-   if(MSVC)
-     set(OPT_FLAG "/fp:strict ")
-   else(MSVC)
--    set(OPT_FLAG "-O3 ")
-+    set(OPT_FLAG " ")
-     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
-       set(OPT_FLAG " ")
-     endif()
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -111,7 +111,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 "")
-@@ -537,7 +537,6 @@
- if(NOT MSVC)
-   set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_jit.cpp PROPERTIES COMPILE_FLAGS -Wno-noexcept-type)
-   # Force -Werror on several files
--  set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/mkldnn/Pooling.cpp PROPERTIES COMPILE_FLAGS "-Werror")
- endif()
- # Disable certain warnings for GCC-9.X
- if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0.0))
-@@ -825,7 +824,6 @@
- torch_compile_options(torch_cpu)  # see cmake/public/utils.cmake
- if(HAS_WERROR_SIGN_COMPARE AND WERROR)
-   # target_compile_options(torch_cpu PRIVATE "-Werror=sign-compare")
--  set_property(SOURCE ${ATen_CORE_SRCS} ${ATen_CPU_SRCS} APPEND PROPERTY COMPILE_OPTIONS "-Werror=sign-compare")
- endif()
- 
- set_property(SOURCE ${ATen_CORE_SRCS} APPEND
-@@ -1017,7 +1015,6 @@
- endif()
- 
- if(NOT MSVC AND USE_XNNPACK)
--  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
- endif()
- 
- # ==========================================================
-@@ -1136,8 +1133,7 @@
- target_include_directories(torch_cpu PRIVATE
-   ${TORCH_ROOT}/third_party/miniz-2.1.0)
- 
--target_include_directories(torch_cpu PRIVATE
--  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
-+target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
- 
- if(USE_KINETO)
-   target_include_directories(torch_cpu PRIVATE
---- a/cmake/External/nnpack.cmake
-+++ b/cmake/External/nnpack.cmake
-@@ -58,7 +58,7 @@
-   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
-   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
- 
--  if(NOT TARGET nnpack)
-+  if(FALSE)
-     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
-       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
-     endif()
---- a/torch/csrc/Exceptions.cpp	2023-02-13 12:46:54.447013004 +0100
-+++ b/torch/csrc/Exceptions.cpp	2023-02-13 12:50:18.433791791 +0100
-@@ -1,11 +1,10 @@
- #include <torch/csrc/Exceptions.h>
- #include <torch/csrc/python_headers.h>
- 
-+#include <array>
- #include <cstdarg>
- #include <exception>
--#include <sstream>
- #include <utility>
--#include <vector>
- 
- #include <fmt/format.h>
- #include <torch/csrc/THP.h>
-@@ -259,15 +258,12 @@
-       } else {
-         // Lets Python set the source location and puts the C++ warning
-         // location into the message.
--        fmt::memory_buffer buf;
--        fmt::format_to(
--            buf,
--            FMT_STRING("{} (Triggered internally at {}:{}.)"),
-+        auto buf = fmt::format(
-+            "{} (Triggered internally at {}:{}.)",
-             msg,
-             source_location.file,
-             source_location.line);
--        buf.push_back('\0');
--        result = PyErr_WarnEx(PyExc_UserWarning, buf.data(), 1);
-+        result = PyErr_WarnEx(PyExc_UserWarning, buf.c_str(), 1);
-       }
-       if (result < 0) {
-         if (in_exception_) {

diff --git a/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch
deleted file mode 100644
index fce7a395023e..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.0.0-gentoo.patch
+++ /dev/null
@@ -1,204 +0,0 @@
---- a/cmake/Dependencies.cmake
-+++ b/cmake/Dependencies.cmake
-@@ -486,7 +486,7 @@ endif()
- list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
- 
- # ---[ QNNPACK
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
- 
-   if(NOT DEFINED QNNPACK_SOURCE_DIR)
-@@ -542,7 +542,7 @@ if(USE_QNNPACK)
- endif()
- 
- # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
--if(USE_QNNPACK)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
-   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
-@@ -802,7 +802,7 @@
- endif()
- 
- # ---[ FBGEMM
--if(USE_FBGEMM)
-+if(FALSE)
-   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
-   if(NOT DEFINED FBGEMM_SOURCE_DIR)
-     set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory")
-@@ -847,6 +847,7 @@
- endif()
- 
- if(USE_FBGEMM)
-+  list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
-   caffe2_update_option(USE_FBGEMM ON)
- else()
-   caffe2_update_option(USE_FBGEMM OFF)
-@@ -1554,7 +1555,6 @@
-       set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
-     endif()
-   endif()
--  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
- 
-   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
-   if(NOT USE_SYSTEM_ONNX)
-@@ -1819,7 +1819,6 @@
- #
- set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
- set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
--add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
- 
- # Disable compiler feature checks for `fmt`.
- #
-@@ -1828,9 +1827,7 @@
- # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
- # `fmt` is compatible with a superset of the compilers that PyTorch is, it
- # shouldn't be too bad to just disable the checks.
--set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
- 
--list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
- set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
- 
- # ---[ Kineto
---- a/c10/CMakeLists.txt
-+++ b/c10/CMakeLists.txt
-@@ -65,7 +65,7 @@
- if(${USE_GLOG})
-     target_link_libraries(c10 PUBLIC glog::glog)
- endif()
--target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
-+target_link_libraries(c10 PRIVATE fmt)
- 
- find_package(Backtrace)
- if(Backtrace_FOUND)
---- a/torch/CMakeLists.txt
-+++ b/torch/CMakeLists.txt
-@@ -66,15 +66,9 @@
-     ${CMAKE_BINARY_DIR}
-     ${CMAKE_BINARY_DIR}/aten/src
-     ${CMAKE_BINARY_DIR}/caffe2/aten/src
--    ${CMAKE_BINARY_DIR}/third_party
--    ${CMAKE_BINARY_DIR}/third_party/onnx
- 
--    ${TORCH_ROOT}/third_party/valgrind-headers
- 
--    ${TORCH_ROOT}/third_party/gloo
--    ${TORCH_ROOT}/third_party/onnx
--    ${TORCH_ROOT}/third_party/flatbuffers/include
--    ${TORCH_ROOT}/third_party/kineto/libkineto/include
-+    /usr/include/kineto
- 
-     ${TORCH_SRC_DIR}/csrc
-     ${TORCH_SRC_DIR}/csrc/api/include
-@@ -87,7 +81,6 @@
-     python::python
-     pybind::pybind11
-     shm
--    fmt::fmt-header-only
-     ATEN_CPU_FILES_GEN_LIB)
- 
- set(TORCH_PYTHON_COMPILE_DEFINITIONS)
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -799,12 +799,11 @@
- 
- # ---[ Build flags
- if(NOT MSVC)
--  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
-+  string(APPEND CMAKE_CXX_FLAGS " -fPIC")
-   # Eigen fails to build with some versions, so convert this to a warning
-   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
-   string(APPEND CMAKE_CXX_FLAGS " -Wall")
-   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
--  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
-@@ -912,8 +911,6 @@
-   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
-   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
-   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
--  append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
- endif()
- 
- if(USE_ASAN)
---- a/cmake/public/utils.cmake
-+++ b/cmake/public/utils.cmake
-@@ -507,8 +507,6 @@
-   endif()
- 
-   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
--  target_compile_options(${libname} PRIVATE
--      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
- 
- endfunction()
- 
---- a/cmake/Codegen.cmake
-+++ b/cmake/Codegen.cmake
-@@ -57,7 +57,7 @@
-   if(MSVC)
-     set(OPT_FLAG "/fp:strict ")
-   else(MSVC)
--    set(OPT_FLAG "-O3 ")
-+    set(OPT_FLAG " ")
-     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
-       set(OPT_FLAG " ")
-     endif()
---- a/caffe2/CMakeLists.txt
-+++ b/caffe2/CMakeLists.txt
-@@ -106,7 +106,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 "")
-@@ -533,7 +533,6 @@
- if(NOT MSVC)
-   set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_jit.cpp PROPERTIES COMPILE_FLAGS -Wno-noexcept-type)
-   # Force -Werror on several files
--  set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/mkldnn/Pooling.cpp PROPERTIES COMPILE_FLAGS "-Werror")
- endif()
- # Disable certain warnings for GCC-9.X
- if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0.0))
-@@ -811,7 +812,6 @@
- torch_compile_options(torch_cpu)  # see cmake/public/utils.cmake
- if(HAS_WERROR_SIGN_COMPARE AND WERROR)
-   # target_compile_options(torch_cpu PRIVATE "-Werror=sign-compare")
--  set_property(SOURCE ${ATen_CORE_SRCS} ${ATen_CPU_SRCS} APPEND PROPERTY COMPILE_OPTIONS "-Werror=sign-compare")
- endif()
- 
- set_property(SOURCE ${ATen_CORE_SRCS} APPEND
-@@ -975,7 +977,6 @@
- endif()
- 
- if(NOT MSVC AND USE_XNNPACK)
--  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
- endif()
- 
- # ==========================================================
-@@ -1095,8 +1098,7 @@
- target_include_directories(torch_cpu PRIVATE
-   ${TORCH_ROOT}/third_party/miniz-2.1.0)
- 
--target_include_directories(torch_cpu PRIVATE
--  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
-+target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
- 
- if(USE_KINETO)
-   target_include_directories(torch_cpu PRIVATE
---- a/cmake/External/nnpack.cmake
-+++ b/cmake/External/nnpack.cmake
-@@ -58,7 +58,7 @@
-   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
-   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
- 
--  if(NOT TARGET nnpack)
-+  if(FALSE)
-     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
-       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
-     endif()

diff --git a/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch b/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch
deleted file mode 100644
index 2366c04c1b40..000000000000
--- a/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- a/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:42:07.336946970 +0100
-+++ b/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:46:35.101749250 +0100
-@@ -18,7 +18,7 @@
- set(NVFUSER_ROOT ${PROJECT_SOURCE_DIR})
- set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc")
- set(TORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
--set(TORCH_INSTALL_LIB_DIR ${TORCH_ROOT}/torch/lib)
-+set(TORCH_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
- 
- # --- build nvfuser_codegen library
- 
-@@ -213,7 +213,7 @@
-     message(STATUS "somehow this is happening")
-     set_target_properties(${NVFUSER} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
-   endif()
--  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION ${TORCH_ROOT}/nvfuser/)
-+  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
- endif()
- 
- # --- generate runtime files
---- a/functorch/CMakeLists.txt	2023-11-30 20:30:45.805209036 +0100
-+++ b/functorch/CMakeLists.txt	2023-11-30 20:31:13.284766157 +0100
-@@ -35,4 +35,4 @@
- if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
-   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
- endif()
--install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
-+install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2023-12-01  5:53 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2023-12-01  5:53 UTC (permalink / raw
  To: gentoo-commits

commit:     6066231bec8d7a83aff48ff16eb28e44eadd6ef4
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Fri Dec  1 05:52:18 2023 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Fri Dec  1 05:53:04 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6066231b

sci-libs/caffe2: install nvfuser and functorch files

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

 sci-libs/caffe2/caffe2-2.0.1-r5.ebuild             | 210 +++++++++++++++++++++
 sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch |  28 +++
 2 files changed, 238 insertions(+)

diff --git a/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild b/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild
new file mode 100644
index 000000000000..c062b38f1e86
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-2.0.1-r5.ebuild
@@ -0,0 +1,210 @@
+# Copyright 2022-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{9..11} )
+inherit python-single-r1 cmake cuda flag-o-matic prefix
+
+MYPN=pytorch
+MYP=${MYPN}-${PV}
+
+DESCRIPTION="A deep learning framework"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
+	-> ${MYP}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="cuda distributed fbgemm ffmpeg gloo mpi nnpack +numpy opencl opencv openmp qnnpack tensorpipe xnnpack"
+RESTRICT="test"
+REQUIRED_USE="
+	${PYTHON_REQUIRED_USE}
+	ffmpeg? ( opencv )
+	mpi? ( distributed )
+	tensorpipe? ( distributed )
+	distributed? ( tensorpipe )
+	gloo? ( distributed )
+" # ?? ( cuda rocm )
+
+# CUDA 12 not supported yet: https://github.com/pytorch/pytorch/issues/91122
+RDEPEND="
+	${PYTHON_DEPS}
+	dev-cpp/gflags:=
+	>=dev-cpp/glog-0.5.0
+	dev-libs/cpuinfo
+	dev-libs/libfmt
+	dev-libs/protobuf:=
+	dev-libs/pthreadpool
+	dev-libs/sleef
+	sci-libs/lapack
+	>=sci-libs/onnx-1.12.0
+	sci-libs/foxi
+	cuda? (
+		=dev-libs/cudnn-8*
+		dev-libs/cudnn-frontend:0/8
+		<dev-util/nvidia-cuda-toolkit-12:=[profiler]
+	)
+	fbgemm? ( dev-libs/FBGEMM )
+	ffmpeg? ( media-video/ffmpeg:= )
+	gloo? ( sci-libs/gloo[cuda?] )
+	mpi? ( virtual/mpi )
+	nnpack? ( sci-libs/NNPACK )
+	numpy? ( $(python_gen_cond_dep '
+		dev-python/numpy[${PYTHON_USEDEP}]
+		') )
+	opencl? ( virtual/opencl )
+	opencv? ( media-libs/opencv:= )
+	qnnpack? ( sci-libs/QNNPACK )
+	tensorpipe? ( sci-libs/tensorpipe[cuda?] )
+	xnnpack? ( >=sci-libs/XNNPACK-2022.12.22 )
+"
+DEPEND="
+	${RDEPEND}
+	dev-cpp/eigen
+	cuda? ( dev-libs/cutlass )
+	dev-libs/psimd
+	dev-libs/FP16
+	dev-libs/FXdiv
+	dev-libs/pocketfft
+	dev-libs/flatbuffers
+	sci-libs/kineto
+	$(python_gen_cond_dep '
+		dev-python/pyyaml[${PYTHON_USEDEP}]
+		dev-python/pybind11[${PYTHON_USEDEP}]
+	')
+"
+
+S="${WORKDIR}"/${MYP}
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-2.0.0-gentoo.patch
+	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
+	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
+	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
+	"${FILESDIR}"/${PN}-2.0.0-gcc13.patch
+	"${FILESDIR}"/${PN}-2.0.0-cudnn_include_fix.patch
+	"${FILESDIR}"/${P}-cudaExtra.patch
+)
+
+src_prepare() {
+	filter-lto #bug 862672
+	sed -i \
+		-e "/third_party\/gloo/d" \
+		cmake/Dependencies.cmake \
+		|| 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 \
+		caffe2/CMakeLists.txt \
+		cmake/Metal.cmake \
+		cmake/Modules/*.cmake \
+		cmake/Modules_CUDA_fix/FindCUDNN.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindCUDA/make2cmake.cmake \
+		cmake/Modules_CUDA_fix/upstream/FindPackageHandleStandardArgs.cmake \
+		cmake/public/LoadHIP.cmake \
+		cmake/public/cuda.cmake \
+		cmake/Dependencies.cmake \
+		torch/CMakeLists.txt \
+		CMakeLists.txt
+}
+
+src_configure() {
+	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
+		ewarn "These may not be optimal for your GPU."
+		ewarn ""
+		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
+		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
+		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5 3.5"
+		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
+		ewarn ""
+		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
+		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
+	fi
+
+	local mycmakeargs=(
+		-DBUILD_CUSTOM_PROTOBUF=OFF
+		-DBUILD_SHARED_LIBS=ON
+
+		-DUSE_CCACHE=OFF
+		-DUSE_CUDA=$(usex cuda)
+		-DUSE_CUDNN=$(usex cuda)
+		-DUSE_FAST_NVCC=$(usex cuda)
+		-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
+		-DBUILD_NVFUSER=$(usex cuda)
+		-DUSE_DISTRIBUTED=$(usex distributed)
+		-DUSE_MPI=$(usex mpi)
+		-DUSE_FAKELOWP=OFF
+		-DUSE_FBGEMM=$(usex fbgemm)
+		-DUSE_FFMPEG=$(usex ffmpeg)
+		-DUSE_GFLAGS=ON
+		-DUSE_GLOG=ON
+		-DUSE_GLOO=$(usex gloo)
+		-DUSE_KINETO=OFF # TODO
+		-DUSE_LEVELDB=OFF
+		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
+		-DUSE_MKLDNN=OFF
+		-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
+		-DUSE_NNPACK=$(usex nnpack)
+		-DUSE_QNNPACK=$(usex qnnpack)
+		-DUSE_XNNPACK=$(usex xnnpack)
+		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
+		-DUSE_TENSORPIPE=$(usex tensorpipe)
+		-DUSE_PYTORCH_QNNPACK=OFF
+		-DUSE_NUMPY=$(usex numpy)
+		-DUSE_OPENCL=$(usex opencl)
+		-DUSE_OPENCV=$(usex opencv)
+		-DUSE_OPENMP=$(usex openmp)
+		-DUSE_ROCM=OFF # TODO
+		-DUSE_SYSTEM_CPUINFO=ON
+		-DUSE_SYSTEM_PYBIND11=ON
+		-DUSE_UCC=OFF
+		-DUSE_VALGRIND=OFF
+		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
+		-DPYTHON_EXECUTABLE="${PYTHON}"
+		-DUSE_ITT=OFF
+		-DBLAS=Eigen # avoid the use of MKL, if found on the system
+		-DUSE_SYSTEM_EIGEN_INSTALL=ON
+		-DUSE_SYSTEM_PTHREADPOOL=ON
+		-DUSE_SYSTEM_FXDIV=ON
+		-DUSE_SYSTEM_FP16=ON
+		-DUSE_SYSTEM_GLOO=ON
+		-DUSE_SYSTEM_ONNX=ON
+		-DUSE_SYSTEM_SLEEF=ON
+
+		-Wno-dev
+		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
+		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
+	)
+
+	if use cuda; then
+		addpredict "/dev/nvidiactl" # bug 867706
+		addpredict "/dev/char"
+
+		mycmakeargs+=(
+			-DCMAKE_CUDA_FLAGS="$(cuda_gccdir -f | tr -d \")"
+		)
+	fi
+	cmake_src_configure
+}
+
+src_install() {
+	cmake_src_install
+
+	insinto "/var/lib/${PN}"
+	doins "${BUILD_DIR}"/CMakeCache.txt
+
+	rm -rf python
+	mkdir -p python/torch/include || die
+	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
+	mv "${ED}"/usr/include/torch python/torch/include || die
+	cp torch/version.py python/torch/ || die
+	python_domodule python/caffe2
+	python_domodule python/torch
+}

diff --git a/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch b/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch
new file mode 100644
index 000000000000..2366c04c1b40
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.0.1-cudaExtra.patch
@@ -0,0 +1,28 @@
+--- a/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:42:07.336946970 +0100
++++ b/third_party/nvfuser/CMakeLists.txt	2023-11-30 21:46:35.101749250 +0100
+@@ -18,7 +18,7 @@
+ set(NVFUSER_ROOT ${PROJECT_SOURCE_DIR})
+ set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc")
+ set(TORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
+-set(TORCH_INSTALL_LIB_DIR ${TORCH_ROOT}/torch/lib)
++set(TORCH_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
+ 
+ # --- build nvfuser_codegen library
+ 
+@@ -213,7 +213,7 @@
+     message(STATUS "somehow this is happening")
+     set_target_properties(${NVFUSER} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
+   endif()
+-  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION ${TORCH_ROOT}/nvfuser/)
++  install(TARGETS ${NVFUSER} EXPORT NvfuserTargets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
+ endif()
+ 
+ # --- generate runtime files
+--- a/functorch/CMakeLists.txt	2023-11-30 20:30:45.805209036 +0100
++++ b/functorch/CMakeLists.txt	2023-11-30 20:31:13.284766157 +0100
+@@ -35,4 +35,4 @@
+ if(NOT ${TORCH_PYTHON_LINK_FLAGS} STREQUAL "")
+   set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
+ endif()
+-install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
++install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2023-04-12 17:58 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2023-04-12 17:58 UTC (permalink / raw
  To: gentoo-commits

commit:     6c34a781ed2d42b1923889fc4f6d015813d2fcdf
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 12 17:56:54 2023 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Wed Apr 12 17:57:45 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6c34a781

sci-libs/caffe2: to build with gcc-13

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

 sci-libs/caffe2/caffe2-2.0.0-r1.ebuild         |  1 +
 sci-libs/caffe2/files/caffe2-2.0.0-gcc13.patch | 41 ++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/sci-libs/caffe2/caffe2-2.0.0-r1.ebuild b/sci-libs/caffe2/caffe2-2.0.0-r1.ebuild
index ae14175b2471..48a01218a4e0 100644
--- a/sci-libs/caffe2/caffe2-2.0.0-r1.ebuild
+++ b/sci-libs/caffe2/caffe2-2.0.0-r1.ebuild
@@ -80,6 +80,7 @@ PATCHES=(
 	"${FILESDIR}"/${PN}-1.13.0-install-dirs.patch
 	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
 	"${FILESDIR}"/${PN}-1.13.1-tensorpipe.patch
+	"${FILESDIR}"/${P}-gcc13.patch
 )
 
 src_prepare() {

diff --git a/sci-libs/caffe2/files/caffe2-2.0.0-gcc13.patch b/sci-libs/caffe2/files/caffe2-2.0.0-gcc13.patch
new file mode 100644
index 000000000000..acbcebad0a5d
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-2.0.0-gcc13.patch
@@ -0,0 +1,41 @@
+--- a/c10/util/Registry.h   2023-03-09 17:42:00.000000000 -0500
++++ b/c10/util/Registry.h       2023-04-09 20:38:33.108135511 -0400
+@@ -16,6 +16,7 @@
+ #include <memory>
+ #include <mutex>
+ #include <string>
++#include <stdexcept>
+ #include <unordered_map>
+ #include <vector>
+ 
+--- a/torch/csrc/jit/passes/quantization/quantization_type.h    2023-03-09 17:42:00.000000000 -0500
++++ b/torch/csrc/jit/passes/quantization/quantization_type.h    2023-04-09 20:43:43.124806308 -0400
+@@ -1,5 +1,6 @@
+ #pragma once
+ #include <ostream>
++#include <cstdint>
+ 
+ namespace torch {
+ namespace jit {
+
+--- a/torch/csrc/jit/runtime/logging.cpp    2023-03-09 17:42:00.000000000 -0500
++++ b/torch/csrc/jit/runtime/logging.cpp    2023-04-09 20:47:49.758142941 -0400
+@@ -1,6 +1,7 @@
+ #include <torch/csrc/jit/runtime/logging.h>
+ 
+ #include <atomic>
++#include <stdexcept>
+ #include <mutex>
+ #include <unordered_map>
+ 
+
+--- a/torch/csrc/lazy/core/multi_wait.cpp   2023-03-09 17:42:00.000000000 -0500
++++ b/torch/csrc/lazy/core/multi_wait.cpp   2023-04-09 20:50:36.608145172 -0400
+@@ -1,6 +1,7 @@
+ #include <torch/csrc/lazy/core/multi_wait.h>
+ 
+ #include <chrono>
++#include <stdexcept>
+ #include <exception>
+ 
+ namespace torch {


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2023-02-14 19:32 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2023-02-14 19:32 UTC (permalink / raw
  To: gentoo-commits

commit:     fa7df6a08decc35c91a5a791a27a71b32e105b30
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 14 19:30:31 2023 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Tue Feb 14 19:31:37 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fa7df6a0

sci-libs/caffe2: add 1.13.0

Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/Manifest                           |   1 +
 sci-libs/caffe2/caffe2-1.13.0.ebuild               | 168 ++++++++++++++++
 sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch   | 224 +++++++++++++++++++++
 .../caffe2/files/caffe2-1.13.0-install-dirs.patch  | 121 +++++++++++
 4 files changed, 514 insertions(+)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
index adfe026eaff0..fba79e4a9a24 100644
--- a/sci-libs/caffe2/Manifest
+++ b/sci-libs/caffe2/Manifest
@@ -1,2 +1,3 @@
 DIST pytorch-1.12.0.tar.gz 106286765 BLAKE2B ff9bafedb35f859f7dccb9b606299cf9c345bdaa0deb87ecfe0c0c30c3c828414d989e1d9a243d9b7cd3f376d56a2f81c241ca2e3c9a8a2b30cddcdeddd3a5c7 SHA512 c9c748a2e0047daaaf199a1ba3198d2d1aee47f664170a9b34ccacd3deeb95f2070e4035eeb900012ef48dc62cf6fb6806f1a1dfe22de8c94892963076e593b7
 DIST pytorch-1.12.1.tar.gz 106311625 BLAKE2B e8ca19d0e1987449c33ad4c36722a3a467f7f8a9f90be2a7f2de643cbd665038f6802b5ff1f1d3da09b6253d8f29e11549a24295de013d97f73affe538c84c99 SHA512 afeb551904ebd9b5901ae623a98eadbb3045115247cedf8006a940742cfad04e5ce24cfaf363336a9ed88d7ce6a4ac53dbb6a5c690aef6efdf20477c3a22c7ca
+DIST pytorch-1.13.0.tar.gz 108276317 BLAKE2B 8149775dea06d8e4027b741c828169d33f768a96aef58cd2f86daa3bbad5bf36143454e26b683a992aca34e7fb52e6483c46168b698db48ff6978c9605d7a3d2 SHA512 5a0e8c589bdf552ccf682511a8860c754ab6f5844f51e568c5034793f787b97707af4340b338b9b8606dd27a6ced6ef50091f0cc514458b3021a2220409d7f20

diff --git a/sci-libs/caffe2/caffe2-1.13.0.ebuild b/sci-libs/caffe2/caffe2-1.13.0.ebuild
new file mode 100644
index 000000000000..f77c5dd01c55
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-1.13.0.ebuild
@@ -0,0 +1,168 @@
+# Copyright 2022-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{9..10} )
+inherit python-single-r1 cmake flag-o-matic
+
+MYPN=pytorch
+MYP=${MYPN}-${PV}
+
+DESCRIPTION="A deep learning framework"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
+	-> ${MYP}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="cuda ffmpeg nnpack +numpy opencl opencv openmp qnnpack xnnpack"
+RESTRICT="test"
+REQUIRED_USE="
+	${PYTHON_REQUIRED_USE}
+	ffmpeg? ( opencv )
+" # ?? ( cuda rocm )
+
+RDEPEND="
+	${PYTHON_DEPS}
+	dev-cpp/gflags:=
+	>=dev-cpp/glog-0.5.0
+	dev-libs/cpuinfo
+	dev-libs/libfmt
+	dev-libs/protobuf:=
+	dev-libs/pthreadpool
+	dev-libs/sleef
+	sci-libs/lapack
+	>=sci-libs/onnx-1.12.0
+	sci-libs/foxi
+	cuda? (
+		=dev-libs/cudnn-8*
+		dev-libs/cudnn-frontend:0/8
+		dev-util/nvidia-cuda-toolkit:=[profiler]
+	)
+	ffmpeg? ( media-video/ffmpeg:= )
+	nnpack? ( sci-libs/NNPACK )
+	numpy? ( $(python_gen_cond_dep '
+		dev-python/numpy[${PYTHON_USEDEP}]
+		') )
+	opencl? ( virtual/opencl )
+	opencv? ( media-libs/opencv:= )
+	qnnpack? ( sci-libs/QNNPACK )
+	xnnpack? ( sci-libs/XNNPACK )
+"
+DEPEND="
+	${RDEPEND}
+	dev-cpp/eigen
+	dev-libs/psimd
+	dev-libs/FP16
+	dev-libs/FXdiv
+	dev-libs/pocketfft
+	dev-libs/flatbuffers
+	$(python_gen_cond_dep '
+		dev-python/pyyaml[${PYTHON_USEDEP}]
+		dev-python/pybind11[${PYTHON_USEDEP}]
+	')
+"
+
+S="${WORKDIR}"/${MYP}
+
+PATCHES=(
+	"${FILESDIR}"/${P}-gentoo.patch
+	"${FILESDIR}"/${P}-install-dirs.patch
+	"${FILESDIR}"/${PN}-1.12.0-glog-0.6.0.patch
+	"${FILESDIR}"/${PN}-1.12.0-clang.patch
+)
+
+src_prepare() {
+	filter-lto #bug 862672
+	cmake_src_prepare
+	pushd torch/csrc/jit/serialization || die
+	flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
+	popd
+}
+
+src_configure() {
+	if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+		ewarn "WARNING: caffe2 is being built with its default CUDA compute capabilities: 3.5 and 7.0."
+		ewarn "These may not be optimal for your GPU."
+		ewarn ""
+		ewarn "To configure caffe2 with the CUDA compute capability that is optimal for your GPU,"
+		ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and re-emerge caffe2."
+		ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TORCH_CUDA_ARCH_LIST=7.5,3.5"
+		ewarn "For a Maxwell model GPU, an example value would be: TORCH_CUDA_ARCH_LIST=Maxwell"
+		ewarn ""
+		ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus"
+		ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'"
+	fi
+
+	local mycmakeargs=(
+		-DBUILD_CUSTOM_PROTOBUF=OFF
+		-DBUILD_SHARED_LIBS=ON
+
+		-DUSE_CCACHE=OFF
+		-DUSE_CUDA=$(usex cuda)
+		-DUSE_CUDNN=$(usex cuda)
+		-DUSE_FAST_NVCC=$(usex cuda)
+		-DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
+		-DUSE_DISTRIBUTED=OFF
+		-DUSE_FAKELOWP=OFF
+		-DUSE_FBGEMM=OFF # TODO
+		-DUSE_FFMPEG=$(usex ffmpeg)
+		-DUSE_GFLAGS=ON
+		-DUSE_GLOG=ON
+		-DUSE_GLOO=OFF
+		-DUSE_KINETO=OFF # TODO
+		-DUSE_LEVELDB=OFF
+		-DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
+		-DUSE_MKLDNN=OFF
+		-DUSE_NCCL=OFF # TODO: NVIDIA Collective Communication Library
+		-DUSE_NNPACK=$(usex nnpack)
+		-DUSE_QNNPACK=$(usex qnnpack)
+		-DUSE_XNNPACK=$(usex xnnpack)
+		-DUSE_SYSTEM_XNNPACK=$(usex xnnpack)
+		-DUSE_PYTORCH_QNNPACK=OFF
+		-DUSE_NUMPY=$(usex numpy)
+		-DUSE_OPENCL=$(usex opencl)
+		-DUSE_OPENCV=$(usex opencv)
+		-DUSE_OPENMP=$(usex openmp)
+		-DUSE_ROCM=OFF # TODO
+		-DUSE_SYSTEM_CPUINFO=ON
+		-DUSE_SYSTEM_PYBIND11=ON
+		-DUSE_VALGRIND=OFF
+		-DPYBIND11_PYTHON_VERSION="${EPYTHON#python}"
+		-DPYTHON_EXECUTABLE="${PYTHON}"
+		-DUSE_ITT=OFF
+		-DUSE_SYSTEM_EIGEN_INSTALL=ON
+		-DUSE_SYSTEM_PTHREADPOOL=ON
+		-DUSE_SYSTEM_FXDIV=ON
+		-DUSE_SYSTEM_FP16=ON
+		-DUSE_SYSTEM_GLOO=ON
+		-DUSE_SYSTEM_ONNX=ON
+		-DUSE_SYSTEM_SLEEF=ON
+		-DUSE_TENSORPIPE=OFF
+
+		-Wno-dev
+		-DTORCH_INSTALL_LIB_DIR="${EPREFIX}"/usr/$(get_libdir)
+		-DLIBSHM_INSTALL_LIB_SUBDIR="${EPREFIX}"/usr/$(get_libdir)
+	)
+
+	use cuda && addpredict "/dev/nvidiactl" # bug 867706
+	cmake_src_configure
+}
+
+src_install() {
+	cmake_src_install
+
+	insinto "/var/lib/${PN}"
+	doins "${BUILD_DIR}"/CMakeCache.txt
+
+	rm -rf python
+	mkdir -p python/torch/include || die
+	mv "${ED}"/usr/lib/python*/site-packages/caffe2 python/ || die
+	mv "${ED}"/usr/include/torch python/torch/include || die
+	cp torch/version.py python/torch/ || die
+	rm -r "${ED}"/var/tmp || die
+	python_domodule python/caffe2
+	python_domodule python/torch
+}

diff --git a/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch b/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
new file mode 100644
index 000000000000..a2771e3319d8
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-1.13.0-gentoo.patch
@@ -0,0 +1,224 @@
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -1557,7 +1557,6 @@
+   if(NOT USE_SYSTEM_ONNX)
+     add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx EXCLUDE_FROM_ALL)
+   endif()
+-  add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
+ 
+   add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
+   if(NOT USE_SYSTEM_ONNX)
+@@ -1850,7 +1849,6 @@
+ #
+ set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
+-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
+ 
+ # Disable compiler feature checks for `fmt`.
+ #
+@@ -1859,9 +1857,7 @@
+ # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
+ # `fmt` is compatible with a superset of the compilers that PyTorch is, it
+ # shouldn't be too bad to just disable the checks.
+-set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
+ 
+-list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
+ set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
+ 
+ # ---[ Kineto
+--- a/c10/CMakeLists.txt
++++ b/c10/CMakeLists.txt
+@@ -64,7 +64,7 @@
+ if(${USE_GLOG})
+     target_link_libraries(c10 PUBLIC glog::glog)
+ endif()
+-target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
++target_link_libraries(c10 PRIVATE fmt)
+ 
+ find_package(Backtrace)
+ if(Backtrace_FOUND)
+--- a/torch/CMakeLists.txt
++++ b/torch/CMakeLists.txt
+@@ -66,15 +66,9 @@
+     ${CMAKE_BINARY_DIR}
+     ${CMAKE_BINARY_DIR}/aten/src
+     ${CMAKE_BINARY_DIR}/caffe2/aten/src
+-    ${CMAKE_BINARY_DIR}/third_party
+-    ${CMAKE_BINARY_DIR}/third_party/onnx
+ 
+-    ${TORCH_ROOT}/third_party/valgrind-headers
+ 
+-    ${TORCH_ROOT}/third_party/gloo
+-    ${TORCH_ROOT}/third_party/onnx
+-    ${TORCH_ROOT}/third_party/flatbuffers/include
+-    ${TORCH_ROOT}/third_party/kineto/libkineto/include
++    /usr/include/kineto
+ 
+     ${TORCH_SRC_DIR}/csrc
+     ${TORCH_SRC_DIR}/csrc/api/include
+@@ -87,7 +81,6 @@
+     python::python
+     pybind::pybind11
+     shm
+-    fmt::fmt-header-only
+     ATEN_CPU_FILES_GEN_LIB)
+ 
+ set(TORCH_PYTHON_COMPILE_DEFINITIONS)
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -817,13 +817,12 @@
+ 
+ # ---[ Build flags
+ if(NOT MSVC)
+-  string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
++  string(APPEND CMAKE_CXX_FLAGS " -fPIC")
+   string(APPEND CMAKE_CXX_FLAGS " -Wno-narrowing")
+   # Eigen fails to build with some versions, so convert this to a warning
+   # Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
+   string(APPEND CMAKE_CXX_FLAGS " -Wall")
+   string(APPEND CMAKE_CXX_FLAGS " -Wextra")
+-  append_cxx_flag_if_supported("-Werror=return-type" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Wno-missing-field-initializers" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-Wno-type-limits" CMAKE_CXX_FLAGS)
+@@ -925,8 +924,6 @@
+   string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
+   append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
+   append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
+-  append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
+-  append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
+   check_cxx_compiler_flag("-Werror=sign-compare" HAS_WERROR_SIGN_COMPARE)
+   # This doesn't work globally so we use the test on specific
+   # target_compile_options
+--- a/cmake/public/utils.cmake
++++ b/cmake/public/utils.cmake
+@@ -507,8 +507,6 @@
+   endif()
+ 
+   # Use -O2 for release builds (-O3 doesn't improve perf, and -Os results in perf regression)
+-  target_compile_options(${libname} PRIVATE
+-      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:-O2>)
+ 
+ endfunction()
+ 
+--- a/cmake/Codegen.cmake
++++ b/cmake/Codegen.cmake
+@@ -57,7 +57,7 @@
+   if(MSVC)
+     set(OPT_FLAG "/fp:strict ")
+   else(MSVC)
+-    set(OPT_FLAG "-O3 ")
++    set(OPT_FLAG " ")
+     if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
+       set(OPT_FLAG " ")
+     endif()
+--- a/caffe2/CMakeLists.txt
++++ b/caffe2/CMakeLists.txt
+@@ -111,7 +111,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 "")
+@@ -537,7 +537,6 @@
+ if(NOT MSVC)
+   set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_jit.cpp PROPERTIES COMPILE_FLAGS -Wno-noexcept-type)
+   # Force -Werror on several files
+-  set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/mkldnn/Pooling.cpp PROPERTIES COMPILE_FLAGS "-Werror")
+ endif()
+ # Disable certain warnings for GCC-9.X
+ if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0.0))
+@@ -825,7 +824,6 @@
+ torch_compile_options(torch_cpu)  # see cmake/public/utils.cmake
+ if(HAS_WERROR_SIGN_COMPARE AND WERROR)
+   # target_compile_options(torch_cpu PRIVATE "-Werror=sign-compare")
+-  set_property(SOURCE ${ATen_CORE_SRCS} ${ATen_CPU_SRCS} APPEND PROPERTY COMPILE_OPTIONS "-Werror=sign-compare")
+ endif()
+ 
+ set_property(SOURCE ${ATen_CORE_SRCS} APPEND
+@@ -1017,7 +1015,6 @@
+ endif()
+ 
+ if(NOT MSVC AND USE_XNNPACK)
+-  TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
+ endif()
+ 
+ # ==========================================================
+@@ -1136,8 +1133,7 @@
+ target_include_directories(torch_cpu PRIVATE
+   ${TORCH_ROOT}/third_party/miniz-2.1.0)
+ 
+-target_include_directories(torch_cpu PRIVATE
+-  ${TORCH_ROOT}/third_party/kineto/libkineto/include)
++target_include_directories(torch_cpu PRIVATE /usr/include/kineto)
+ 
+ if(USE_KINETO)
+   target_include_directories(torch_cpu PRIVATE
+--- a/cmake/External/nnpack.cmake
++++ b/cmake/External/nnpack.cmake
+@@ -58,7 +58,7 @@
+   set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
+   set(GOOGLETEST_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/googletest" CACHE STRING "Google Test source directory")
+ 
+-  if(NOT TARGET nnpack)
++  if(FALSE)
+     if(NOT USE_SYSTEM_PTHREADPOOL AND USE_INTERNAL_PTHREADPOOL_IMPL)
+       set(NNPACK_CUSTOM_THREADPOOL ON CACHE BOOL "")
+     endif()
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -481,7 +481,7 @@ endif()
+ list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
+ 
+ # ---[ QNNPACK
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+ 
+   if(NOT DEFINED QNNPACK_SOURCE_DIR)
+@@ -537,7 +537,7 @@ if(USE_QNNPACK)
+ endif()
+ 
+ # ---[ Caffe2 Int8 operators (enabled by USE_QNNPACK) depend on gemmlowp and neon2sse headers
+-if(USE_QNNPACK)
++if(FALSE)
+   set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
+   include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}/neon2sse")
+--- a/torch/csrc/Exceptions.cpp	2023-02-13 12:46:54.447013004 +0100
++++ b/torch/csrc/Exceptions.cpp	2023-02-13 12:50:18.433791791 +0100
+@@ -1,11 +1,10 @@
+ #include <torch/csrc/Exceptions.h>
+ #include <torch/csrc/python_headers.h>
+ 
++#include <array>
+ #include <cstdarg>
+ #include <exception>
+-#include <sstream>
+ #include <utility>
+-#include <vector>
+ 
+ #include <fmt/format.h>
+ #include <torch/csrc/THP.h>
+@@ -259,15 +258,12 @@
+       } else {
+         // Lets Python set the source location and puts the C++ warning
+         // location into the message.
+-        fmt::memory_buffer buf;
+-        fmt::format_to(
+-            buf,
+-            FMT_STRING("{} (Triggered internally at {}:{}.)"),
++        auto buf = fmt::format(
++            "{} (Triggered internally at {}:{}.)",
+             msg,
+             source_location.file,
+             source_location.line);
+-        buf.push_back('\0');
+-        result = PyErr_WarnEx(PyExc_UserWarning, buf.data(), 1);
++        result = PyErr_WarnEx(PyExc_UserWarning, buf.c_str(), 1);
+       }
+       if (result < 0) {
+         if (in_exception_) {

diff --git a/sci-libs/caffe2/files/caffe2-1.13.0-install-dirs.patch b/sci-libs/caffe2/files/caffe2-1.13.0-install-dirs.patch
new file mode 100644
index 000000000000..299c9f88a173
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-1.13.0-install-dirs.patch
@@ -0,0 +1,121 @@
+--- a/c10/CMakeLists.txt
++++ b/c10/CMakeLists.txt
+@@ -112,7 +112,7 @@
+ # Note: for now, we will put all export path into one single Caffe2Targets group
+ # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
+ # individual libraries like libc10.so and libcaffe2.so are still self-contained.
+-install(TARGETS c10 EXPORT Caffe2Targets DESTINATION lib)
++install(TARGETS c10 EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+         DESTINATION include
+         FILES_MATCHING PATTERN "*.h")
+--- a/c10/cuda/CMakeLists.txt
++++ b/c10/cuda/CMakeLists.txt
+@@ -64,7 +64,7 @@ add_subdirectory(test)
+ # Note: for now, we will put all export path into one single Caffe2Targets group
+ # to deal with the cmake deployment need. Inside the Caffe2Targets set, the
+ # individual libraries like libc10.so and libcaffe2.so are still self-contained.
+-install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION lib)
++install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ foreach(file ${C10_CUDA_HEADERS})
+   get_filename_component( dir ${file} DIRECTORY )
+   install( FILES ${file} DESTINATION include/c10/cuda/${dir} )
+--- a/c10/hip/CMakeLists.txt
++++ b/c10/hip/CMakeLists.txt
+@@ -55,7 +55,7 @@ target_include_directories(
+ add_subdirectory(test)
+ 
+ # ---[ Installation
+-install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION lib)
++install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+         DESTINATION include
+         FILES_MATCHING PATTERN "*.h")
+--- a/modules/detectron/CMakeLists.txt
++++ b/modules/detectron/CMakeLists.txt
+@@ -20,7 +20,7 @@
+     if(USE_MKLDNN)
+       target_link_libraries(caffe2_detectron_ops_gpu PRIVATE caffe2::mkldnn)
+     endif()
+-    install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
++    install(TARGETS caffe2_detectron_ops_gpu DESTINATION ${CMAKE_INSTALL_LIBDIR})
+     if(MSVC)
+       install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops_gpu> DESTINATION lib OPTIONAL)
+     endif()
+@@ -37,7 +37,7 @@
+       target_link_libraries(caffe2_detectron_ops_hip PRIVATE caffe2::mkldnn)
+     endif()
+     target_link_libraries(caffe2_detectron_ops_hip PRIVATE torch)
+-    install(TARGETS caffe2_detectron_ops_hip DESTINATION lib)
++    install(TARGETS caffe2_detectron_ops_hip DESTINATION ${CMAKE_INSTALL_LIBDIR})
+   elseif(NOT IOS_PLATFORM)
+     add_library(caffe2_detectron_ops SHARED ${Detectron_CPU_SRCS})
+     if(HAVE_SOVERSION)
+@@ -49,7 +49,7 @@
+     if(USE_MKLDNN)
+       target_link_libraries(caffe2_detectron_ops PRIVATE caffe2::mkldnn)
+     endif()
+-    install(TARGETS caffe2_detectron_ops DESTINATION lib)
++    install(TARGETS caffe2_detectron_ops DESTINATION ${CMAKE_INSTALL_LIBDIR})
+     if(MSVC)
+       install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops> DESTINATION lib OPTIONAL)
+     endif()
+--- a/modules/module_test/CMakeLists.txt
++++ b/modules/module_test/CMakeLists.txt
+@@ -16,7 +16,7 @@ if(BUILD_TEST AND NOT BUILD_LITE_INTERPRETER)
+         VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
+   endif()
+   target_link_libraries(caffe2_module_test_dynamic torch_library)
+-  install(TARGETS caffe2_module_test_dynamic DESTINATION lib)
++  install(TARGETS caffe2_module_test_dynamic DESTINATION ${CMAKE_INSTALL_LIBDIR})
+   if(MSVC AND BUILD_SHARED_LIBS)
+     install(FILES $<TARGET_PDB_FILE:caffe2_module_test_dynamic> DESTINATION lib OPTIONAL)
+   endif()
+--- a/modules/observers/CMakeLists.txt
++++ b/modules/observers/CMakeLists.txt
+@@ -21,7 +21,7 @@ endif()
+ target_link_libraries(caffe2_observers PUBLIC torch_library)
+ target_include_directories(caffe2_observers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
+ target_compile_options(caffe2_observers PRIVATE "-DCAFFE2_BUILD_OBSERVER_LIB")
+-install(TARGETS caffe2_observers DESTINATION lib)
++install(TARGETS caffe2_observers DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ caffe2_interface_library(caffe2_observers caffe2_observers_library)
+ if(MSVC AND BUILD_SHARED_LIBS)
+   install(FILES $<TARGET_PDB_FILE:caffe2_observers> DESTINATION lib OPTIONAL)
+--- a/modules/rocksdb/CMakeLists.txt
++++ b/modules/rocksdb/CMakeLists.txt
+@@ -63,7 +63,7 @@ add_library(caffe2_rocksdb ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb.cc)
+ target_link_libraries(caffe2_rocksdb PUBLIC torch_library)
+ target_link_libraries(caffe2_rocksdb PRIVATE ${RocksDB_LIBRARIES})
+ target_include_directories(caffe2_rocksdb PRIVATE ${RocksDB_INCLUDE_DIR})
+-install(TARGETS caffe2_rocksdb DESTINATION lib)
++install(TARGETS caffe2_rocksdb DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ 
+ # ---[ Last, Append the library to Caffe2_MODULES, if we are building with
+ # the main repo.
+--- a/test/cpp/c10d/CMakeLists.txt
++++ b/test/cpp/c10d/CMakeLists.txt
+@@ -51,7 +51,7 @@ if(USE_CUDA)
+     if(INSTALL_TEST)
+       install(TARGETS ProcessGroupNCCLTest DESTINATION bin)
+       install(TARGETS ProcessGroupNCCLErrorsTest DESTINATION bin)
+-      install(TARGETS c10d_cuda_test DESTINATION lib)
++      install(TARGETS c10d_cuda_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
+     endif()
+   endif()
+   if(USE_UCC AND USE_C10D_UCC)
+--- a/test/cpp/jit/CMakeLists.txt
++++ b/test/cpp/jit/CMakeLists.txt
+@@ -32,9 +32,9 @@ endif()
+ target_link_libraries(backend_with_compiler torch)
+ 
+ if(INSTALL_TEST)
+-  install(TARGETS torchbind_test DESTINATION lib)
+-  install(TARGETS jitbackend_test DESTINATION lib)
+-  install(TARGETS backend_with_compiler DESTINATION lib)
++  install(TARGETS torchbind_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
++  install(TARGETS jitbackend_test DESTINATION ${CMAKE_INSTALL_LIBDIR})
++  install(TARGETS backend_with_compiler DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ 
+ # Build the cpp gtest binary containing the cpp-only tests.


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/
@ 2022-07-02 11:04 Alfredo Tupone
  0 siblings, 0 replies; 13+ messages in thread
From: Alfredo Tupone @ 2022-07-02 11:04 UTC (permalink / raw
  To: gentoo-commits

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>tupone@gentoo.org</email>
 		<name>Tupone Alfredo</name>
 	</maintainer>
+	<use>
+		<flag name="xnnpack">Use XNNPACK</flag>
+	</use>
 	<upstream>
 		<remote-id type="github">pytorch/pytorch</remote-id>
 	</upstream>


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-11-14 10:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-06 17:29 [gentoo-commits] repo/gentoo:master commit in: sci-libs/caffe2/, sci-libs/caffe2/files/ Alfredo Tupone
  -- strict thread matches above, loose matches on Subject: below --
2024-11-14 10:00 Alfredo Tupone
2024-09-05  7:10 Alfredo Tupone
2024-08-25 16:10 Sam James
2024-08-09 15:37 Alfredo Tupone
2024-08-08 16:27 Alfredo Tupone
2024-05-26 15:19 Alfredo Tupone
2024-04-30 17:18 Alfredo Tupone
2024-03-22 20:54 Alfredo Tupone
2023-12-01  5:53 Alfredo Tupone
2023-04-12 17:58 Alfredo Tupone
2023-02-14 19:32 Alfredo Tupone
2022-07-02 11:04 Alfredo Tupone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox