summaryrefslogtreecommitdiff
path: root/sci-libs/caffe2
diff options
context:
space:
mode:
Diffstat (limited to 'sci-libs/caffe2')
-rw-r--r--sci-libs/caffe2/Manifest4
-rw-r--r--sci-libs/caffe2/caffe2-1.11.0.ebuild99
-rw-r--r--sci-libs/caffe2/files/caffe2-1.11.0-gentoo.patch93
-rw-r--r--sci-libs/caffe2/metadata.xml11
4 files changed, 207 insertions, 0 deletions
diff --git a/sci-libs/caffe2/Manifest b/sci-libs/caffe2/Manifest
new file mode 100644
index 000000000000..1953d56b4a0c
--- /dev/null
+++ b/sci-libs/caffe2/Manifest
@@ -0,0 +1,4 @@
+AUX caffe2-1.11.0-gentoo.patch 3659 BLAKE2B 3f65ac30ed6ebb4f45ec4abbf0368e5033e2b6bf1ff3bf5a13dfec5d28c803c52053913cfbf1f3576f6b4ac8ff324d79852eb13a2c53ca5ea40915f79edeff2b SHA512 79e82b2dbc4113bc734d6c317e8668d551e8815b0cac41ac1181bcc3e7d285e575539de9ceafaa400c72160a7b1205f3a6975c61ac801e09e4b6dc29a5a1d6ce
+DIST pytorch-1.11.0.tar.gz 20719323 BLAKE2B 24e7aaa2c26821d36f8092542de9d8d5ac85a619fb9fffb5131987958842afb1cad395780662d15f3411a7cc6ff83a445871960eca1e469fcbf0b9895d83d6e0 SHA512 2342eb7a1a241f5855a7cf12e11f62bc4baaa78d1d0864e53bfc946e783eb4addd05ca154a814d2376cd602098b5547e61c158d6eddb7cad5a9f3b0c1357adca
+EBUILD caffe2-1.11.0.ebuild 1988 BLAKE2B f671b7eb952e7f890370f810396afba225e08e358cfde43c728f1ee348eb9b8dbbc35f8be7bd2281307ad9fd31e5f914b72b9410340e5c286f2349ba2c5ae0fa SHA512 6adaf278512440ea17e6f31eec7b9f368168ef5f277a4c17c429d5cf790a859ef7fe79bd9b6ec4895158b88014b3450a278edd46e6c9c641cad67b51a33e3c92
+MISC metadata.xml 328 BLAKE2B f49c6d62ac88dfffe497ed05b1f727941a94acb87a809611dda8aedbd87508fdfdf94ec0e025cac2a649b0881b600236289943b4be0f6ca44fc105b6d8fbe97c SHA512 16c29d2c1177a89026235191ea3e33870c2e6b63f029b7febd4dbd2e99f598fab4b4fd2fa7a801ffd88393663a00752300e6e2cc847a83690b715bcc481d9dc2
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..e0f6d0d772f2
--- /dev/null
+++ b/sci-libs/caffe2/caffe2-1.11.0.ebuild
@@ -0,0 +1,99 @@
+# 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
+ dev-python/pyyaml[${PYTHON_USEDEP}]
+ dev-python/pybind11[${PYTHON_USEDEP}]
+"
+
+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() {
+ python_setup
+ 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>tupone@gentoo.org</email>
+ <name>Tupone Alfredo</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="github">pytorch/pytorch</remote-id>
+ </upstream>
+</pkgmetadata>