aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/machine-learning.scm23
-rw-r--r--gnu/packages/patches/onnx-1.13.1-use-system-googletest.patch55
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