diff options
author | Vinicius Monego <monego@posteo.net> | 2020-08-01 11:43:21 -0300 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2020-08-03 08:59:52 +0200 |
commit | b654037403f0fdae63f200b57aee9a35a236907f (patch) | |
tree | 1281e8a3eb503d67fe73ed706860f2d82a5f78a4 | |
parent | ba4d96d22f5c063c9becd7b16410508a6d278dd6 (diff) | |
download | guix-b654037403f0fdae63f200b57aee9a35a236907f.tar.gz guix-b654037403f0fdae63f200b57aee9a35a236907f.zip |
gnu: Add python-onnx.
* gnu/packages/machine-learning.scm (python-onnx): New variable.
* gnu/packages/patches/python-onnx-use-system-googletest.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/machine-learning.scm | 43 | ||||
-rw-r--r-- | gnu/packages/patches/python-onnx-use-system-googletest.patch | 54 |
3 files changed, 98 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 15ae30f30a..f1a6c6a0d0 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1464,6 +1464,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-memcached-syntax-warnings.patch \ %D%/packages/patches/python-mox3-python3.6-compat.patch \ %D%/packages/patches/python-testtools.patch \ + %D%/packages/patches/python-onnx-use-system-googletest.patch \ %D%/packages/patches/python-packaging-test-arch.patch \ %D%/packages/patches/python2-parameterized-docstring-test.patch \ %D%/packages/patches/python-paste-remove-timing-test.patch \ diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 18a4ac9ef2..4ec3ed05c7 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -15,6 +15,7 @@ ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com> +;;; Copyright © 2020 Vinicius Monego <monego@posteo.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -53,6 +54,7 @@ #:use-module (gnu packages boost) #:use-module (gnu packages check) #:use-module (gnu packages compression) + #:use-module (gnu packages cmake) #:use-module (gnu packages cran) #:use-module (gnu packages databases) #:use-module (gnu packages dejagnu) @@ -70,6 +72,7 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages protobuf) #:use-module (gnu packages python) + #:use-module (gnu packages python-check) #:use-module (gnu packages python-science) #:use-module (gnu packages python-web) #:use-module (gnu packages python-xyz) @@ -576,6 +579,46 @@ tools. This enables both rapid prototyping of data pipelines and extensibility in terms of new algorithms.") (license license:gpl3+))) +(define-public python-onnx + (package + (name "python-onnx") + (version "1.7.0") + (source + (origin + (method url-fetch) + (uri (pypi-uri "onnx" version)) + ;; ONNX will build googletest from a git checkout. Patch CMake + ;; to use googletest from Guix and enable tests by default. + (patches (search-patches "python-onnx-use-system-googletest.patch")) + (sha256 + (base32 "0j6rgfbhsw3a8id8pyg18y93k68lbjbj1kq6qia36h69f6pvlyjy")))) + (build-system python-build-system) + (native-inputs + `(("cmake" ,cmake) + ("googletest" ,googletest) + ("pybind11" ,pybind11) + ("python-coverage" ,python-coverage) + ("python-nbval" ,python-nbval) + ("python-pytest" ,python-pytest) + ("python-pytest-runner" ,python-pytest-runner))) + (inputs + `(("protobuf" ,protobuf))) + (propagated-inputs + `(("python-numpy" ,python-numpy) + ("python-protobuf" ,python-protobuf) + ("python-six" ,python-six) + ("python-tabulate" ,python-tabulate) + ("python-typing-extensions" + ,python-typing-extensions))) + (home-page "https://onnx.ai/") + (synopsis "Open Neural Network Exchange") + (description + "Open Neural Network Exchange (ONNX) provides an open source format for +AI models, both deep learning and traditional ML. It defines an extensible +computation graph model, as well as definitions of built-in operators and +standard data types.") + (license license:expat))) + (define-public rxcpp (package (name "rxcpp") diff --git a/gnu/packages/patches/python-onnx-use-system-googletest.patch b/gnu/packages/patches/python-onnx-use-system-googletest.patch new file mode 100644 index 0000000000..33d2fa12de --- /dev/null +++ b/gnu/packages/patches/python-onnx-use-system-googletest.patch @@ -0,0 +1,54 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0aa9fda2..a573170c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF) + option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON) + option(ONNX_WERROR "Build with Werror" OFF) + option(ONNX_COVERAGE "Build with coverage instrumentation" OFF) +-option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF) ++option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" ON) + option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) + option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF) + if(NOT DEFINED ONNX_ML) +@@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + endif() + + if(ONNX_BUILD_TESTS) +- list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external) +- include(googletest) ++ find_package(GTest REQUIRED) ++ if(NOT GTest_FOUND) ++ message(FATAL_ERROR "cannot find googletest") ++ endif() + endif() + + if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) +diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake +index e29a93ff..ae146390 100644 +--- a/cmake/unittest.cmake ++++ b/cmake/unittest.cmake +@@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake) + + find_package(Threads) + +-set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES}) +-set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES}) ++set(${UT_NAME}_libs ${GTEST_LIBRARIES}) ++set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES}) + + list(APPEND ${UT_NAME}_libs onnx) + list(APPEND ${UT_NAME}_libs onnx_proto) +@@ -31,10 +31,10 @@ function(AddTest) + list(REMOVE_DUPLICATES _UT_SOURCES) + + add_executable(${_UT_TARGET} ${_UT_SOURCES}) +- add_dependencies(${_UT_TARGET} onnx onnx_proto googletest) ++ add_dependencies(${_UT_TARGET} onnx onnx_proto) + + target_include_directories(${_UT_TARGET} +- PUBLIC ${googletest_INCLUDE_DIRS} ++ PUBLIC ${GTEST_INCLUDE_DIRS} + ${ONNX_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIRS} + ${ONNX_ROOT} |