commit:     794186914f817e446782620d16d4f7eda5d8353c
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 25 21:40:03 2022 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sun Jun 26 07:47:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79418691

sci-libs/caffe2: add to tree

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

 sci-libs/caffe2/Manifest                         |  1 +
 sci-libs/caffe2/caffe2-1.11.0.ebuild             | 96 ++++++++++++++++++++++++
 sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch | 93 +++++++++++++++++++++++
 sci-libs/caffe2/metadata.xml                     | 11 +++
 4 files changed, 201 insertions(+)

diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
new file mode 100644
index 000000000000..ae4d5567b7fc
--- /dev/null
+++ b/sci-libs/caffe2/Manifest
@@ -0,0 +1 @@
+DIST pytorch-1.11.0.tar.gz 20719323 BLAKE2B 
24e7aaa2c26821d36f8092542de9d8d5ac85a619fb9fffb5131987958842afb1cad395780662d15f3411a7cc6ff83a445871960eca1e469fcbf0b9895d83d6e0
 SHA512 
2342eb7a1a241f5855a7cf12e11f62bc4baaa78d1d0864e53bfc946e783eb4addd05ca154a814d2376cd602098b5547e61c158d6eddb7cad5a9f3b0c1357adca

diff --git a/sci-libs/caffe2/caffe2-1.11.0.ebuild 
b/sci-libs/caffe2/caffe2-1.11.0.ebuild
new file mode 100644
index 000000000000..f8e9483bf74a
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-1.11.0.ebuild
@@ -0,0 +1,96 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit python-r1 cmake
+
+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"
+RESTRICT="test"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="
+       ${PYTHON_DEPS}
+       dev-libs/cpuinfo
+       dev-libs/libfmt
+       dev-libs/protobuf
+       dev-libs/sleef
+       sci-libs/lapack
+       sci-libs/onnx
+       sci-libs/foxi
+"
+DEPEND="${RDEPEND}
+       dev-libs/FP16
+       dev-libs/pocketfft
+       dev-libs/flatbuffers
+"
+
+S="${WORKDIR}"/${MYP}
+
+PATCHES=( "${FILESDIR}"/${P}-gentoo.patch )
+
+src_prepare() {
+       cmake_src_prepare
+       pushd torch/csrc/jit/serialization || die
+       flatc --cpp --gen-mutable --scoped-enums mobile_bytecode.fbs || die
+       popd
+}
+
+src_configure() {
+       local mycmakeargs=(
+               -DUSE_KINETO=OFF
+               -DUSE_XNNPACK=OFF
+               -DUSE_SYSTEM_SLEEF=ON
+               -DUSE_BREAKPAD=OFF
+               -DUSE_SYSTEM_ONNX=ON
+               -DUSE_TENSORPIPE=OFF
+               -DUSE_GLOO=OFF
+               -DUSE_SYSTEM_FP16=ON
+               -DUSE_FBGEMM=OFF
+               -DUSE_NNPACK=OFF
+               -DUSE_PYTORCH_QNNPACK=OFF
+               -DUSE_QNNPACK=OFF
+               -DUSE_SYSTEM_CPUINFO=ON
+               -DBUILD_CUSTOM_PROTOBUF=OFF
+               -DUSE_MKLDNN=OFF
+               -DUSE_NUMPY=OFF
+               -DUSE_OPENMP=OFF
+               -DUSE_DISTRIBUTED=OFF
+               -DUSE_CUDA=OFF
+               -DUSE_NCCL=OFF
+               -Wno-dev
+               -DTORCH_INSTALL_LIB_DIR=/usr/$(get_libdir)
+               -DLIBSHM_INSTALL_LIB_SUBDIR=/usr/$(get_libdir)
+               -DUSE_CCACHE=OFF
+       )
+       cmake_src_configure
+}
+
+python_install() {
+       python_domodule python/caffe2
+       python_domodule python/torch
+}
+
+src_install() {
+       cmake_src_install
+
+       insinto "/var/lib/${PN}"
+       doins "${BUILD_DIR}"/CMakeCache.txt
+
+       rm -rf python
+       mkdir -p python/torch || die
+       mv "${D}"/usr/lib/python*/site-packages/caffe2 python/ || die
+       cp torch/version.py python/torch/ || die
+       python_foreach_impl python_install
+}

diff --git a/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch 
b/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch
new file mode 100644
index 000000000000..ac74edadab35
--- /dev/null
+++ b/sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch
@@ -0,0 +1,93 @@
+--- a/cmake/Dependencies.cmake 2022-06-17 22:12:34.451841710 +0200
++++ b/cmake/Dependencies.cmake 2022-06-17 22:12:48.302786501 +0200
+@@ -1512,7 +1512,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)
+@@ -1810,7 +1809,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`.
+ #
+@@ -1819,9 +1817,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)
+ 
+ if(USE_BREAKPAD)
+--- a/c10/CMakeLists.txt       2022-06-17 22:40:53.573306905 +0200
++++ b/c10/CMakeLists.txt       2022-06-17 22:41:16.920219686 +0200
+@@ -59,7 +59,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     2022-06-17 22:42:20.396982644 +0200
++++ b/torch/CMakeLists.txt     2022-06-17 22:43:20.214759326 +0200
+@@ -82,7 +82,6 @@
+ 
+ set(TORCH_PYTHON_LINK_LIBRARIES
+     shm
+-    fmt::fmt-header-only
+     ATEN_CPU_FILES_GEN_LIB)
+ 
+ set(TORCH_PYTHON_COMPILE_DEFINITIONS)
+--- a/CMakeLists.txt   2022-06-18 20:35:01.451116185 +0200
++++ b/CMakeLists.txt   2022-06-18 20:35:08.219023569 +0200
+@@ -750,7 +750,7 @@
+ 
+ # ---[ 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
+--- a/cmake/public/utils.cmake 2022-06-18 20:50:39.314263395 +0200
++++ b/cmake/public/utils.cmake 2022-06-18 20:51:49.611291709 +0200
+@@ -512,8 +512,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      2022-06-18 21:33:13.366381817 +0200
++++ b/cmake/Codegen.cmake      2022-06-18 21:33:30.249157610 +0200
+@@ -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/c10/CMakeLists.txt       2022-06-19 09:57:16.776536871 +0200
++++ b/c10/CMakeLists.txt       2022-06-19 09:58:51.663356075 +0200
+@@ -107,7 +107,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")

diff --git a/sci-libs/caffe2/metadata.xml b/sci-libs/caffe2/metadata.xml
new file mode 100644
index 000000000000..d12749aa5c21
--- /dev/null
+++ b/sci-libs/caffe2/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="person">
+               <email>tup...@gentoo.org</email>
+               <name>Tupone Alfredo</name>
+       </maintainer>
+       <upstream>
+               <remote-id type="github">pytorch/pytorch</remote-id>
+       </upstream>
+</pkgmetadata>

Reply via email to