From b402a3ec86ebac4df4eed6a4030923bc62683d1d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 29 Jul 2021 21:15:23 +0200 Subject: gnu: Add XNNPACK. * gnu/packages/machine-learning.scm (xnnpack): New variable. * gnu/packages/patches/xnnpack-system-libraries.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/packages/machine-learning.scm | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 952872e468..4ac1fb5ab5 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -70,6 +70,7 @@ #:use-module (gnu packages mpi) #:use-module (gnu packages ocaml) #:use-module (gnu packages onc-rpc) + #:use-module (gnu packages parallel) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages protobuf) @@ -2229,3 +2230,52 @@ These include a barrier, broadcast, and allreduce.") technique that can be used for visualisation similarly to t-SNE, but also for general non-linear dimension reduction.") (license license:bsd-3))) + +(define-public xnnpack + ;; There's currently no tag on this repo. + (let ((version "0.0") + (commit "bbe88243aba847f6a3dd86defec0fea4a0e415a1") + (revision "1")) + (package + (name "xnnpack") + (version (git-version version revision commit)) + (home-page "https://github.com/google/XNNPACK") + (source (origin + (method git-fetch) + (uri (git-reference (url home-page) (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "19j605x1l2h95mjhcj90zwjh1153pdgmqggl35ya5w0wll628iiz")) + (patches (search-patches "xnnpack-system-libraries.patch")))) + (build-system cmake-build-system) + (arguments + '(#:configure-flags '("-DXNNPACK_USE_SYSTEM_LIBS=YES" + "-DBUILD_SHARED_LIBS=ON" + "-DXNNPACK_LIBRARY_TYPE=shared" + "-DXNNPACK_BUILD_TESTS=FALSE" ;FIXME: see below + "-DXNNPACK_BUILD_BENCHMARKS=FALSE") + + ;; FIXME: Building tests leads to a CMake error: + ;; + ;; ADD_LIBRARY cannot create target "all_microkernels" because + ;; another target with the same name already exists. + #:tests? #f)) + (inputs + `(("cpuinfo" ,cpuinfo) + ("pthreadpool" ,pthreadpool) + ("googletest" ,googletest) + ("googlebenchmark" ,googlebenchmark) + ("fxdiv" ,fxdiv) + ("fp16" ,fp16) + ("psimd" ,psimd))) + (synopsis "Optimized floating-point neural network inference operators") + (description + "XNNPACK is a highly optimized library of floating-point neural network +inference operators for ARM, WebAssembly, and x86 platforms. XNNPACK is not +intended for direct use by deep learning practitioners and researchers; +instead it provides low-level performance primitives for accelerating +high-level machine learning frameworks, such as TensorFlow Lite, +TensorFlow.js, PyTorch, and MediaPipe.") + (license license:bsd-3)))) + -- cgit v1.2.3 From 5f9dc326d9f6a4948ad30f2d3d554e3135f4727e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 11:29:42 +0200 Subject: gnu: python-onnx: Update to 1.9.0. * gnu/packages/machine-learning.scm (python-onnx): Update to 1.9.0. --- gnu/packages/machine-learning.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 4ac1fb5ab5..9ac1a79844 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -584,7 +584,7 @@ in terms of new algorithms.") (define-public python-onnx (package (name "python-onnx") - (version "1.8.1") + (version "1.9.0") (source (origin (method url-fetch) @@ -593,7 +593,7 @@ in terms of new algorithms.") ;; to use googletest from Guix and enable tests by default. (patches (search-patches "python-onnx-use-system-googletest.patch")) (sha256 - (base32 "1ys5f4kqkabm4mgivsw80zz8xj1svanfbpszqbw9j15914hcarcx")))) + (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")))) (build-system python-build-system) (native-inputs `(("cmake" ,cmake) -- cgit v1.2.3 From 3ac3ca367af7ecdd40b3ee304436f0018b059ce4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 11:30:54 +0200 Subject: gnu: python-onnx: Move comment to the patch header. * gnu/packages/machine-learning.scm (python-onnx): Move patch comment to... * gnu/packages/patches/python-onnx-use-system-googletest.patch: ... here. --- gnu/packages/machine-learning.scm | 2 -- gnu/packages/patches/python-onnx-use-system-googletest.patch | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 9ac1a79844..108bcbdfef 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -589,8 +589,6 @@ in terms of new algorithms.") (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 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")))) diff --git a/gnu/packages/patches/python-onnx-use-system-googletest.patch b/gnu/packages/patches/python-onnx-use-system-googletest.patch index 33d2fa12de..5dfcbc6dc3 100644 --- a/gnu/packages/patches/python-onnx-use-system-googletest.patch +++ b/gnu/packages/patches/python-onnx-use-system-googletest.patch @@ -1,3 +1,6 @@ +ONNX will build googletest from a Git checkout. Patch CMake to use our +googletest package and enable tests by default. + diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aa9fda2..a573170c 100644 --- a/CMakeLists.txt -- cgit v1.2.3 From bb5b6b09dcea95ea65797a897fcef143835cedcb Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 17:01:54 +0200 Subject: gnu: python-onnx: Delete bundled software. * gnu/packages/machine-learning.scm (python-onnx)[source]: Delete the 'third_party' directory. --- gnu/packages/machine-learning.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 108bcbdfef..268ec9b5ce 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -591,7 +591,9 @@ in terms of new algorithms.") (uri (pypi-uri "onnx" version)) (patches (search-patches "python-onnx-use-system-googletest.patch")) (sha256 - (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")))) + (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")) + (modules '((guix build utils))) + (snippet '(delete-file-recursively "third_party")))) (build-system python-build-system) (native-inputs `(("cmake" ,cmake) -- cgit v1.2.3 From 2b55f914c3198f9b07399d10502fbdb22b7d6e47 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 17:04:40 +0200 Subject: gnu: python-onnx: Install libonnx.so and libonnx_proto.so. * gnu/packages/patches/python-onnx-shared-libraries.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/machine-learning.scm (python-onnx)[source]: Use it. [arguments]: New field. --- gnu/local.mk | 1 + gnu/packages/machine-learning.scm | 39 +++++++++++++++++++++- .../patches/python-onnx-shared-libraries.patch | 24 +++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/python-onnx-shared-libraries.patch (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/local.mk b/gnu/local.mk index 472b030e6d..798560ca95 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1634,6 +1634,7 @@ dist_patch_DATA = \ %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-onnx-shared-libraries.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 268ec9b5ce..1cea91977f 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -589,12 +589,49 @@ in terms of new algorithms.") (origin (method url-fetch) (uri (pypi-uri "onnx" version)) - (patches (search-patches "python-onnx-use-system-googletest.patch")) + (patches (search-patches "python-onnx-use-system-googletest.patch" + "python-onnx-shared-libraries.patch")) (sha256 (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")) (modules '((guix build utils))) (snippet '(delete-file-recursively "third_party")))) (build-system python-build-system) + (arguments + '(#:phases (modify-phases %standard-phases + (add-before 'build 'pass-cmake-arguments + (lambda* (#:key outputs #:allow-other-keys) + ;; Pass options to the CMake-based build process. + (define out + (assoc-ref outputs "out")) + + (define args + ;; Copy arguments from 'cmake-build-system', plus ask + ;; for shared libraries. + (list "-DCMAKE_BUILD_TYPE=RelWithDebInfo" + (string-append "-DCMAKE_INSTALL_PREFIX=" out) + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" + (string-append "-DCMAKE_INSTALL_RPATH=" out + "/lib") + "-DCMAKE_VERBOSE_MAKEFILE=ON" + + "-DBUILD_SHARED_LIBS=ON")) + + ;; This environment variable is honored by 'setup.py', + ;; which passes it down to 'cmake'. + (setenv "CMAKE_ARGS" (string-join args)) + + ;; This one is honored by 'setup.py' and passed to 'make + ;; -j'. + (setenv "MAX_JOBS" + (number->string (parallel-job-count))))) + (add-after 'install 'install-from-cmake + (lambda _ + ;; Run "make install" in the build tree 'setup.py' + ;; created for CMake so that libonnx.so, + ;; libonnx_proto.so, etc. are installed. + (invoke "make" "install" + "-C" ".setuptools-cmake-build")))))) (native-inputs `(("cmake" ,cmake) ("googletest" ,googletest) diff --git a/gnu/packages/patches/python-onnx-shared-libraries.patch b/gnu/packages/patches/python-onnx-shared-libraries.patch new file mode 100644 index 0000000000..00583b35da --- /dev/null +++ b/gnu/packages/patches/python-onnx-shared-libraries.patch @@ -0,0 +1,24 @@ +These linker options for the 'onnx_cpp2py_export.cpython-38-*-gnu.so' +(or similar) extension are meant to be used when building 'libonn.a', +a static archive. This patch adapts the link flags to linking with +'libonnx.so'. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cede3073..52f846ed 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -475,11 +475,10 @@ if(BUILD_ONNX_PYTHON) + PRIVATE $) + else() + # Assume everything else is like gcc +- target_link_libraries(onnx_cpp2py_export +- PRIVATE "-Wl,--whole-archive" $ +- "-Wl,--no-whole-archive") ++ target_link_libraries(onnx_cpp2py_export PRIVATE onnx) + set_target_properties(onnx_cpp2py_export +- PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") ++ PROPERTIES LINK_FLAGS ++ "-Wl,-rpath=${CMAKE_INSTALL_PREFIX}/lib") + endif() + + target_link_libraries(onnx_cpp2py_export PRIVATE onnx) -- cgit v1.2.3 From fa2d94b5e362c684da812d494463d965e601c18d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 17:19:34 +0200 Subject: gnu: python-onnx: Rename to "onnx". * gnu/packages/machine-learning.scm (python-onnx): Rename to... (onnx): ... this, and change 'name' field accordingly. (python-onnx): New variable. * gnu/packages/patches/python-onnx-shared-libraries.patch: Rename to... * gnu/packages/patches/onnx-shared-libraries.patch: ... this. * gnu/packages/patches/python-onnx-use-system-googletest.patch: Rename to... * gnu/packages/patches/onnx-use-system-googletest.patch: ... this. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. --- gnu/local.mk | 4 +- gnu/packages/machine-learning.scm | 14 ++++-- gnu/packages/patches/onnx-shared-libraries.patch | 24 +++++++++ .../patches/onnx-use-system-googletest.patch | 57 ++++++++++++++++++++++ .../patches/python-onnx-shared-libraries.patch | 24 --------- .../python-onnx-use-system-googletest.patch | 57 ---------------------- 6 files changed, 93 insertions(+), 87 deletions(-) create mode 100644 gnu/packages/patches/onnx-shared-libraries.patch create mode 100644 gnu/packages/patches/onnx-use-system-googletest.patch delete mode 100644 gnu/packages/patches/python-onnx-shared-libraries.patch delete mode 100644 gnu/packages/patches/python-onnx-use-system-googletest.patch (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/local.mk b/gnu/local.mk index 798560ca95..e6c03cbe55 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1512,6 +1512,8 @@ dist_patch_DATA = \ %D%/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch \ %D%/packages/patches/omake-fix-non-determinism.patch \ %D%/packages/patches/oneko-remove-nonfree-characters.patch \ + %D%/packages/patches/onnx-use-system-googletest.patch \ + %D%/packages/patches/onnx-shared-libraries.patch \ %D%/packages/patches/openbabel-fix-crash-on-nwchem-output.patch \ %D%/packages/patches/opencascade-oce-glibc-2.26.patch \ %D%/packages/patches/opencv-fix-build-of-grfmt_jpeg2000.cpp.patch \ @@ -1633,8 +1635,6 @@ 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-onnx-shared-libraries.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 1cea91977f..75faeb8eb8 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -581,16 +581,16 @@ tools. This enables both rapid prototyping of data pipelines and extensibility in terms of new algorithms.") (license license:gpl3+))) -(define-public python-onnx +(define-public onnx (package - (name "python-onnx") + (name "onnx") (version "1.9.0") (source (origin (method url-fetch) (uri (pypi-uri "onnx" version)) - (patches (search-patches "python-onnx-use-system-googletest.patch" - "python-onnx-shared-libraries.patch")) + (patches (search-patches "onnx-use-system-googletest.patch" + "onnx-shared-libraries.patch")) (sha256 (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")) (modules '((guix build utils))) @@ -658,6 +658,12 @@ computation graph model, as well as definitions of built-in operators and standard data types.") (license license:expat))) +(define-public python-onnx + ;; This used to be called "python-onnx" because it provided nothing but + ;; Python bindings. The package now provides shared libraries and C++ + ;; headers, hence the name change. + (deprecated-package "python-onnx" onnx)) + (define-public rxcpp (package (name "rxcpp") diff --git a/gnu/packages/patches/onnx-shared-libraries.patch b/gnu/packages/patches/onnx-shared-libraries.patch new file mode 100644 index 0000000000..00583b35da --- /dev/null +++ b/gnu/packages/patches/onnx-shared-libraries.patch @@ -0,0 +1,24 @@ +These linker options for the 'onnx_cpp2py_export.cpython-38-*-gnu.so' +(or similar) extension are meant to be used when building 'libonn.a', +a static archive. This patch adapts the link flags to linking with +'libonnx.so'. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cede3073..52f846ed 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -475,11 +475,10 @@ if(BUILD_ONNX_PYTHON) + PRIVATE $) + else() + # Assume everything else is like gcc +- target_link_libraries(onnx_cpp2py_export +- PRIVATE "-Wl,--whole-archive" $ +- "-Wl,--no-whole-archive") ++ target_link_libraries(onnx_cpp2py_export PRIVATE onnx) + set_target_properties(onnx_cpp2py_export +- PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") ++ PROPERTIES LINK_FLAGS ++ "-Wl,-rpath=${CMAKE_INSTALL_PREFIX}/lib") + endif() + + target_link_libraries(onnx_cpp2py_export PRIVATE onnx) diff --git a/gnu/packages/patches/onnx-use-system-googletest.patch b/gnu/packages/patches/onnx-use-system-googletest.patch new file mode 100644 index 0000000000..5dfcbc6dc3 --- /dev/null +++ b/gnu/packages/patches/onnx-use-system-googletest.patch @@ -0,0 +1,57 @@ +ONNX will build googletest from a Git checkout. Patch CMake to use our +googletest package and enable tests by default. + +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} diff --git a/gnu/packages/patches/python-onnx-shared-libraries.patch b/gnu/packages/patches/python-onnx-shared-libraries.patch deleted file mode 100644 index 00583b35da..0000000000 --- a/gnu/packages/patches/python-onnx-shared-libraries.patch +++ /dev/null @@ -1,24 +0,0 @@ -These linker options for the 'onnx_cpp2py_export.cpython-38-*-gnu.so' -(or similar) extension are meant to be used when building 'libonn.a', -a static archive. This patch adapts the link flags to linking with -'libonnx.so'. - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index cede3073..52f846ed 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -475,11 +475,10 @@ if(BUILD_ONNX_PYTHON) - PRIVATE $) - else() - # Assume everything else is like gcc -- target_link_libraries(onnx_cpp2py_export -- PRIVATE "-Wl,--whole-archive" $ -- "-Wl,--no-whole-archive") -+ target_link_libraries(onnx_cpp2py_export PRIVATE onnx) - set_target_properties(onnx_cpp2py_export -- PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") -+ PROPERTIES LINK_FLAGS -+ "-Wl,-rpath=${CMAKE_INSTALL_PREFIX}/lib") - endif() - - target_link_libraries(onnx_cpp2py_export PRIVATE onnx) diff --git a/gnu/packages/patches/python-onnx-use-system-googletest.patch b/gnu/packages/patches/python-onnx-use-system-googletest.patch deleted file mode 100644 index 5dfcbc6dc3..0000000000 --- a/gnu/packages/patches/python-onnx-use-system-googletest.patch +++ /dev/null @@ -1,57 +0,0 @@ -ONNX will build googletest from a Git checkout. Patch CMake to use our -googletest package and enable tests by default. - -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} -- cgit v1.2.3 From 630c39d8df7557b6a0941c1d5ee879e487de0f5e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 17:26:24 +0200 Subject: gnu: onnx: Change source to 'git-fetch'. * gnu/packages/machine-learning.scm (onnx)[source]: Change to 'git-fetch'. Add "onnx-skip-model-downloads.patch". [arguments]: Add 'make-test-directory-writable' phase. * gnu/packages/patches/onnx-skip-model-downloads.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + gnu/packages/machine-learning.scm | 31 +++++++++++++++------- .../patches/onnx-skip-model-downloads.patch | 16 +++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 gnu/packages/patches/onnx-skip-model-downloads.patch (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/local.mk b/gnu/local.mk index e6c03cbe55..450d9574b0 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1514,6 +1514,7 @@ dist_patch_DATA = \ %D%/packages/patches/oneko-remove-nonfree-characters.patch \ %D%/packages/patches/onnx-use-system-googletest.patch \ %D%/packages/patches/onnx-shared-libraries.patch \ + %D%/packages/patches/onnx-skip-model-downloads.patch \ %D%/packages/patches/openbabel-fix-crash-on-nwchem-output.patch \ %D%/packages/patches/opencascade-oce-glibc-2.26.patch \ %D%/packages/patches/opencv-fix-build-of-grfmt_jpeg2000.cpp.patch \ diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 75faeb8eb8..177d1aaa4f 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -585,16 +585,20 @@ in terms of new algorithms.") (package (name "onnx") (version "1.9.0") - (source - (origin - (method url-fetch) - (uri (pypi-uri "onnx" version)) - (patches (search-patches "onnx-use-system-googletest.patch" - "onnx-shared-libraries.patch")) - (sha256 - (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")) - (modules '((guix build utils))) - (snippet '(delete-file-recursively "third_party")))) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/onnx/onnx") + (commit (string-append "v" version)))) + (sha256 + (base32 + "1xnii361f68x0masxgfc4ai7hh3wlxxk56aznwf4m4yr6wqx47ml")) + (file-name (git-file-name name version)) + (patches (search-patches "onnx-use-system-googletest.patch" + "onnx-shared-libraries.patch" + "onnx-skip-model-downloads.patch")) + (modules '((guix build utils))) + (snippet '(delete-file-recursively "third_party")))) (build-system python-build-system) (arguments '(#:phases (modify-phases %standard-phases @@ -625,6 +629,13 @@ in terms of new algorithms.") ;; -j'. (setenv "MAX_JOBS" (number->string (parallel-job-count))))) + (add-before 'check 'make-test-directory-writable + (lambda _ + ;; Make things writable for tests. + (setenv "HOME" (getcwd)) + (for-each make-file-writable + (find-files "onnx/examples" "." + #:directories? #t)))) (add-after 'install 'install-from-cmake (lambda _ ;; Run "make install" in the build tree 'setup.py' diff --git a/gnu/packages/patches/onnx-skip-model-downloads.patch b/gnu/packages/patches/onnx-skip-model-downloads.patch new file mode 100644 index 0000000000..4ab55b4ceb --- /dev/null +++ b/gnu/packages/patches/onnx-skip-model-downloads.patch @@ -0,0 +1,16 @@ +A few tests require downloading models from URLs such as + . +Skip those. + +diff --git a/onnx/backend/test/runner/__init__.py b/onnx/backend/test/runner/__init__.py +index 049ed57b..f236f1bf 100644 +--- a/onnx/backend/test/runner/__init__.py ++++ b/onnx/backend/test/runner/__init__.py +@@ -202,6 +202,7 @@ class Runner(object): + print('Start downloading model {} from {}'.format( + model_test.model_name, + model_test.url)) ++ raise unittest.SkipTest('Skipping download') + urlretrieve(model_test.url, download_file.name) + print('Done') + with tarfile.open(download_file.name) as t: -- cgit v1.2.3