diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2023-12-27 16:13:30 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2024-01-01 14:35:12 +0100 |
commit | 43c92f323e1750d2d3661b419e53c45c673501af (patch) | |
tree | 5fe715fefdcdd5c3f66bf81329e5de07dba436fb | |
parent | 77204306783ef7aae8b44bcafe699cbe35fb761d (diff) | |
download | guix-43c92f323e1750d2d3661b419e53c45c673501af.tar.gz guix-43c92f323e1750d2d3661b419e53c45c673501af.zip |
gnu: Add onnx-for-torch2.
* gnu/packages/machine-learning.scm (onnx-for-torch2): New variable.
* gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
Change-Id: I8a46b9a8096a33bcf949bc4f5d497e22902ab301
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/machine-learning.scm | 23 | ||||
-rw-r--r-- | gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch | 55 |
3 files changed, 79 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index a6167ee95a..4de5603091 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1720,6 +1720,7 @@ dist_patch_DATA = \ %D%/packages/patches/online-judge-tools.patch \ %D%/packages/patches/onnx-optimizer-system-library.patch \ %D%/packages/patches/onnx-use-system-googletest.patch \ + %D%/packages/patches/onnx-1.13.1-use-system-googletest.patch \ %D%/packages/patches/onnx-shared-libraries.patch \ %D%/packages/patches/onnx-skip-model-downloads.patch \ %D%/packages/patches/openbios-aarch64-riscv64-support.patch \ diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index c27b4b394b..bef4d62163 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -1214,6 +1214,29 @@ an extensible computation graph model, as well as definitions of built-in operators and standard data types.") (license license:expat))) +(define-public onnx-for-torch2 + (package + (inherit onnx) + (name "onnx") + (version "1.13.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/onnx/onnx") + (commit (string-append "v" version)))) + (sha256 + (base32 + "16967dbq2j40diqd0s37r19llsab8q8vbxkg1ppgy0p9fpdhfhyp")) + (file-name (git-file-name name version)) + (patches (search-patches "onnx-1.13.1-use-system-googletest.patch" + "onnx-shared-libraries.patch")) + (modules '((guix build utils))) + (snippet + '(begin + (delete-file-recursively "third_party") + (substitute* "onnx/backend/test/runner/__init__.py" + (("urlretrieve\\(.*") "raise unittest.SkipTest('Skipping download')\n")))))))) + (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++ diff --git a/gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch b/gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch new file mode 100644 index 0000000000..b6a5e5d828 --- /dev/null +++ b/gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch @@ -0,0 +1,55 @@ +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 +@@ -7,7 +7,7 @@ + + find_package(Threads) + +-set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES}) ++set(${UT_NAME}_libs ${GTEST_LIBRARIES}) + + list(APPEND ${UT_NAME}_libs onnx) + list(APPEND ${UT_NAME}_libs onnx_proto) +@@ -22,9 +22,9 @@ + 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}
\ No newline at end of file |