Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
8b787eb9 | 2 | ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Ricardo Wurmus <rekado@elephly.net> |
53a8e8fd | 3 | ;;; Copyright © 2016, 2020, 2021, 2022 Efraim Flashner <efraim@flashner.co.il> |
382550f0 | 4 | ;;; Copyright © 2016, 2017, 2020 Marius Bakke <mbakke@fastmail.com> |
be6eb2f1 | 5 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> |
d2a7cb46 | 6 | ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
3a354e10 | 7 | ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net> |
a9b34762 MM |
8 | ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org> |
9 | ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com> | |
2dab4188 | 10 | ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com> |
564cf93f | 11 | ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> |
df4c8434 | 12 | ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de> |
d60b064d | 13 | ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr> |
5dc04da4 | 14 | ;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net> |
5e42d197 | 15 | ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> |
d9e9a261 | 16 | ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> |
bcbd6340 | 17 | ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com> |
c30fa177 | 18 | ;;; Copyright © 2020, 2021, 2022 Vinicius Monego <monego@posteo.net> |
1d1f44b7 | 19 | ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
741115b6 RW |
20 | ;;; |
21 | ;;; This file is part of GNU Guix. | |
22 | ;;; | |
23 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
24 | ;;; under the terms of the GNU General Public License as published by | |
25 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
26 | ;;; your option) any later version. | |
27 | ;;; | |
28 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
29 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
30 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
31 | ;;; GNU General Public License for more details. | |
32 | ;;; | |
33 | ;;; You should have received a copy of the GNU General Public License | |
34 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
35 | ||
36 | (define-module (gnu packages machine-learning) | |
37 | #:use-module ((guix licenses) #:prefix license:) | |
f9d3f74a | 38 | #:use-module (guix gexp) |
741115b6 RW |
39 | #:use-module (guix packages) |
40 | #:use-module (guix utils) | |
41 | #:use-module (guix download) | |
23aab4ab | 42 | #:use-module (guix svn-download) |
c1670a81 | 43 | #:use-module (guix build-system cmake) |
741115b6 | 44 | #:use-module (guix build-system gnu) |
0a3063d6 | 45 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 46 | #:use-module (guix build-system python) |
8406138b | 47 | #:use-module (guix build-system r) |
a9b34762 | 48 | #:use-module (guix git-download) |
71f80f54 | 49 | #:use-module (gnu packages) |
0dfeb285 | 50 | #:use-module (gnu packages adns) |
5a14e81e | 51 | #:use-module (gnu packages algebra) |
b9445d0b | 52 | #:use-module (gnu packages audio) |
23aab4ab | 53 | #:use-module (gnu packages autotools) |
b9445d0b | 54 | #:use-module (gnu packages base) |
99260014 | 55 | #:use-module (gnu packages bash) |
0931c609 | 56 | #:use-module (gnu packages boost) |
06b51c68 | 57 | #:use-module (gnu packages bdw-gc) |
be6eb2f1 | 58 | #:use-module (gnu packages check) |
0931c609 | 59 | #:use-module (gnu packages compression) |
b6540374 | 60 | #:use-module (gnu packages cmake) |
c1e41109 | 61 | #:use-module (gnu packages cpp) |
9e37e537 | 62 | #:use-module (gnu packages cran) |
4fa16c9a | 63 | #:use-module (gnu packages databases) |
23aab4ab | 64 | #:use-module (gnu packages dejagnu) |
0931c609 | 65 | #:use-module (gnu packages gcc) |
f9d3f74a RW |
66 | #:use-module (gnu packages gettext) |
67 | #:use-module (gnu packages gl) | |
b9445d0b | 68 | #:use-module (gnu packages glib) |
f1765b57 | 69 | #:use-module (gnu packages graphviz) |
b9445d0b | 70 | #:use-module (gnu packages gstreamer) |
f9d3f74a RW |
71 | #:use-module (gnu packages guile) |
72 | #:use-module (gnu packages haskell-xyz) | |
5f0ff6a9 | 73 | #:use-module (gnu packages image) |
f9d3f74a RW |
74 | #:use-module (gnu packages image-processing) |
75 | #:use-module (gnu packages imagemagick) | |
6416e772 | 76 | #:use-module (gnu packages jupyter) |
dd55ad7f | 77 | #:use-module (gnu packages libffi) |
b9445d0b | 78 | #:use-module (gnu packages linux) |
8cd10a76 | 79 | #:use-module (gnu packages llvm) |
0931c609 | 80 | #:use-module (gnu packages maths) |
112c2c01 | 81 | #:use-module (gnu packages mpi) |
dd55ad7f | 82 | #:use-module (gnu packages ninja) |
0a3063d6 | 83 | #:use-module (gnu packages ocaml) |
3929f46c | 84 | #:use-module (gnu packages onc-rpc) |
b402a3ec | 85 | #:use-module (gnu packages parallel) |
791c11d6 | 86 | #:use-module (gnu packages perl) |
c1670a81 | 87 | #:use-module (gnu packages pkg-config) |
0dfeb285 | 88 | #:use-module (gnu packages protobuf) |
f9d3f74a | 89 | #:use-module (gnu packages pulseaudio) |
0931c609 | 90 | #:use-module (gnu packages python) |
13bb41f8 | 91 | #:use-module (gnu packages python-build) |
b6540374 | 92 | #:use-module (gnu packages python-check) |
ec1224a7 | 93 | #:use-module (gnu packages python-science) |
10451f6b | 94 | #:use-module (gnu packages python-web) |
44d10b1f | 95 | #:use-module (gnu packages python-xyz) |
c61557b1 | 96 | #:use-module (gnu packages rpc) |
4fa16c9a | 97 | #:use-module (gnu packages serialization) |
f1765b57 | 98 | #:use-module (gnu packages sphinx) |
c1670a81 | 99 | #:use-module (gnu packages statistics) |
4fa16c9a | 100 | #:use-module (gnu packages sqlite) |
c1670a81 | 101 | #:use-module (gnu packages swig) |
36f7e1d7 | 102 | #:use-module (gnu packages tls) |
f9d3f74a | 103 | #:use-module (gnu packages video) |
99260014 | 104 | #:use-module (gnu packages web) |
5f0ff6a9 | 105 | #:use-module (gnu packages xml) |
39bb4937 RW |
106 | #:use-module (gnu packages xorg) |
107 | #:use-module (ice-9 match)) | |
741115b6 | 108 | |
a9b34762 MM |
109 | (define-public fann |
110 | ;; The last release is >100 commits behind, so we package from git. | |
111 | (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7")) | |
112 | (package | |
113 | (name "fann") | |
114 | (version (string-append "2.2.0-1." (string-take commit 8))) | |
115 | (source (origin | |
116 | (method git-fetch) | |
117 | (uri (git-reference | |
b0e7b699 | 118 | (url "https://github.com/libfann/fann") |
a9b34762 MM |
119 | (commit commit))) |
120 | (file-name (string-append name "-" version "-checkout")) | |
121 | (sha256 | |
122 | (base32 | |
123 | "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x")))) | |
124 | (build-system cmake-build-system) | |
125 | (arguments | |
126 | `(#:phases | |
127 | (modify-phases %standard-phases | |
128 | (replace 'check | |
129 | (lambda* (#:key outputs #:allow-other-keys) | |
130 | (let* ((out (assoc-ref outputs "out"))) | |
131 | (with-directory-excursion (string-append (getcwd) "/tests") | |
132 | (invoke "./fann_tests")))))))) | |
133 | (home-page "http://leenissen.dk/fann/wp/") | |
134 | (synopsis "Fast Artificial Neural Network") | |
135 | (description | |
bd2bd80d MB |
136 | "FANN is a neural network library, which implements multilayer |
137 | artificial neural networks in C with support for both fully connected and | |
138 | sparsely connected networks.") | |
a9b34762 MM |
139 | (license license:lgpl2.1)))) |
140 | ||
741115b6 RW |
141 | (define-public libsvm |
142 | (package | |
143 | (name "libsvm") | |
2cffa2f2 | 144 | (version "3.23") |
741115b6 RW |
145 | (source |
146 | (origin | |
147 | (method url-fetch) | |
d1308c5e TGR |
148 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
149 | name "-" version ".tar.gz")) | |
741115b6 | 150 | (sha256 |
2cffa2f2 | 151 | (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5")))) |
741115b6 RW |
152 | (build-system gnu-build-system) |
153 | (arguments | |
2cffa2f2 | 154 | `(#:tests? #f ; no "check" target |
4fb363c9 RW |
155 | #:phases |
156 | (modify-phases %standard-phases | |
157 | (delete 'configure) | |
158 | (add-after 'build 'build-lib | |
159 | (lambda _ | |
160 | (invoke "make" "lib"))) | |
161 | (replace 'install ; no ‘install’ target | |
162 | (lambda* (#:key outputs #:allow-other-keys) | |
163 | (let* ((out (assoc-ref outputs "out")) | |
164 | (bin (string-append out "/bin/")) | |
165 | (lib (string-append out "/lib/")) | |
166 | (inc (string-append out "/include/libsvm"))) | |
167 | (mkdir-p bin) | |
168 | (for-each (lambda (file) | |
169 | (copy-file file (string-append bin file))) | |
170 | '("svm-train" | |
171 | "svm-predict" | |
172 | "svm-scale")) | |
173 | (mkdir-p lib) | |
174 | (install-file "libsvm.so.2" lib) | |
175 | (mkdir-p inc) | |
176 | (install-file "svm.h" inc))))))) | |
62290cd4 | 177 | (home-page "https://www.csie.ntu.edu.tw/~cjlin/libsvm/") |
741115b6 RW |
178 | (synopsis "Library for Support Vector Machines") |
179 | (description | |
180 | "LIBSVM is a machine learning library for support vector | |
181 | classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and | |
182 | distribution estimation (one-class SVM). It supports multi-class | |
183 | classification.") | |
184 | (license license:bsd-3))) | |
71f80f54 RW |
185 | |
186 | (define-public python-libsvm | |
187 | (package (inherit libsvm) | |
188 | (name "python-libsvm") | |
189 | (build-system gnu-build-system) | |
190 | (arguments | |
2cffa2f2 | 191 | `(#:tests? #f ; no "check" target |
71f80f54 RW |
192 | #:make-flags '("-C" "python") |
193 | #:phases | |
194 | (modify-phases %standard-phases | |
195 | (delete 'configure) | |
196 | (replace | |
d1308c5e | 197 | 'install ; no ‘install’ target |
71f80f54 RW |
198 | (lambda* (#:key inputs outputs #:allow-other-keys) |
199 | (let ((site (string-append (assoc-ref outputs "out") | |
200 | "/lib/python" | |
201 | (string-take | |
202 | (string-take-right | |
203 | (assoc-ref inputs "python") 5) 3) | |
204 | "/site-packages/"))) | |
205 | (substitute* "python/svm.py" | |
206 | (("../libsvm.so.2") "libsvm.so.2")) | |
207 | (mkdir-p site) | |
208 | (for-each (lambda (file) | |
209 | (copy-file file (string-append site (basename file)))) | |
210 | (find-files "python" "\\.py")) | |
211 | (copy-file "libsvm.so.2" | |
212 | (string-append site "libsvm.so.2"))) | |
213 | #t))))) | |
214 | (inputs | |
8394619b | 215 | (list python)) |
71f80f54 | 216 | (synopsis "Python bindings of libSVM"))) |
0931c609 | 217 | |
23aab4ab RW |
218 | (define-public ghmm |
219 | ;; The latest release candidate is several years and a couple of fixes have | |
220 | ;; been published since. This is why we download the sources from the SVN | |
221 | ;; repository. | |
222 | (let ((svn-revision 2341)) | |
223 | (package | |
224 | (name "ghmm") | |
225 | (version (string-append "0.9-rc3-0." (number->string svn-revision))) | |
226 | (source (origin | |
227 | (method svn-fetch) | |
228 | (uri (svn-reference | |
229 | (url "http://svn.code.sf.net/p/ghmm/code/trunk") | |
230 | (revision svn-revision))) | |
e3a69938 | 231 | (file-name (string-append name "-" version "-checkout")) |
23aab4ab RW |
232 | (sha256 |
233 | (base32 | |
234 | "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq")))) | |
235 | (build-system gnu-build-system) | |
236 | (arguments | |
ced12a7b RW |
237 | `(#:imported-modules (,@%gnu-build-system-modules |
238 | (guix build python-build-system)) | |
3cb8cb66 MB |
239 | #:modules ((guix build python-build-system) |
240 | ,@%gnu-build-system-modules) | |
ced12a7b | 241 | #:phases |
23aab4ab RW |
242 | (modify-phases %standard-phases |
243 | (add-after 'unpack 'enter-dir | |
e3bc7881 | 244 | (lambda _ (chdir "ghmm"))) |
23aab4ab RW |
245 | (add-after 'enter-dir 'fix-runpath |
246 | (lambda* (#:key outputs #:allow-other-keys) | |
247 | (substitute* "ghmmwrapper/setup.py" | |
248 | (("^(.*)extra_compile_args = \\[" line indent) | |
249 | (string-append indent | |
250 | "extra_link_args = [\"-Wl,-rpath=" | |
251 | (assoc-ref outputs "out") "/lib\"],\n" | |
252 | line | |
253 | "\"-Wl,-rpath=" | |
254 | (assoc-ref outputs "out") | |
e3bc7881 | 255 | "/lib\", "))))) |
23aab4ab RW |
256 | (add-after 'enter-dir 'disable-broken-tests |
257 | (lambda _ | |
258 | (substitute* "tests/Makefile.am" | |
259 | ;; GHMM_SILENT_TESTS is assumed to be a command. | |
260 | (("TESTS_ENVIRONMENT.*") "") | |
261 | ;; Do not build broken tests. | |
262 | (("chmm .*") "") | |
263 | (("read_fa .*") "") | |
264 | (("mcmc .*") "") | |
265 | (("label_higher_order_test.*$") | |
266 | "label_higher_order_test\n")) | |
267 | ||
268 | ;; These Python unittests are broken as there is no gato. | |
269 | ;; See https://sourceforge.net/p/ghmm/support-requests/3/ | |
270 | (substitute* "ghmmwrapper/ghmmunittests.py" | |
271 | (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)" | |
272 | line indent) | |
273 | (string-append indent | |
274 | "@unittest.skip(\"Disabled by Guix\")\n" | |
e3bc7881 | 275 | line)))))))) |
23aab4ab RW |
276 | (inputs |
277 | `(("python" ,python-2) ; only Python 2 is supported | |
278 | ("libxml2" ,libxml2))) | |
279 | (native-inputs | |
8394619b LC |
280 | (list pkg-config |
281 | dejagnu | |
282 | swig | |
283 | autoconf | |
284 | automake | |
285 | libtool)) | |
23aab4ab RW |
286 | (home-page "http://ghmm.org") |
287 | (synopsis "Hidden Markov Model library") | |
288 | (description | |
289 | "The General Hidden Markov Model library (GHMM) is a C library with | |
290 | additional Python bindings implementing a wide range of types of @dfn{Hidden | |
d1e4ad1b | 291 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
292 | training, HMM clustering, HMM mixtures.") |
293 | (license license:lgpl2.0+)))) | |
294 | ||
f9d3f74a RW |
295 | (define-public guile-aiscm |
296 | (package | |
297 | (name "guile-aiscm") | |
298 | (version "0.23.1") | |
299 | (source (origin | |
300 | (method git-fetch) | |
301 | (uri (git-reference | |
302 | (url "https://github.com/wedesoft/aiscm") | |
303 | (commit "c78b91edb7c17c6fbf3b294452f44e91d75e3c67"))) | |
304 | (file-name (git-file-name name version)) | |
305 | (sha256 | |
306 | (base32 | |
307 | "09rdbcr8dinzijyx9h940ann91yjlbg0fangx365llhvy354n840")))) | |
308 | (build-system gnu-build-system) | |
309 | (arguments | |
310 | (list | |
311 | #:make-flags | |
312 | #~(list (string-append "GUILE_CACHE=" #$output "/lib/guile/3.0/site-ccache") | |
313 | (string-append "GUILE_EXT=" #$output "/lib/guile/3.0/extensions") | |
314 | (string-append "GUILE_SITE=" #$output "/share/guile/site/3.0")) | |
315 | #:phases | |
316 | '(modify-phases %standard-phases | |
50bd2b33 RW |
317 | (add-after 'unpack 'build-reproducibly |
318 | (lambda _ | |
319 | (substitute* "doc/Makefile.am" | |
320 | (("\\$\\(DATE\\)") "1970-01-01")))) | |
f9d3f74a RW |
321 | (add-after 'unpack 'use-llvm-config |
322 | (lambda _ | |
323 | (substitute* "m4/ax_llvmc.m4" | |
324 | (("llvm-config-13") "llvm-config") | |
325 | ;; For some reason this library is not on the link list. | |
326 | (("(LLVM_LIBS=\"\\$\\(\\$ac_llvm_config_path --libs \\$1\\))\"" _ m) | |
327 | (string-append m " -lLLVMMCJIT\""))) | |
328 | ||
329 | ;; Because of this message: | |
330 | ;; symbol lookup error: ./.libs/libguile-aiscm-core.so: undefined symbol: LLVMInitializeX86TargetInfo | |
331 | ;; This probably needs to differ when building on architectures | |
332 | ;; other than x86_64p | |
333 | (substitute* "aiscm/Makefile.am" | |
334 | (("LLVM_LIBS\\)") "LLVM_LIBS) \ | |
335 | -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info")))) | |
336 | ;; Use Clang instead of GCC. | |
337 | (add-before 'configure 'prepare-build-environment | |
338 | (lambda _ | |
339 | (setenv "AR" "llvm-ar") | |
340 | (setenv "NM" "llvm-nm") | |
341 | (setenv "CC" "clang") | |
342 | (setenv "CXX" "clang++")))))) | |
343 | (inputs | |
344 | (list ffmpeg | |
345 | freeglut | |
346 | guile-3.0 | |
347 | imagemagick | |
348 | libjpeg-turbo | |
349 | libomp | |
350 | libxi | |
351 | libxmu | |
352 | libxpm | |
353 | libxt | |
354 | libxv | |
355 | mesa | |
356 | mjpegtools | |
f9d3f74a | 357 | pandoc |
f44305bc | 358 | pulseaudio)) |
f9d3f74a RW |
359 | (native-inputs |
360 | (list clang-13 | |
361 | llvm-13 | |
362 | pkg-config | |
363 | autoconf | |
364 | automake | |
365 | gettext-minimal | |
366 | libtool | |
367 | which)) | |
368 | (home-page "https://wedesoft.github.io/aiscm/") | |
369 | (synopsis "Guile extension for numerical arrays and tensors") | |
370 | (description "AIscm is a Guile extension for numerical arrays and tensors. | |
371 | Performance is achieved by using the LLVM JIT compiler.") | |
372 | (license license:gpl3+))) | |
373 | ||
06b51c68 RW |
374 | (define-public guile-aiscm-next |
375 | (let ((commit "b17ed538c303badc419a7c358d91f266d2a8c354") | |
376 | (revision "1")) | |
377 | (package | |
378 | (inherit guile-aiscm) | |
379 | (name "guile-aiscm-next") | |
380 | (version (git-version "0.23.1" revision commit)) | |
381 | (source (origin | |
382 | (method git-fetch) | |
383 | (uri (git-reference | |
384 | (url "https://github.com/wedesoft/aiscm") | |
385 | (commit commit))) | |
386 | (file-name (git-file-name name version)) | |
387 | (sha256 | |
388 | (base32 | |
389 | "0px7r7lfskbp1prdrfrcvrsc4wjrk3ahkigsw4pqvny6zs7jnvc0")))) | |
390 | (arguments | |
391 | (substitute-keyword-arguments (package-arguments guile-aiscm) | |
392 | ((#:configure-flags flags '()) | |
393 | #~(list (string-append "OPENCV_CFLAGS=-I" #$(this-package-input "opencv") | |
394 | "/include/opencv4") | |
395 | (let ((modules | |
396 | (list "aruco" "barcode" "bgsegm" "bioinspired" | |
397 | "calib3d" "ccalib" "core" "datasets" "dnn" | |
398 | "dnn_objdetect" "dnn_superres" "dpm" "face" | |
399 | "features2d" "flann" "freetype" "fuzzy" "hdf" | |
400 | "hfs" "highgui" "img_hash" "imgcodecs" "imgproc" | |
401 | "intensity_transform" "line_descriptor" "mcc" | |
402 | "ml" "objdetect" "optflow" "phase_unwrapping" | |
403 | "photo" "plot" "quality" "rapid" "reg" "rgbd" | |
404 | "saliency" "shape" "stereo" "stitching" | |
405 | "structured_light" "superres" "surface_matching" | |
406 | "text" "tracking" "video" "videoio" "videostab" | |
407 | "wechat_qrcode" "ximgproc" "xobjdetect" "xphoto"))) | |
408 | (format #false "OPENCV_LIBS=~{-lopencv_~a~^ ~}" modules)))) | |
409 | ((#:phases phases '%standard-phases) | |
410 | `(modify-phases ,phases | |
411 | (add-after 'unpack 'find-clearsilver | |
412 | (lambda* (#:key inputs #:allow-other-keys) | |
413 | (substitute* "configure.ac" | |
414 | (("/usr/local/include/ClearSilver") | |
415 | (string-append (assoc-ref inputs "clearsilver") | |
416 | "/include/ClearSilver"))) | |
417 | (substitute* "aiscm/Makefile.am" | |
418 | (("-lneo_utl" m) | |
419 | (string-append m " -lstreamhtmlparser"))) | |
420 | (setenv "C_INCLUDE_PATH" | |
421 | (string-append (assoc-ref inputs "clearsilver") | |
422 | "/include/ClearSilver:" | |
423 | (or (getenv "C_INCLUDE_PATH") ""))))) | |
424 | ;; This test fails because our version of tensorflow is too old | |
425 | ;; to provide tf-string-length. | |
426 | (add-after 'unpack 'disable-broken-test | |
427 | (lambda _ | |
428 | (substitute* "tests/test_tensorflow.scm" | |
429 | (("\\(test-eqv \"determine string length" m) | |
430 | (string-append "#;" m))))))))) | |
431 | (inputs | |
432 | (modify-inputs (package-inputs guile-aiscm) | |
433 | (append clearsilver opencv tensorflow libgc))) | |
434 | (native-inputs | |
435 | (modify-inputs (package-native-inputs guile-aiscm) | |
436 | (append protobuf-c)))))) | |
437 | ||
791c11d6 BW |
438 | (define-public mcl |
439 | (package | |
440 | (name "mcl") | |
441 | (version "14.137") | |
442 | (source (origin | |
443 | (method url-fetch) | |
444 | (uri (string-append | |
445 | "http://micans.org/mcl/src/mcl-" | |
446 | (string-replace-substring version "." "-") | |
447 | ".tar.gz")) | |
448 | (sha256 | |
449 | (base32 | |
450 | "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m")))) | |
451 | (build-system gnu-build-system) | |
452 | (arguments | |
c25a6d39 RW |
453 | `(#:configure-flags (list "--enable-blast" |
454 | "CFLAGS=-fcommon"))) | |
791c11d6 | 455 | (inputs |
8394619b | 456 | (list perl)) |
791c11d6 BW |
457 | (home-page "http://micans.org/mcl/") |
458 | (synopsis "Clustering algorithm for graphs") | |
459 | (description | |
460 | "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a | |
461 | fast and scalable unsupervised cluster algorithm for graphs (also known as | |
462 | networks) based on simulation of (stochastic) flow in graphs.") | |
463 | ;; In the LICENCE file and web page it says "The software is licensed | |
464 | ;; under the GNU General Public License, version 3.", but in several of | |
465 | ;; the source code files it suggests GPL3 or later. | |
466 | ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html | |
467 | (license license:gpl3))) | |
468 | ||
0a3063d6 BW |
469 | (define-public ocaml-mcl |
470 | (package | |
471 | (name "ocaml-mcl") | |
472 | (version "12-068oasis4") | |
473 | (source | |
474 | (origin | |
fb168a31 RW |
475 | (method git-fetch) |
476 | (uri (git-reference | |
b0e7b699 | 477 | (url "https://github.com/fhcrc/mcl") |
fb168a31 RW |
478 | (commit version))) |
479 | (file-name (git-file-name name version)) | |
0a3063d6 BW |
480 | (sha256 |
481 | (base32 | |
fb168a31 | 482 | "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p")))) |
0a3063d6 BW |
483 | (build-system ocaml-build-system) |
484 | (arguments | |
b24aaeec | 485 | `(#:phases |
0a3063d6 BW |
486 | (modify-phases %standard-phases |
487 | (add-before 'configure 'patch-paths | |
488 | (lambda _ | |
0a3063d6 BW |
489 | (substitute* "setup.ml" |
490 | (("LDFLAGS=-fPIC") | |
b24aaeec | 491 | (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))) |
c8060055 | 492 | (("-std=c89") "-std=gnu99 -fcommon") |
b24aaeec RW |
493 | |
494 | ;; This is a mutable string, which is no longer supported. Use | |
495 | ;; a byte buffer instead. | |
496 | (("String.make \\(String.length s\\)") | |
497 | "Bytes.make (String.length s)") | |
498 | ||
499 | ;; These two belong together. | |
500 | (("OASISString.replace_chars") | |
501 | "Bytes.to_string (OASISString.replace_chars") | |
502 | ((" s;") | |
503 | " s);")) | |
504 | (substitute* "myocamlbuild.ml" | |
c8060055 | 505 | (("std=c89") "std=gnu99 -fcommon")) |
b24aaeec RW |
506 | ;; Since we build with a more recent OCaml, we have to use C99 or |
507 | ;; later. This causes problems with the old C code. | |
508 | (substitute* "src/impala/matrix.c" | |
509 | (("restrict") "restrict_")) | |
0a3063d6 | 510 | #t))))) |
b24aaeec | 511 | (native-inputs |
8394619b | 512 | (list ocamlbuild)) |
0a3063d6 BW |
513 | (home-page "https://github.com/fhcrc/mcl") |
514 | (synopsis "OCaml wrappers around MCL") | |
515 | (description | |
516 | "This package provides OCaml bindings for the MCL graph clustering | |
517 | algorithm.") | |
518 | (license license:gpl3))) | |
519 | ||
0931c609 RW |
520 | (define-public randomjungle |
521 | (package | |
522 | (name "randomjungle") | |
523 | (version "2.1.0") | |
524 | (source | |
525 | (origin | |
526 | (method url-fetch) | |
527 | (uri (string-append | |
df4c8434 BH |
528 | "https://www.imbs.uni-luebeck.de/fileadmin/files/Software" |
529 | "/randomjungle/randomjungle-" version ".tar_.gz")) | |
1e92d311 | 530 | (patches (search-patches "randomjungle-disable-static-build.patch")) |
0931c609 RW |
531 | (sha256 |
532 | (base32 | |
533 | "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w")))) | |
534 | (build-system gnu-build-system) | |
535 | (arguments | |
536 | `(#:configure-flags | |
1e92d311 MB |
537 | (list "--disable-static" |
538 | (string-append "--with-boost=" | |
0931c609 RW |
539 | (assoc-ref %build-inputs "boost"))) |
540 | #:phases | |
541 | (modify-phases %standard-phases | |
cd40978a RW |
542 | (add-after 'unpack 'fix-compatibility-errors |
543 | (lambda _ | |
544 | (substitute* "src/library/IAM2WayImportance.h" | |
545 | (("= std::make_pair.*") | |
546 | "= std::minmax(varID1, varID2);")) | |
547 | (substitute* "src/library/DataFrame.h" | |
548 | (("isFirst\\?.*") | |
549 | "if (isFirst) { isFirst = false; } else { os << par.delimiter; }\n")))) | |
550 | (add-before 'configure 'set-CXXFLAGS | |
551 | (lambda _ (setenv "CXXFLAGS" "-fpermissive ")))))) | |
0931c609 | 552 | (inputs |
8394619b | 553 | (list boost gsl libxml2 zlib)) |
0931c609 | 554 | (native-inputs |
25e0037a EF |
555 | `(("gfortran" ,gfortran) |
556 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
557 | ;; Non-portable assembly instructions are used so building fails on |
558 | ;; platforms other than x86_64 or i686. | |
559 | (supported-systems '("x86_64-linux" "i686-linux")) | |
df4c8434 | 560 | (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224") |
0931c609 RW |
561 | (synopsis "Implementation of the Random Forests machine learning method") |
562 | (description | |
563 | "Random Jungle is an implementation of Random Forests. It is supposed to | |
564 | analyse high dimensional data. In genetics, it can be used for analysing big | |
565 | Genome Wide Association (GWA) data. Random Forests is a powerful machine | |
566 | learning method. Most interesting features are variable selection, missing | |
567 | value imputation, classifier creation, generalization error estimation and | |
568 | sample proximities between pairs of cases.") | |
569 | (license license:gpl3+))) | |
c1670a81 | 570 | |
7d4cab74 RW |
571 | (define-public openfst |
572 | (package | |
573 | (name "openfst") | |
7c204281 | 574 | (version "1.8.2") |
7d4cab74 RW |
575 | (source (origin |
576 | (method url-fetch) | |
577 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
578 | "FstDownload/openfst-" version ".tar.gz")) | |
579 | (sha256 | |
580 | (base32 | |
7c204281 | 581 | "0hlbdmjjf1jgsvi3d2hwni5lz3l9a5bzj6ijpbawa8a7cbrpp66y")))) |
7d4cab74 | 582 | (build-system gnu-build-system) |
7c204281 | 583 | (arguments '(#:configure-flags '("--enable-ngram-fsts"))) |
7d4cab74 RW |
584 | (home-page "http://www.openfst.org") |
585 | (synopsis "Library for weighted finite-state transducers") | |
586 | (description "OpenFst is a library for constructing, combining, | |
587 | optimizing, and searching weighted finite-state transducers (FSTs).") | |
588 | (license license:asl2.0))) | |
589 | ||
8c7e4a96 A |
590 | ;; This is a temporary addition to bypass upstream issues with the kaldi |
591 | ;; package. | |
592 | (define-public openfst-1.7.3 | |
593 | (package (inherit openfst) | |
594 | (version "1.7.3") | |
595 | (source (origin | |
596 | (method url-fetch) | |
597 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
598 | "FstDownload/openfst-" version ".tar.gz")) | |
599 | (sha256 | |
600 | (base32 | |
d60b9f8d A |
601 | "038a60w7y8qnbxmcrsim9rafz9mihsny8xv50jpzlr7rl166pp5q")))) |
602 | (arguments '(#:configure-flags '("--enable-ngram-fsts" "CXXFLAGS=-std=c++14") | |
603 | #:make-flags '("CXXFLAGS=-std=c++14"))))) | |
8c7e4a96 | 604 | |
c1670a81 RW |
605 | (define-public shogun |
606 | (package | |
607 | (name "shogun") | |
5a14e81e | 608 | (version "6.1.3") |
c1670a81 RW |
609 | (source |
610 | (origin | |
611 | (method url-fetch) | |
612 | (uri (string-append | |
613 | "ftp://shogun-toolbox.org/shogun/releases/" | |
614 | (version-major+minor version) | |
615 | "/sources/shogun-" version ".tar.bz2")) | |
616 | (sha256 | |
617 | (base32 | |
5a14e81e | 618 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
619 | (modules '((guix build utils) |
620 | (ice-9 rdelim))) | |
621 | (snippet | |
622 | '(begin | |
623 | ;; Remove non-free sources and files referencing them | |
624 | (for-each delete-file | |
625 | (find-files "src/shogun/classifier/svm/" | |
626 | "SVMLight\\.(cpp|h)")) | |
627 | (for-each delete-file | |
628 | (find-files "examples/undocumented/libshogun/" | |
629 | (string-append | |
630 | "(classifier_.*svmlight.*|" | |
631 | "evaluation_cross_validation_locked_comparison).cpp"))) | |
632 | ;; Remove non-free functions. | |
633 | (define (delete-ifdefs file) | |
634 | (with-atomic-file-replacement file | |
635 | (lambda (in out) | |
636 | (let loop ((line (read-line in 'concat)) | |
637 | (skipping? #f)) | |
638 | (if (eof-object? line) | |
639 | #t | |
640 | (let ((skip-next? | |
641 | (or (and skipping? | |
642 | (not (string-prefix? | |
643 | "#endif //USE_SVMLIGHT" line))) | |
644 | (string-prefix? | |
645 | "#ifdef USE_SVMLIGHT" line)))) | |
646 | (when (or (not skipping?) | |
647 | (and skipping? (not skip-next?))) | |
648 | (display line out)) | |
649 | (loop (read-line in 'concat) skip-next?))))))) | |
5a14e81e KK |
650 | (for-each delete-ifdefs |
651 | (append | |
652 | (find-files "src/shogun/classifier/mkl" | |
653 | "^MKLClassification\\.cpp") | |
654 | (find-files "src/shogun/classifier/svm" | |
655 | "^SVMLightOneClass\\.(cpp|h)") | |
656 | (find-files "src/shogun/multiclass" | |
657 | "^ScatterSVM\\.(cpp|h)") | |
658 | (find-files "src/shogun/kernel/" | |
659 | "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)") | |
660 | (find-files "src/shogun/regression/svr" | |
661 | "^(MKLRegression|SVRLight)\\.(cpp|h)") | |
662 | (find-files "src/shogun/transfer/domain_adaptation" | |
c0d7c124 | 663 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 664 | #t)))) |
c1670a81 RW |
665 | (build-system cmake-build-system) |
666 | (arguments | |
667 | '(#:tests? #f ;no check target | |
668 | #:phases | |
dc1d3cde KK |
669 | (modify-phases %standard-phases |
670 | (add-after 'unpack 'delete-broken-symlinks | |
671 | (lambda _ | |
672 | (for-each delete-file '("applications/arts/data" | |
673 | "applications/asp/data" | |
674 | "applications/easysvm/data" | |
675 | "applications/msplicer/data" | |
676 | "applications/ocr/data" | |
5a14e81e KK |
677 | "examples/meta/data" |
678 | "examples/undocumented/data")) | |
dc1d3cde KK |
679 | #t)) |
680 | (add-after 'unpack 'change-R-target-path | |
681 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
682 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
683 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
684 | (("\\$\\{R_COMPONENT_LIB_PATH\\}") |
685 | (string-append (assoc-ref outputs "out") | |
686 | "/lib/R/library/"))) | |
687 | #t)) | |
688 | (add-after 'unpack 'fix-octave-modules | |
689 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e | 690 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 691 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
692 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
693 | ;; change target directory | |
dc1d3cde KK |
694 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
695 | (string-append (assoc-ref outputs "out") | |
696 | "/share/octave/packages"))) | |
5a14e81e KK |
697 | (substitute* '("src/interfaces/octave/swig_typemaps.i" |
698 | "src/interfaces/octave/sg_print_functions.cpp") | |
699 | ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave. | |
700 | (("octave/config\\.h") "octave/octave-config.h") | |
701 | (("octave/oct-obj.h") "octave/ovl.h")) | |
dc1d3cde | 702 | #t)) |
5a14e81e KK |
703 | (add-after 'unpack 'move-rxcpp |
704 | (lambda* (#:key inputs #:allow-other-keys) | |
705 | (let ((rxcpp-dir "shogun/third-party/rxcpp")) | |
706 | (mkdir-p rxcpp-dir) | |
707 | (install-file (assoc-ref inputs "rxcpp") rxcpp-dir) | |
708 | #t))) | |
dc1d3cde | 709 | (add-before 'build 'set-HOME |
c1670a81 | 710 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 711 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
712 | #:configure-flags |
713 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
714 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
715 | "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags |
716 | ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas | |
717 | ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray | |
718 | ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist | |
719 | ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file | |
720 | "-DINTERFACE_OCTAVE=ON" | |
721 | "-DINTERFACE_PYTHON=ON" | |
722 | "-DINTERFACE_R=ON"))) | |
c1670a81 RW |
723 | (inputs |
724 | `(("python" ,python) | |
725 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 726 | ("r-minimal" ,r-minimal) |
5537603f | 727 | ("octave" ,octave-cli) |
c1670a81 | 728 | ("swig" ,swig) |
5a14e81e | 729 | ("eigen" ,eigen) |
c1670a81 RW |
730 | ("hdf5" ,hdf5) |
731 | ("atlas" ,atlas) | |
732 | ("arpack" ,arpack-ng) | |
733 | ("lapack" ,lapack) | |
734 | ("glpk" ,glpk) | |
735 | ("libxml2" ,libxml2) | |
736 | ("lzo" ,lzo) | |
737 | ("zlib" ,zlib))) | |
738 | (native-inputs | |
8394619b | 739 | (list pkg-config rxcpp)) |
6b5b656f RW |
740 | ;; Non-portable SSE instructions are used so building fails on platforms |
741 | ;; other than x86_64. | |
742 | (supported-systems '("x86_64-linux")) | |
df10a64e | 743 | (home-page "https://shogun-toolbox.org/") |
c1670a81 RW |
744 | (synopsis "Machine learning toolbox") |
745 | (description | |
746 | "The Shogun Machine learning toolbox provides a wide range of unified and | |
cc24c4cb VC |
747 | efficient Machine Learning (ML) methods. The toolbox seamlessly |
748 | combines multiple data representations, algorithm classes, and general purpose | |
c1670a81 RW |
749 | tools. This enables both rapid prototyping of data pipelines and extensibility |
750 | in terms of new algorithms.") | |
751 | (license license:gpl3+))) | |
8406138b | 752 | |
fa2d94b5 | 753 | (define-public onnx |
b6540374 | 754 | (package |
fa2d94b5 | 755 | (name "onnx") |
b211824f | 756 | (version "1.12.0") |
630c39d8 LC |
757 | (source (origin |
758 | (method git-fetch) | |
759 | (uri (git-reference | |
760 | (url "https://github.com/onnx/onnx") | |
761 | (commit (string-append "v" version)))) | |
762 | (sha256 | |
763 | (base32 | |
b211824f | 764 | "1g9f1hviksbn7gi6fnd0dsm7nf0w3yia0mjj33d9mggklrl0db6x")) |
630c39d8 LC |
765 | (file-name (git-file-name name version)) |
766 | (patches (search-patches "onnx-use-system-googletest.patch" | |
767 | "onnx-shared-libraries.patch" | |
768 | "onnx-skip-model-downloads.patch")) | |
769 | (modules '((guix build utils))) | |
770 | (snippet '(delete-file-recursively "third_party")))) | |
b6540374 | 771 | (build-system python-build-system) |
2b55f914 LC |
772 | (arguments |
773 | '(#:phases (modify-phases %standard-phases | |
774 | (add-before 'build 'pass-cmake-arguments | |
775 | (lambda* (#:key outputs #:allow-other-keys) | |
776 | ;; Pass options to the CMake-based build process. | |
777 | (define out | |
778 | (assoc-ref outputs "out")) | |
779 | ||
780 | (define args | |
781 | ;; Copy arguments from 'cmake-build-system', plus ask | |
782 | ;; for shared libraries. | |
783 | (list "-DCMAKE_BUILD_TYPE=RelWithDebInfo" | |
784 | (string-append "-DCMAKE_INSTALL_PREFIX=" out) | |
785 | "-DCMAKE_INSTALL_LIBDIR=lib" | |
786 | "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" | |
787 | (string-append "-DCMAKE_INSTALL_RPATH=" out | |
788 | "/lib") | |
789 | "-DCMAKE_VERBOSE_MAKEFILE=ON" | |
790 | ||
791 | "-DBUILD_SHARED_LIBS=ON")) | |
792 | ||
793 | ;; This environment variable is honored by 'setup.py', | |
794 | ;; which passes it down to 'cmake'. | |
795 | (setenv "CMAKE_ARGS" (string-join args)) | |
796 | ||
797 | ;; This one is honored by 'setup.py' and passed to 'make | |
798 | ;; -j'. | |
799 | (setenv "MAX_JOBS" | |
800 | (number->string (parallel-job-count))))) | |
630c39d8 LC |
801 | (add-before 'check 'make-test-directory-writable |
802 | (lambda _ | |
803 | ;; Make things writable for tests. | |
804 | (setenv "HOME" (getcwd)) | |
805 | (for-each make-file-writable | |
806 | (find-files "onnx/examples" "." | |
807 | #:directories? #t)))) | |
2b55f914 LC |
808 | (add-after 'install 'install-from-cmake |
809 | (lambda _ | |
810 | ;; Run "make install" in the build tree 'setup.py' | |
811 | ;; created for CMake so that libonnx.so, | |
812 | ;; libonnx_proto.so, etc. are installed. | |
813 | (invoke "make" "install" | |
814 | "-C" ".setuptools-cmake-build")))))) | |
b6540374 | 815 | (native-inputs |
8394619b LC |
816 | (list cmake |
817 | googletest | |
818 | pybind11 | |
819 | python-coverage | |
820 | python-nbval | |
821 | python-pytest | |
822 | python-pytest-runner)) | |
b6540374 | 823 | (inputs |
8394619b | 824 | (list protobuf)) |
b6540374 | 825 | (propagated-inputs |
8394619b LC |
826 | (list python-numpy python-protobuf python-six python-tabulate |
827 | python-typing-extensions)) | |
b6540374 VM |
828 | (home-page "https://onnx.ai/") |
829 | (synopsis "Open Neural Network Exchange") | |
830 | (description | |
831 | "Open Neural Network Exchange (ONNX) provides an open source format for | |
832 | AI models, both deep learning and traditional ML. It defines an extensible | |
833 | computation graph model, as well as definitions of built-in operators and | |
834 | standard data types.") | |
835 | (license license:expat))) | |
836 | ||
fa2d94b5 LC |
837 | (define-public python-onnx |
838 | ;; This used to be called "python-onnx" because it provided nothing but | |
839 | ;; Python bindings. The package now provides shared libraries and C++ | |
840 | ;; headers, hence the name change. | |
841 | (deprecated-package "python-onnx" onnx)) | |
842 | ||
6da2b35b LC |
843 | (define-public onnx-optimizer |
844 | (package | |
845 | (name "onnx-optimizer") | |
846 | ;; Note: 0.2.x is *more* recent than 1.5.0. | |
847 | (version "0.2.6") | |
848 | (home-page "https://github.com/onnx/optimizer") | |
849 | (source (origin | |
850 | (method git-fetch) | |
851 | (uri (git-reference | |
852 | (url home-page) | |
853 | (commit (string-append "v" version)))) | |
854 | (sha256 | |
855 | (base32 | |
856 | "1wkqqdxcxpfbf8zpbdfdd3zz5jkw775g31gyykj11z4y6pp659l6")) | |
857 | (file-name (git-file-name name version)) | |
858 | (patches (search-patches "onnx-optimizer-system-library.patch")) | |
859 | (modules '((guix build utils))) | |
860 | (snippet '(delete-file-recursively "third_party")))) | |
861 | (build-system python-build-system) | |
862 | (arguments (package-arguments onnx)) ;reuse build system tweaks | |
863 | (native-inputs | |
8394619b LC |
864 | (list cmake python-pytest python-pytest-runner python-nbval |
865 | python-coverage)) | |
6da2b35b | 866 | (inputs |
8394619b | 867 | (list onnx protobuf pybind11)) |
6da2b35b | 868 | (propagated-inputs |
8394619b | 869 | (list python-numpy)) |
6da2b35b LC |
870 | (synopsis "Library to optimize ONNX models") |
871 | (description | |
872 | "This package provides a C++ and Python library for performing arbitrary | |
873 | optimizations on ONNX models, as well as a growing list of prepackaged | |
874 | optimization passes. | |
875 | ||
876 | Not all possible optimizations can be directly implemented on ONNX graphs--- | |
877 | some will need additional backend-specific information---but many can, and the | |
878 | aim is to provide all such passes along with ONNX so that they can be re-used | |
879 | with a single function call.") | |
880 | (license license:expat))) | |
881 | ||
3a354e10 KK |
882 | (define-public rxcpp |
883 | (package | |
884 | (name "rxcpp") | |
e91a0bff | 885 | (version "4.1.0") |
3a354e10 KK |
886 | (source |
887 | (origin | |
5daafe0b TGR |
888 | (method git-fetch) |
889 | (uri (git-reference | |
b0e7b699 | 890 | (url "https://github.com/ReactiveX/RxCpp") |
5daafe0b | 891 | (commit (string-append "v" version)))) |
3a354e10 | 892 | (sha256 |
5daafe0b TGR |
893 | (base32 "1rdpa3jlc181jd08nk437aar085h28i45s6nzrv65apb3xyyz0ij")) |
894 | (file-name (git-file-name name version)))) | |
3a354e10 KK |
895 | (build-system cmake-build-system) |
896 | (arguments | |
897 | `(#:phases | |
898 | (modify-phases %standard-phases | |
899 | (add-after 'unpack 'remove-werror | |
900 | (lambda _ | |
901 | (substitute* (find-files ".") | |
902 | (("-Werror") "")) | |
903 | #t)) | |
904 | (replace 'check | |
905 | (lambda _ | |
906 | (invoke "ctest")))))) | |
907 | (native-inputs | |
8394619b | 908 | (list catch-framework)) |
3a354e10 KK |
909 | (home-page "http://reactivex.io/") |
910 | (synopsis "Reactive Extensions for C++") | |
911 | (description | |
912 | "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for | |
913 | values-distributed-in-time. ReactiveX is a library for composing asynchronous | |
914 | and event-based programs by using observable sequences. | |
915 | ||
916 | It extends the observer pattern to support sequences of data and/or events and | |
917 | adds operators that allow you to compose sequences together declaratively while | |
918 | abstracting away concerns about things like low-level threading, | |
919 | synchronization, thread-safety, concurrent data structures, and non-blocking | |
920 | I/O.") | |
921 | (license license:asl2.0))) | |
922 | ||
38d319d3 LC |
923 | |
924 | (define-public gemmlowp | |
925 | (let ((commit "f9959600daa42992baace8a49544a00a743ce1b6") | |
926 | (version "0.1") | |
927 | (revision "1")) | |
39bb4937 RW |
928 | (package |
929 | (name "gemmlowp") | |
38d319d3 LC |
930 | (version (git-version version revision commit)) |
931 | (home-page "https://github.com/google/gemmlowp") | |
39bb4937 | 932 | (source (origin |
38d319d3 LC |
933 | (method git-fetch) |
934 | (uri (git-reference (url home-page) (commit commit))) | |
935 | (file-name (git-file-name name version)) | |
39bb4937 RW |
936 | (sha256 |
937 | (base32 | |
38d319d3 | 938 | "1hzfhlhzcb827aza6a7drydc67dw5fm3qfqilb9ibskan8dsf0c6")))) |
39bb4937 RW |
939 | (arguments |
940 | `(#:configure-flags | |
941 | (list ,@(match (%current-system) | |
942 | ((or "x86_64-linux" "i686-linux") | |
a32e3b90 | 943 | '("-DCMAKE_CXX_FLAGS=-msse2")) |
39bb4937 RW |
944 | (_ '()))) |
945 | #:phases | |
946 | (modify-phases %standard-phases | |
947 | ;; This directory contains the CMakeLists.txt. | |
948 | (add-after 'unpack 'chdir | |
949 | (lambda _ (chdir "contrib") #t)) | |
950 | ;; There is no install target | |
951 | (replace 'install | |
952 | (lambda* (#:key outputs #:allow-other-keys) | |
953 | (let* ((out (assoc-ref outputs "out")) | |
954 | (lib (string-append out "/lib/")) | |
955 | (inc (string-append out "/include/"))) | |
956 | (install-file "../build/libeight_bit_int_gemm.so" lib) | |
957 | (for-each (lambda (dir) | |
38d319d3 LC |
958 | (let ((target |
959 | (string-append inc "/gemmlowp/" dir))) | |
39bb4937 RW |
960 | (for-each (lambda (h) |
961 | (install-file h target)) | |
962 | (find-files (string-append "../" dir) | |
963 | "\\.h$")))) | |
964 | '("meta" "profiling" "public" "fixedpoint" | |
38d319d3 LC |
965 | "eight_bit_int_gemm" "internal")))))))) |
966 | (build-system cmake-build-system) | |
39bb4937 RW |
967 | (synopsis "Small self-contained low-precision GEMM library") |
968 | (description | |
969 | "This is a small self-contained low-precision @dfn{general matrix | |
970 | multiplication} (GEMM) library. It is not a full linear algebra library. | |
971 | Low-precision means that the input and output matrix entries are integers on | |
972 | at most 8 bits. To avoid overflow, results are internally accumulated on more | |
973 | than 8 bits, and at the end only some significant 8 bits are kept.") | |
974 | (license license:asl2.0)))) | |
f05c7eb4 | 975 | |
38d319d3 LC |
976 | (define-public gemmlowp-for-tensorflow |
977 | ;; The commit hash is taken from "tensorflow/workspace.bzl". | |
978 | (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98") | |
979 | (revision "2")) | |
980 | (package | |
981 | (inherit gemmlowp) | |
982 | (version (git-version "0" revision commit)) | |
983 | (source (origin | |
984 | (method url-fetch) | |
985 | (uri (string-append "https://mirror.bazel.build/" | |
986 | "github.com/google/gemmlowp/archive/" | |
987 | commit ".zip")) | |
988 | (file-name (string-append "gemmlowp-" version ".zip")) | |
989 | (sha256 | |
990 | (base32 | |
991 | "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq")))) | |
992 | (arguments | |
993 | (substitute-keyword-arguments (package-arguments gemmlowp) | |
994 | ((#:phases phases) | |
995 | `(modify-phases ,phases | |
996 | (replace 'install | |
997 | (lambda* (#:key outputs #:allow-other-keys) | |
998 | (let* ((out (assoc-ref outputs "out")) | |
999 | (lib (string-append out "/lib/")) | |
1000 | (inc (string-append out "/include/"))) | |
1001 | (install-file "../build/libeight_bit_int_gemm.so" lib) | |
1002 | (for-each (lambda (dir) | |
1003 | ;; Note: Install headers straight into | |
1004 | ;; $includedir instead of $includedir/gemmlowp. | |
1005 | (let ((target (string-append inc "/" dir))) | |
1006 | (for-each (lambda (h) | |
1007 | (install-file h target)) | |
1008 | (find-files (string-append "../" dir) | |
1009 | "\\.h$")))) | |
1010 | '("meta" "profiling" "public" "fixedpoint" | |
1011 | "eight_bit_int_gemm" "internal"))))))))) | |
1012 | (native-inputs | |
8394619b | 1013 | (list unzip)) |
38d319d3 LC |
1014 | (properties '((hidden? . #t)))))) |
1015 | ||
5f0ff6a9 MB |
1016 | (define-public dlib |
1017 | (package | |
1018 | (name "dlib") | |
d2a7cb46 | 1019 | (version "19.20") |
5f0ff6a9 MB |
1020 | (source (origin |
1021 | (method url-fetch) | |
1022 | (uri (string-append | |
1023 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
1024 | (sha256 | |
1025 | (base32 | |
d2a7cb46 | 1026 | "139jyi19qz37wwmmy48gil9d1kkh2r3w3bwdzabha6ayxmba96nz")) |
5f0ff6a9 MB |
1027 | (modules '((guix build utils))) |
1028 | (snippet | |
1029 | '(begin | |
1030 | ;; Delete ~13MB of bundled dependencies. | |
1031 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
1032 | (delete-file-recursively "docs/dlib/external") |
1033 | #t)))) | |
5f0ff6a9 MB |
1034 | (build-system cmake-build-system) |
1035 | (arguments | |
f90b2691 EF |
1036 | `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON") |
1037 | #:phases | |
5f0ff6a9 MB |
1038 | (modify-phases %standard-phases |
1039 | (add-after 'unpack 'disable-asserts | |
1040 | (lambda _ | |
1041 | ;; config.h recommends explicitly enabling or disabling asserts | |
1042 | ;; when building as a shared library. By default neither is set. | |
1043 | (substitute* "dlib/config.h" | |
1044 | (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS")) | |
1045 | #t)) | |
4fba38db MB |
1046 | (add-after 'disable-asserts 'disable-failing-tests |
1047 | (lambda _ | |
1048 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 1049 | ;; Others are flaky on some platforms. |
4fba38db MB |
1050 | (let* ((system ,(or (%current-target-system) |
1051 | (%current-system))) | |
1052 | (disabled-tests (cond | |
1053 | ((string-prefix? "mips64" system) | |
1054 | '("object_detector" ; timeout | |
1055 | "data_io")) | |
1056 | ((string-prefix? "armhf" system) | |
a343c461 | 1057 | '("learning_to_track")) |
4fba38db | 1058 | ((string-prefix? "i686" system) |
0ef7ea66 | 1059 | '("optimization")) |
4fba38db | 1060 | (else '())))) |
4fba38db MB |
1061 | (for-each |
1062 | (lambda (test) | |
1063 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
1064 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
1065 | disabled-tests) | |
1066 | #t))) | |
5f0ff6a9 MB |
1067 | (replace 'check |
1068 | (lambda _ | |
1069 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 1070 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 1071 | (with-directory-excursion test-dir |
8448e6bf TGR |
1072 | (invoke "make" "-j" (number->string (parallel-job-count))) |
1073 | (invoke "./dtest" "--runall")) | |
f90b2691 | 1074 | #t)))))) |
5f0ff6a9 | 1075 | (native-inputs |
8394619b LC |
1076 | (list pkg-config |
1077 | ;; For tests. | |
1078 | libnsl)) | |
5f0ff6a9 | 1079 | (inputs |
f40841e9 | 1080 | `(("giflib" ,giflib) |
4fba38db | 1081 | ("lapack" ,lapack) |
4bd428a7 | 1082 | ("libjpeg" ,libjpeg-turbo) |
5f0ff6a9 MB |
1083 | ("libpng" ,libpng) |
1084 | ("libx11" ,libx11) | |
1085 | ("openblas" ,openblas) | |
1086 | ("zlib" ,zlib))) | |
1087 | (synopsis | |
1088 | "Toolkit for making machine learning and data analysis applications in C++") | |
1089 | (description | |
1090 | "Dlib is a modern C++ toolkit containing machine learning algorithms and | |
1091 | tools. It is used in both industry and academia in a wide range of domains | |
1092 | including robotics, embedded devices, mobile phones, and large high performance | |
1093 | computing environments.") | |
1094 | (home-page "http://dlib.net") | |
1095 | (license license:boost1.0))) | |
be6eb2f1 RW |
1096 | |
1097 | (define-public python-scikit-learn | |
1098 | (package | |
1099 | (name "python-scikit-learn") | |
af36848f | 1100 | (version "1.0.2") |
be6eb2f1 RW |
1101 | (source |
1102 | (origin | |
4a89bdd1 RW |
1103 | (method git-fetch) |
1104 | (uri (git-reference | |
b0e7b699 | 1105 | (url "https://github.com/scikit-learn/scikit-learn") |
4a89bdd1 RW |
1106 | (commit version))) |
1107 | (file-name (git-file-name name version)) | |
be6eb2f1 RW |
1108 | (sha256 |
1109 | (base32 | |
af36848f | 1110 | "1rli53544vlsnmx4v4xcb8fdqcy5n3zksl4plwp76gsmrppb2lig")))) |
be6eb2f1 RW |
1111 | (build-system python-build-system) |
1112 | (arguments | |
1113 | `(#:phases | |
1114 | (modify-phases %standard-phases | |
1d1f44b7 MC |
1115 | (add-before 'build 'configure |
1116 | (lambda _ | |
1117 | (setenv "SKLEARN_BUILD_PARALLEL" | |
1118 | (number->string (parallel-job-count))))) | |
4a89bdd1 | 1119 | (add-after 'build 'build-ext |
1d1f44b7 MC |
1120 | (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace" |
1121 | "-j" (number->string (parallel-job-count))))) | |
4a89bdd1 | 1122 | (replace 'check |
3d56b8af RW |
1123 | (lambda* (#:key tests? #:allow-other-keys) |
1124 | (when tests? | |
1125 | ;; Restrict OpenBLAS threads to prevent segfaults while testing! | |
1126 | (setenv "OPENBLAS_NUM_THREADS" "1") | |
7ff3f3d2 | 1127 | |
3d56b8af RW |
1128 | ;; Some tests require write access to $HOME. |
1129 | (setenv "HOME" "/tmp") | |
7ff3f3d2 | 1130 | |
b182e136 | 1131 | (invoke "pytest" "sklearn" "-m" "not network" |
1d1f44b7 | 1132 | "-n" (number->string (parallel-job-count)) |
b182e136 | 1133 | ;; This test tries to access the internet. |
18e872b8 | 1134 | "-k" "not test_load_boston_alternative"))))))) |
1d1f44b7 | 1135 | (inputs (list openblas)) |
be6eb2f1 | 1136 | (native-inputs |
1d1f44b7 MC |
1137 | (list python-cython |
1138 | python-pandas | |
1139 | python-pytest | |
1140 | python-pytest-xdist)) | |
be6eb2f1 | 1141 | (propagated-inputs |
8394619b | 1142 | (list python-numpy python-threadpoolctl python-scipy python-joblib)) |
e51b34bb | 1143 | (home-page "https://scikit-learn.org/") |
be6eb2f1 RW |
1144 | (synopsis "Machine Learning in Python") |
1145 | (description | |
4a89bdd1 RW |
1146 | "Scikit-learn provides simple and efficient tools for data mining and |
1147 | data analysis.") | |
be6eb2f1 RW |
1148 | (license license:bsd-3))) |
1149 | ||
3d72867e EF |
1150 | (define-public python-threadpoolctl |
1151 | (package | |
1152 | (name "python-threadpoolctl") | |
1153 | (version "2.1.0") | |
1154 | (source | |
1155 | (origin | |
1156 | (method url-fetch) | |
1157 | (uri (pypi-uri "threadpoolctl" version)) | |
1158 | (sha256 | |
1159 | (base32 | |
1160 | "0szsxcm2fbxrn83iynn42bnvrdh7mfsmkhfn8pdn7swblfb7rifx")))) | |
1161 | (build-system python-build-system) | |
1162 | (arguments | |
1163 | `(#:phases | |
1164 | (modify-phases %standard-phases | |
1165 | (replace 'check | |
1166 | (lambda* (#:key tests? inputs outputs #:allow-other-keys) | |
1167 | (when tests? | |
1168 | (add-installed-pythonpath inputs outputs) | |
1169 | (invoke "pytest")) | |
1170 | #t))))) | |
1171 | (native-inputs | |
8394619b | 1172 | (list python-pytest)) |
3d72867e EF |
1173 | (home-page "https://github.com/joblib/threadpoolctl") |
1174 | (synopsis "Python helpers for common threading libraries") | |
1175 | (description "Thread-pool Controls provides Python helpers to limit the | |
1176 | number of threads used in the threadpool-backed of common native libraries used | |
1177 | for scientific computing and data science (e.g. BLAS and OpenMP).") | |
1178 | (license license:bsd-3))) | |
1179 | ||
8cd10a76 VM |
1180 | (define-public python-pynndescent |
1181 | (package | |
1182 | (name "python-pynndescent") | |
06b05122 | 1183 | (version "0.5.6") |
8cd10a76 VM |
1184 | (source |
1185 | (origin | |
1186 | (method url-fetch) | |
1187 | (uri (pypi-uri "pynndescent" version)) | |
1188 | (sha256 | |
06b05122 | 1189 | (base32 "0p3jsdcprjfzz7qf5674dsqfpvdn6p4wgqikg7b6ki5abf433yv1")))) |
8cd10a76 | 1190 | (build-system python-build-system) |
0848b559 VM |
1191 | (arguments |
1192 | `(#:phases | |
1193 | (modify-phases %standard-phases | |
1194 | (replace 'check | |
1195 | (lambda* (#:key inputs outputs tests? #:allow-other-keys) | |
1196 | (when tests? | |
06b05122 MC |
1197 | (invoke "python" "-m" "pytest" "--pyargs" "pynndescent" |
1198 | ;; wminkowski no longer exists in scipy 1.8.0 (see: | |
1199 | ;; https://github.com/lmcinnes/pynndescent/issues/177) | |
1200 | "-k" "not test_weighted_minkowski"))))))) | |
1201 | (native-inputs (list python-pytest)) | |
8cd10a76 | 1202 | (propagated-inputs |
06b05122 MC |
1203 | (list python-joblib |
1204 | python-llvmlite | |
1205 | python-numba | |
1206 | python-scikit-learn | |
8394619b | 1207 | python-scipy)) |
8cd10a76 VM |
1208 | (home-page "https://github.com/lmcinnes/pynndescent") |
1209 | (synopsis "Nearest neighbor descent for approximate nearest neighbors") | |
1210 | (description | |
1211 | "PyNNDescent provides a Python implementation of Nearest Neighbor Descent | |
1212 | for k-neighbor-graph construction and approximate nearest neighbor search.") | |
1213 | (license license:bsd-2))) | |
1214 | ||
6a5da0d0 VM |
1215 | (define-public python-opentsne |
1216 | (package | |
1217 | (name "python-opentsne") | |
2522ea38 | 1218 | (version "0.6.1") |
6a5da0d0 VM |
1219 | (source |
1220 | (origin | |
2522ea38 | 1221 | (method git-fetch) ; no tests in PyPI release |
6a5da0d0 VM |
1222 | (uri (git-reference |
1223 | (url "https://github.com/pavlin-policar/openTSNE") | |
1224 | (commit (string-append "v" version)))) | |
2522ea38 | 1225 | (file-name (git-file-name name version)) |
6a5da0d0 | 1226 | (sha256 |
2522ea38 | 1227 | (base32 "124nid27lfq1ipfjd2gkynqcmb4khisjb4r05jv42ckfkk4dbsxs")))) |
6a5da0d0 VM |
1228 | (build-system python-build-system) |
1229 | (arguments | |
1230 | `(#:phases | |
1231 | (modify-phases %standard-phases | |
1232 | ;; Benchmarks require the 'macosko2015' data files. | |
1233 | (add-after 'unpack 'delete-benchmark | |
1234 | (lambda _ | |
2522ea38 VM |
1235 | (delete-file-recursively "benchmarks"))) |
1236 | (add-after 'unpack 'skip-test | |
1237 | (lambda _ ;; TODO: figure out why this test fails. | |
1238 | (substitute* "tests/test_correctness.py" | |
1239 | (("def test_iris\\(self\\)") "def _test_iris(self)")))) | |
6a5da0d0 VM |
1240 | ;; Numba needs a writable dir to cache functions. |
1241 | (add-before 'check 'set-numba-cache-dir | |
1242 | (lambda _ | |
2522ea38 | 1243 | (setenv "NUMBA_CACHE_DIR" "/tmp")))))) |
6a5da0d0 | 1244 | (native-inputs |
8394619b | 1245 | (list python-cython)) |
6a5da0d0 | 1246 | (inputs |
8394619b | 1247 | (list fftw)) |
6a5da0d0 | 1248 | (propagated-inputs |
8394619b LC |
1249 | (list python-numpy python-pynndescent python-scikit-learn |
1250 | python-scipy)) | |
6a5da0d0 VM |
1251 | (home-page "https://github.com/pavlin-policar/openTSNE") |
1252 | (synopsis "Extensible, parallel implementations of t-SNE") | |
1253 | (description | |
1254 | "This is a modular Python implementation of t-Distributed Stochastic | |
1255 | Neighbor Embedding (t-SNE), a popular dimensionality-reduction algorithm for | |
1256 | visualizing high-dimensional data sets.") | |
1257 | (license license:bsd-3))) | |
1258 | ||
639ae3f2 RJ |
1259 | (define-public python-scikit-rebate |
1260 | (package | |
1261 | (name "python-scikit-rebate") | |
c7ef428a | 1262 | (version "0.62") |
639ae3f2 RJ |
1263 | (source (origin |
1264 | (method url-fetch) | |
1265 | (uri (pypi-uri "skrebate" version)) | |
1266 | (sha256 | |
1267 | (base32 | |
c7ef428a | 1268 | "0n55ghvnv7rxqa5agq6a4892ad0ghha165b0g4ghwr9gqm6ss3dj")))) |
639ae3f2 | 1269 | (build-system python-build-system) |
c7ef428a | 1270 | (arguments '(#:tests? #f)) ;no tests on PyPI and no tags in repo |
639ae3f2 | 1271 | (propagated-inputs |
8394619b | 1272 | (list python-numpy python-scipy python-scikit-learn python-joblib)) |
639ae3f2 RJ |
1273 | (home-page "https://epistasislab.github.io/scikit-rebate/") |
1274 | (synopsis "Relief-based feature selection algorithms for Python") | |
1275 | (description "Scikit-rebate is a scikit-learn-compatible Python | |
1276 | implementation of ReBATE, a suite of Relief-based feature selection algorithms | |
1277 | for Machine Learning. These algorithms excel at identifying features that are | |
1278 | predictive of the outcome in supervised learning problems, and are especially | |
1279 | good at identifying feature interactions that are normally overlooked by | |
1280 | standard feature selection algorithms.") | |
1281 | (license license:expat))) | |
1282 | ||
57a747e1 VM |
1283 | (define-public python-cmaes |
1284 | (package | |
1285 | (name "python-cmaes") | |
1286 | (version "0.8.2") | |
1287 | (source | |
1288 | (origin | |
1289 | (method git-fetch) ;no tests in PyPI | |
1290 | (uri (git-reference | |
1291 | (url "https://github.com/CyberAgent/cmaes") | |
1292 | (commit (string-append "v" version)))) | |
1293 | (sha256 | |
1294 | (base32 "1jyckaifir528dz6m95nvky8hvqmz5gz6dlp65baahhbca0danzb")) | |
1295 | (file-name (git-file-name name version)))) | |
1296 | (build-system python-build-system) | |
1297 | (native-inputs | |
8394619b LC |
1298 | (list python-setuptools ;build fails without this |
1299 | python-wheel)) | |
57a747e1 | 1300 | (propagated-inputs |
8394619b | 1301 | (list python-numpy)) |
57a747e1 VM |
1302 | (home-page "https://github.com/CyberAgent/cmaes") |
1303 | (synopsis "CMA-ES implementation for Python") | |
1304 | (description "This package provides provides an implementation of the | |
1305 | Covariance Matrix Adaptation Evolution Strategy (CMA-ES) for Python.") | |
1306 | (license license:expat))) | |
1307 | ||
2dab4188 FT |
1308 | (define-public python-autograd |
1309 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
1310 | (revision "0") | |
1311 | (version (git-version "0.0.0" revision commit))) | |
1312 | (package | |
1313 | (name "python-autograd") | |
1314 | (home-page "https://github.com/HIPS/autograd") | |
1315 | (source (origin | |
1316 | (method git-fetch) | |
1317 | (uri (git-reference | |
1318 | (url home-page) | |
1319 | (commit commit))) | |
1320 | (sha256 | |
1321 | (base32 | |
1322 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
1323 | (file-name (git-file-name name version)))) | |
1324 | (version version) | |
1325 | (build-system python-build-system) | |
1326 | (native-inputs | |
8394619b | 1327 | (list python-nose python-pytest)) |
2dab4188 | 1328 | (propagated-inputs |
8394619b | 1329 | (list python-future python-numpy)) |
2dab4188 FT |
1330 | (arguments |
1331 | `(#:phases (modify-phases %standard-phases | |
1332 | (replace 'check | |
1333 | (lambda _ | |
1334 | (invoke "py.test" "-v")))))) | |
1335 | (synopsis "Efficiently computes derivatives of NumPy code") | |
1336 | (description "Autograd can automatically differentiate native Python and | |
1337 | NumPy code. It can handle a large subset of Python's features, including loops, | |
1338 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
1339 | of derivatives. It supports reverse-mode differentiation | |
1340 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
1341 | scalar-valued functions with respect to array-valued arguments, as well as | |
1342 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
1343 | main intended application of Autograd is gradient-based optimization.") | |
1344 | (license license:expat)))) | |
1345 | ||
112c2c01 FT |
1346 | (define-public lightgbm |
1347 | (package | |
1348 | (name "lightgbm") | |
1349 | (version "2.0.12") | |
1350 | (source (origin | |
a2a7cc9b EF |
1351 | (method git-fetch) |
1352 | (uri (git-reference | |
1353 | (url "https://github.com/Microsoft/LightGBM") | |
1354 | (commit (string-append "v" version)))) | |
112c2c01 FT |
1355 | (sha256 |
1356 | (base32 | |
a2a7cc9b EF |
1357 | "0jlvyn7k81dzrh9ij3zw576wbgiwmmr26rzpdxjn1dbpc3njpvzi")) |
1358 | (file-name (git-file-name name version)))) | |
112c2c01 | 1359 | (native-inputs |
8394619b | 1360 | (list python-pytest python-nose)) |
112c2c01 | 1361 | (inputs |
8394619b | 1362 | (list openmpi)) |
112c2c01 | 1363 | (propagated-inputs |
8394619b | 1364 | (list python-numpy python-scipy)) |
112c2c01 FT |
1365 | (arguments |
1366 | `(#:configure-flags | |
1367 | '("-DUSE_MPI=ON") | |
1368 | #:phases | |
1369 | (modify-phases %standard-phases | |
1370 | (replace 'check | |
a2a7cc9b EF |
1371 | (lambda _ |
1372 | (with-directory-excursion "../source" | |
112c2c01 FT |
1373 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) |
1374 | (build-system cmake-build-system) | |
1375 | (home-page "https://github.com/Microsoft/LightGBM") | |
1376 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
1377 | (description "LightGBM is a gradient boosting framework that uses tree | |
1378 | based learning algorithms. It is designed to be distributed and efficient with | |
1379 | the following advantages: | |
1380 | ||
1381 | @itemize | |
1382 | @item Faster training speed and higher efficiency | |
1383 | @item Lower memory usage | |
1384 | @item Better accuracy | |
1385 | @item Parallel and GPU learning supported (not enabled in this package) | |
1386 | @item Capable of handling large-scale data | |
1387 | @end itemize\n") | |
1388 | (license license:expat))) | |
a8fb82a8 FT |
1389 | |
1390 | (define-public vowpal-wabbit | |
1391 | ;; Language bindings not included. | |
1392 | (package | |
1393 | (name "vowpal-wabbit") | |
1394 | (version "8.5.0") | |
1395 | (source (origin | |
4eb40497 EF |
1396 | (method git-fetch) |
1397 | (uri (git-reference | |
1398 | (url "https://github.com/JohnLangford/vowpal_wabbit") | |
1399 | (commit version))) | |
a8fb82a8 FT |
1400 | (sha256 |
1401 | (base32 | |
4eb40497 EF |
1402 | "04bwzk6ifgnz3fmzid8b7avxf9n5pnx9xcjm61nkjng1vv0bpj8x")) |
1403 | (file-name (git-file-name name version)))) | |
a8fb82a8 | 1404 | (inputs |
8394619b | 1405 | (list boost zlib)) |
a8fb82a8 FT |
1406 | (arguments |
1407 | `(#:configure-flags | |
1408 | (list (string-append "--with-boost=" | |
4eb40497 EF |
1409 | (assoc-ref %build-inputs "boost"))) |
1410 | #:phases | |
1411 | (modify-phases %standard-phases | |
1412 | (add-after 'unpack 'make-files-writable | |
1413 | (lambda _ | |
d9bba529 EF |
1414 | (for-each make-file-writable (find-files "." ".*")) #t)) |
1415 | (add-after 'install 'install-more-headers | |
1416 | (lambda* (#:key outputs #:allow-other-keys) | |
1417 | (for-each | |
1418 | (lambda (file) | |
1419 | (install-file file (string-append | |
1420 | (assoc-ref outputs "out") | |
1421 | "/include/vowpalwabbit"))) | |
1422 | (find-files "vowpalwabbit" "\\.h$")) | |
1423 | #t))))) | |
a8fb82a8 FT |
1424 | (build-system gnu-build-system) |
1425 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
1426 | (synopsis "Fast machine learning library for online learning") | |
1427 | (description "Vowpal Wabbit is a machine learning system with techniques | |
1428 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
1429 | interactive learning.") | |
1430 | (license license:bsd-3))) | |
915c6bf6 | 1431 | |
8854acd4 VM |
1432 | (define-public python-hyperopt |
1433 | (package | |
1434 | (name "python-hyperopt") | |
1435 | (version "0.2.5") | |
1436 | (source | |
1437 | (origin | |
1438 | (method url-fetch) | |
1439 | (uri (pypi-uri "hyperopt" version)) | |
1440 | (sha256 | |
1441 | (base32 "1k4ma8ci0bxghw7g4ms944zak1pi83yv2d6bxd7fcslm1zalfq5w")))) | |
1442 | (build-system python-build-system) | |
1443 | (arguments | |
1444 | `(#:phases | |
1445 | (modify-phases %standard-phases | |
1446 | (replace 'check | |
1447 | (lambda* (#:key inputs outputs tests? #:allow-other-keys) | |
1448 | (when tests? | |
1449 | (add-installed-pythonpath inputs outputs) | |
1450 | (invoke "python" "-m" "pytest" "--ignore" | |
1451 | ;; Needs python-pyspark. | |
1452 | "hyperopt/tests/test_spark.py" | |
1453 | ;; Needs both python-scikit-learn and python-lightgbm. | |
1454 | "--ignore" "hyperopt/tests/test_atpe_basic.py" | |
1455 | ;; The tests below need python-lightgbm. | |
1456 | "-k" (string-append "not test_branin" | |
1457 | " and not test_distractor" | |
1458 | " and not test_q1lognormal" | |
1459 | " and not test_quadratic1" | |
1460 | " and not test_twoarms")))))))) | |
1461 | (propagated-inputs | |
8394619b LC |
1462 | (list python-cloudpickle |
1463 | python-future | |
1464 | python-networkx | |
1465 | python-numpy | |
1466 | python-scipy | |
1467 | python-six | |
1468 | python-tqdm)) | |
8854acd4 | 1469 | (native-inputs |
8394619b LC |
1470 | (list python-black |
1471 | python-ipython | |
1472 | python-ipyparallel | |
1473 | python-nose | |
1474 | python-pymongo | |
1475 | python-pytest)) | |
8854acd4 VM |
1476 | (home-page "https://hyperopt.github.io/hyperopt/") |
1477 | (synopsis "Library for hyperparameter optimization") | |
1478 | (description "Hyperopt is a Python library for serial and parallel | |
1479 | optimization over awkward search spaces, which may include real-valued, | |
1480 | discrete, and conditional dimensions.") | |
1481 | (license license:bsd-3))) | |
1482 | ||
b9445d0b RW |
1483 | ;; There have been no proper releases yet. |
1484 | (define-public kaldi | |
d57a2c2b A |
1485 | (let ((commit "dd107fd594ac58af962031c1689abfdc10f84452") |
1486 | (revision "0") | |
1487 | (openfst openfst-1.7.3)) ;; Temporary bypass for upstream issues | |
b9445d0b RW |
1488 | (package |
1489 | (name "kaldi") | |
1490 | (version (git-version "0" revision commit)) | |
1491 | (source (origin | |
1492 | (method git-fetch) | |
1493 | (uri (git-reference | |
b0e7b699 | 1494 | (url "https://github.com/kaldi-asr/kaldi") |
b9445d0b RW |
1495 | (commit commit))) |
1496 | (file-name (git-file-name name version)) | |
1497 | (sha256 | |
1498 | (base32 | |
d57a2c2b | 1499 | "0iqbzgn7gzmgwvjfzifpbwwidxx887qmlgmsjkg7b1yzyfv00l21")))) |
b9445d0b RW |
1500 | (build-system gnu-build-system) |
1501 | (arguments | |
1502 | `(#:test-target "test" | |
1503 | #:phases | |
1504 | (modify-phases %standard-phases | |
1505 | (add-after 'unpack 'chdir | |
1506 | (lambda _ (chdir "src") #t)) | |
1507 | (replace 'configure | |
1508 | (lambda* (#:key build system inputs outputs #:allow-other-keys) | |
1509 | (when (not (or (string-prefix? "x86_64" system) | |
1510 | (string-prefix? "i686" system))) | |
1511 | (substitute* "makefiles/linux_openblas.mk" | |
1512 | (("-msse -msse2") ""))) | |
1513 | (substitute* "makefiles/default_rules.mk" | |
1514 | (("/bin/bash") (which "bash"))) | |
1515 | (substitute* "Makefile" | |
1516 | (("ext_depend: check_portaudio") | |
1517 | "ext_depend:")) | |
1518 | (substitute* '("online/Makefile" | |
1519 | "onlinebin/Makefile" | |
1520 | "gst-plugin/Makefile") | |
1521 | (("../../tools/portaudio/install") | |
1522 | (assoc-ref inputs "portaudio"))) | |
d57a2c2b A |
1523 | (substitute* "matrix/Makefile" ;temporary test bypass |
1524 | (("matrix-lib-test sparse-matrix-test") "")) | |
b9445d0b RW |
1525 | |
1526 | ;; This `configure' script doesn't support variables passed as | |
1527 | ;; arguments, nor does it support "prefix". | |
1528 | (let ((out (assoc-ref outputs "out")) | |
1529 | (openblas (assoc-ref inputs "openblas")) | |
1530 | (openfst (assoc-ref inputs "openfst"))) | |
1531 | (substitute* "configure" | |
1532 | (("check_for_slow_expf;") "") | |
1533 | ;; This affects the RPATH and also serves as the installation | |
1534 | ;; directory. | |
1535 | (("KALDILIBDIR=`pwd`/lib") | |
1536 | (string-append "KALDILIBDIR=" out "/lib"))) | |
1537 | (mkdir-p out) ; must exist | |
1538 | (setenv "CONFIG_SHELL" (which "bash")) | |
1539 | (setenv "OPENFST_VER" ,(package-version openfst)) | |
1540 | (invoke "./configure" | |
1541 | "--use-cuda=no" | |
1542 | "--shared" | |
1543 | (string-append "--openblas-root=" openblas) | |
1544 | (string-append "--fst-root=" openfst))))) | |
1545 | (add-after 'build 'build-ext-and-gstreamer-plugin | |
1546 | (lambda _ | |
1547 | (invoke "make" "-C" "online" "depend") | |
1548 | (invoke "make" "-C" "online") | |
1549 | (invoke "make" "-C" "onlinebin" "depend") | |
1550 | (invoke "make" "-C" "onlinebin") | |
1551 | (invoke "make" "-C" "gst-plugin" "depend") | |
1552 | (invoke "make" "-C" "gst-plugin") | |
1553 | #t)) | |
1554 | ;; TODO: also install the executables. | |
1555 | (replace 'install | |
1556 | (lambda* (#:key outputs #:allow-other-keys) | |
1557 | (let* ((out (assoc-ref outputs "out")) | |
1fdd20c7 | 1558 | (inc (string-append out "/include")) |
b9445d0b RW |
1559 | (lib (string-append out "/lib"))) |
1560 | (mkdir-p lib) | |
1fdd20c7 RW |
1561 | ;; The build phase installed symlinks to the actual |
1562 | ;; libraries. Install the actual targets. | |
1563 | (for-each (lambda (file) | |
1564 | (let ((target (readlink file))) | |
1565 | (delete-file file) | |
1566 | (install-file target lib))) | |
1567 | (find-files lib "\\.so")) | |
1568 | ;; Install headers | |
1569 | (for-each (lambda (file) | |
1570 | (let ((target-dir (string-append inc "/" (dirname file)))) | |
1571 | (install-file file target-dir))) | |
1572 | (find-files "." "\\.h")) | |
1573 | (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" | |
1574 | (string-append lib "/gstreamer-1.0")) | |
b9445d0b RW |
1575 | #t)))))) |
1576 | (inputs | |
8394619b LC |
1577 | (list alsa-lib |
1578 | `(,gfortran "lib") | |
1579 | glib | |
1580 | gstreamer | |
1581 | jack-1 | |
1582 | openblas | |
1583 | openfst | |
1584 | portaudio | |
1585 | python)) | |
b9445d0b | 1586 | (native-inputs |
8394619b LC |
1587 | (list `(,glib "bin") ; glib-genmarshal |
1588 | grep | |
1589 | sed | |
1590 | pkg-config | |
1591 | which)) | |
b9445d0b RW |
1592 | (home-page "https://kaldi-asr.org/") |
1593 | (synopsis "Speech recognition toolkit") | |
1594 | (description "Kaldi is an extensible toolkit for speech recognition | |
1595 | written in C++.") | |
1596 | (license license:asl2.0)))) | |
99260014 RW |
1597 | |
1598 | (define-public gst-kaldi-nnet2-online | |
b3cf5f86 RW |
1599 | (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad") |
1600 | (revision "2")) | |
99260014 RW |
1601 | (package |
1602 | (name "gst-kaldi-nnet2-online") | |
1603 | (version (git-version "0" revision commit)) | |
1604 | (source (origin | |
1605 | (method git-fetch) | |
1606 | (uri (git-reference | |
b0e7b699 | 1607 | (url "https://github.com/alumae/gst-kaldi-nnet2-online") |
99260014 RW |
1608 | (commit commit))) |
1609 | (file-name (git-file-name name version)) | |
1610 | (sha256 | |
1611 | (base32 | |
b3cf5f86 | 1612 | "1i6ffwiavxx07ri0lxix6s8q0r31x7i4xxvhys5jxkixf5q34w8g")))) |
99260014 RW |
1613 | (build-system gnu-build-system) |
1614 | (arguments | |
1615 | `(#:tests? #f ; there are none | |
1616 | #:make-flags | |
1617 | (list (string-append "SHELL=" | |
1618 | (assoc-ref %build-inputs "bash") "/bin/bash") | |
1619 | (string-append "KALDI_ROOT=" | |
1620 | (assoc-ref %build-inputs "kaldi-src")) | |
1621 | (string-append "KALDILIBDIR=" | |
1622 | (assoc-ref %build-inputs "kaldi") "/lib") | |
1623 | "KALDI_FLAVOR=dynamic") | |
1624 | #:phases | |
1625 | (modify-phases %standard-phases | |
1626 | (add-after 'unpack 'chdir | |
1627 | (lambda _ (chdir "src") #t)) | |
1628 | (replace 'configure | |
1629 | (lambda* (#:key inputs #:allow-other-keys) | |
1630 | (let ((glib (assoc-ref inputs "glib"))) | |
ad60a348 | 1631 | (setenv "CXXFLAGS" "-fPIC") |
99260014 RW |
1632 | (setenv "CPLUS_INCLUDE_PATH" |
1633 | (string-append glib "/include/glib-2.0:" | |
1634 | glib "/lib/glib-2.0/include:" | |
1635 | (assoc-ref inputs "gstreamer") | |
ad60a348 | 1636 | "/include/gstreamer-1.0"))) |
99260014 RW |
1637 | (substitute* "Makefile" |
1638 | (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") | |
ad60a348 MB |
1639 | (("\\$\\(error Cannot find") "#")) |
1640 | #t)) | |
99260014 RW |
1641 | (add-before 'build 'build-depend |
1642 | (lambda* (#:key make-flags #:allow-other-keys) | |
1643 | (apply invoke "make" "depend" make-flags))) | |
1644 | (replace 'install | |
1645 | (lambda* (#:key outputs #:allow-other-keys) | |
1646 | (let* ((out (assoc-ref outputs "out")) | |
1647 | (lib (string-append out "/lib/gstreamer-1.0"))) | |
1648 | (install-file "libgstkaldinnet2onlinedecoder.so" lib) | |
1649 | #t)))))) | |
1650 | (inputs | |
8394619b | 1651 | (list glib gstreamer jansson openfst kaldi)) |
99260014 RW |
1652 | (native-inputs |
1653 | `(("bash" ,bash) | |
1654 | ("glib:bin" ,glib "bin") ; glib-genmarshal | |
1655 | ("kaldi-src" ,(package-source kaldi)) | |
1656 | ("pkg-config" ,pkg-config))) | |
1657 | (home-page "https://kaldi-asr.org/") | |
1658 | (synopsis "Gstreamer plugin for decoding speech") | |
1659 | (description "This package provides a GStreamer plugin that wraps | |
1660 | Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN | |
1661 | acoustic models. The iVectors are adapted to the current audio stream | |
1662 | automatically.") | |
1663 | (license license:asl2.0)))) | |
10451f6b RW |
1664 | |
1665 | (define-public kaldi-gstreamer-server | |
1228c2ab RW |
1666 | ;; This is the tip of the py3 branch |
1667 | (let ((commit "f68cab490be7eb0da2af1475fbc16655f50a60cb") | |
1668 | (revision "2")) | |
10451f6b RW |
1669 | (package |
1670 | (name "kaldi-gstreamer-server") | |
1671 | (version (git-version "0" revision commit)) | |
1672 | (source (origin | |
1673 | (method git-fetch) | |
1674 | (uri (git-reference | |
b0e7b699 | 1675 | (url "https://github.com/alumae/kaldi-gstreamer-server") |
10451f6b RW |
1676 | (commit commit))) |
1677 | (file-name (git-file-name name version)) | |
1678 | (sha256 | |
1679 | (base32 | |
1228c2ab | 1680 | "17lh1368vkg8ngrcbn2phvigzlmalrqg6djx2gg61qq1a0nj87dm")))) |
10451f6b RW |
1681 | (build-system gnu-build-system) |
1682 | (arguments | |
1683 | `(#:tests? #f ; there are no tests that can be run automatically | |
1684 | #:modules ((guix build utils) | |
1685 | (guix build gnu-build-system) | |
1686 | (srfi srfi-26)) | |
1687 | #:phases | |
1688 | (modify-phases %standard-phases | |
1689 | (delete 'configure) | |
1690 | (replace 'build | |
1691 | (lambda* (#:key outputs #:allow-other-keys) | |
1692 | ;; Disable hash randomization to ensure the generated .pycs | |
1693 | ;; are reproducible. | |
1694 | (setenv "PYTHONHASHSEED" "0") | |
1695 | (with-directory-excursion "kaldigstserver" | |
46d07f84 RW |
1696 | ;; See https://github.com/alumae/kaldi-gstreamer-server/issues/232 |
1697 | (substitute* "master_server.py" | |
1698 | (("\\.replace\\('\\\\.*") ")")) | |
1699 | ||
1228c2ab RW |
1700 | ;; This is a Python 2 file |
1701 | (delete-file "decoder_test.py") | |
1702 | (delete-file "test-buffer.py") | |
1703 | ||
10451f6b RW |
1704 | (for-each (lambda (file) |
1705 | (apply invoke | |
1706 | `("python" | |
1707 | "-m" "compileall" | |
1708 | "-f" ; force rebuild | |
1709 | ,file))) | |
1710 | (find-files "." "\\.py$"))) | |
1711 | #t)) | |
1712 | (replace 'install | |
1713 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1714 | (let* ((out (assoc-ref outputs "out")) | |
1715 | (bin (string-append out "/bin")) | |
1716 | (share (string-append out "/share/kaldi-gstreamer-server/"))) | |
1717 | ;; Install Python files | |
1718 | (with-directory-excursion "kaldigstserver" | |
1719 | (for-each (cut install-file <> share) | |
1720 | (find-files "." ".*"))) | |
1721 | ||
1722 | ;; Install sample configuration files | |
1723 | (for-each (cut install-file <> share) | |
1724 | (find-files "." "\\.yaml")) | |
1725 | ||
1726 | ;; Install executables | |
1727 | (mkdir-p bin) | |
1728 | (let* ((server (string-append bin "/kaldi-gst-server")) | |
1729 | (client (string-append bin "/kaldi-gst-client")) | |
1730 | (worker (string-append bin "/kaldi-gst-worker")) | |
d42245d4 | 1731 | (PYTHONPATH (getenv "GUIX_PYTHONPATH")) |
10451f6b RW |
1732 | (GST_PLUGIN_PATH (string-append |
1733 | (assoc-ref inputs "gst-kaldi-nnet2-online") | |
1734 | "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) | |
1735 | (wrap (lambda (wrapper what) | |
1736 | (with-output-to-file wrapper | |
1737 | (lambda _ | |
1738 | (format #t | |
1739 | "#!~a | |
ef302ba9 | 1740 | export GUIX_PYTHONPATH=~a |
10451f6b RW |
1741 | export GST_PLUGIN_PATH=~a |
1742 | exec ~a ~a/~a \"$@\"~%" | |
1743 | (which "bash") PYTHONPATH GST_PLUGIN_PATH | |
1744 | (which "python") share what))) | |
1745 | (chmod wrapper #o555)))) | |
1746 | (for-each wrap | |
1747 | (list server client worker) | |
1748 | (list "master_server.py" | |
1749 | "client.py" | |
1750 | "worker.py"))) | |
1751 | #t)))))) | |
1752 | (inputs | |
1753 | `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online) | |
1228c2ab RW |
1754 | ("python" ,python-wrapper) |
1755 | ("python-pygobject" ,python-pygobject) | |
1756 | ("python-pyyaml" ,python-pyyaml) | |
cb44af24 | 1757 | ("python-tornado" ,python-tornado-6))) |
10451f6b RW |
1758 | (home-page "https://github.com/alumae/kaldi-gstreamer-server") |
1759 | (synopsis "Real-time full-duplex speech recognition server") | |
1760 | (description "This is a real-time full-duplex speech recognition server, | |
1761 | based on the Kaldi toolkit and the GStreamer framework and implemented in | |
1762 | Python.") | |
1763 | (license license:bsd-2)))) | |
0dfeb285 | 1764 | |
4fa16c9a RW |
1765 | ;; Note that Tensorflow includes a "third_party" directory, which seems to not |
1766 | ;; only contain modified subsets of upstream library source code, but also | |
1767 | ;; adapter headers provided by Google (such as the fft.h header, which is not | |
1768 | ;; part of the upstream project code). The Tensorflow code includes headers | |
1769 | ;; from the "third_party" directory. It does not look like we can replace | |
1770 | ;; these headers with unmodified upstream files, so we keep them. | |
1771 | (define-public tensorflow | |
1772 | (package | |
1773 | (name "tensorflow") | |
1774 | (version "1.9.0") | |
1775 | (source | |
1776 | (origin | |
1777 | (method git-fetch) | |
1778 | (uri (git-reference | |
b0e7b699 | 1779 | (url "https://github.com/tensorflow/tensorflow") |
4fa16c9a RW |
1780 | (commit (string-append "v" version)))) |
1781 | (file-name (string-append "tensorflow-" version "-checkout")) | |
1782 | (sha256 | |
1783 | (base32 | |
9e644d97 RW |
1784 | "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")) |
1785 | (patches | |
1786 | (search-patches "tensorflow-c-api-fix.patch")))) | |
4fa16c9a RW |
1787 | (build-system cmake-build-system) |
1788 | (arguments | |
1789 | `(#:tests? #f ; no "check" target | |
1790 | #:build-type "Release" | |
1791 | #:configure-flags | |
1792 | (let ((protobuf (assoc-ref %build-inputs "protobuf")) | |
1793 | (protobuf:native (assoc-ref %build-inputs "protobuf:native")) | |
1794 | (jsoncpp (assoc-ref %build-inputs "jsoncpp")) | |
1795 | (snappy (assoc-ref %build-inputs "snappy")) | |
1796 | (sqlite (assoc-ref %build-inputs "sqlite"))) | |
1797 | (list | |
1798 | ;; Use protobuf from Guix | |
1799 | (string-append "-Dprotobuf_STATIC_LIBRARIES=" | |
1800 | protobuf "/lib/libprotobuf.so") | |
1801 | (string-append "-DPROTOBUF_PROTOC_EXECUTABLE=" | |
1802 | protobuf:native "/bin/protoc") | |
1803 | ||
1804 | ;; Use snappy from Guix | |
1805 | (string-append "-Dsnappy_STATIC_LIBRARIES=" | |
1806 | snappy "/lib/libsnappy.so") | |
1807 | ;; Yes, this is not actually the include directory but a prefix... | |
1808 | (string-append "-Dsnappy_INCLUDE_DIR=" snappy) | |
1809 | ||
1810 | ;; Use jsoncpp from Guix | |
1811 | (string-append "-Djsoncpp_STATIC_LIBRARIES=" | |
1812 | jsoncpp "/lib/libjsoncpp.so") | |
1813 | ;; Yes, this is not actually the include directory but a prefix... | |
1814 | (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp) | |
1815 | ||
1816 | ;; Use sqlite from Guix | |
1817 | (string-append "-Dsqlite_STATIC_LIBRARIES=" | |
1818 | sqlite "/lib/libsqlite.a") | |
1819 | ||
1820 | ;; Use system libraries wherever possible. Currently, this | |
1821 | ;; only affects zlib. | |
1822 | "-Dsystemlib_ALL=ON" | |
1823 | "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON" | |
1824 | "-Dtensorflow_BUILD_SHARED_LIB=ON" | |
1825 | "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF" | |
1826 | "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF" | |
1827 | "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF")) | |
1828 | #:make-flags | |
1829 | (list "CC=gcc") | |
1830 | #:modules ((ice-9 ftw) | |
1831 | (guix build utils) | |
0b967058 EF |
1832 | (guix build cmake-build-system) |
1833 | ((guix build python-build-system) | |
1834 | #:select (python-version))) | |
1835 | #:imported-modules (,@%cmake-build-system-modules | |
92c3d1c3 | 1836 | (guix build python-build-system)) |
4fa16c9a RW |
1837 | #:phases |
1838 | (modify-phases %standard-phases | |
1839 | (add-after 'unpack 'set-source-file-times-to-1980 | |
1840 | ;; At the end of the tf_python_build_pip_package target, a ZIP | |
1841 | ;; archive should be generated via bdist_wheel, but it fails with | |
1842 | ;; "ZIP does not support timestamps before 1980". Luckily, | |
1843 | ;; SOURCE_DATE_EPOCH is respected, which we set to some time in | |
1844 | ;; 1980. | |
1845 | (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t)) | |
e1c91aae | 1846 | (add-after 'unpack 'python3.9-compatibility |
4fa16c9a | 1847 | (lambda _ |
e1c91aae | 1848 | ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913 |
4fa16c9a RW |
1849 | (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc" |
1850 | "tensorflow/python/lib/core/ndarray_tensor.cc" | |
1851 | "tensorflow/python/lib/core/py_func.cc") | |
1852 | (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8")) | |
1853 | (substitute* "tensorflow/c/eager/c_api.h" | |
1854 | (("unsigned char async") | |
1855 | "unsigned char is_async")) | |
1856 | ||
1857 | ;; Remove dependency on tensorboard, a complicated but probably | |
1858 | ;; optional package. | |
1859 | (substitute* "tensorflow/tools/pip_package/setup.py" | |
1860 | ((".*'tensorboard >.*") "")) | |
0b967058 EF |
1861 | |
1862 | ;; Fix the build with python-3.8, taken from rejected upstream patch: | |
1863 | ;; https://github.com/tensorflow/tensorflow/issues/34197 | |
1864 | (substitute* (find-files "tensorflow/python" ".*\\.cc$") | |
1865 | (("(nullptr,)(\\ +/. tp_print)" _ _ tp_print) | |
e1c91aae RW |
1866 | (string-append "NULL, " tp_print))) |
1867 | ||
1868 | ;; Fix the build with numpy >= 1.19. | |
1869 | ;; Suggested in https://github.com/tensorflow/tensorflow/issues/41086#issuecomment-656833081 | |
1870 | (substitute* "tensorflow/python/lib/core/bfloat16.cc" | |
1871 | (("void BinaryUFunc\\(char\\*\\* args, npy_intp\\* dimensions, npy_intp\\* steps,") | |
1872 | "void BinaryUFunc(char** args, npy_intp const* dimensions, npy_intp const* steps,") | |
1873 | (("void CompareUFunc\\(char\\*\\* args, npy_intp\\* dimensions, npy_intp\\* steps,") | |
1874 | "void CompareUFunc(char** args, npy_intp const* dimensions, npy_intp const* steps,")))) | |
1875 | (add-after 'python3.9-compatibility 'chdir | |
4327f06e | 1876 | (lambda _ (chdir "tensorflow/contrib/cmake"))) |
4fa16c9a RW |
1877 | (add-after 'chdir 'disable-downloads |
1878 | (lambda* (#:key inputs #:allow-other-keys) | |
1879 | (substitute* (find-files "external" "\\.cmake$") | |
1880 | (("GIT_REPOSITORY.*") "") | |
1881 | (("GIT_TAG.*") "") | |
1882 | (("PREFIX ") | |
1883 | "DOWNLOAD_COMMAND \"\"\nPREFIX ")) | |
1884 | ||
1885 | ;; Use packages from Guix | |
1886 | (let ((grpc (assoc-ref inputs "grpc"))) | |
1887 | (substitute* "CMakeLists.txt" | |
1888 | ;; Sqlite | |
1889 | (("include\\(sqlite\\)") "") | |
1890 | (("\\$\\{sqlite_STATIC_LIBRARIES\\}") | |
377e9453 | 1891 | (search-input-file inputs "/lib/libsqlite3.so")) |
4fa16c9a RW |
1892 | (("sqlite_copy_headers_to_destination") "") |
1893 | ||
1894 | ;; PNG | |
1895 | (("include\\(png\\)") "") | |
1896 | (("\\$\\{png_STATIC_LIBRARIES\\}") | |
377e9453 | 1897 | (search-input-file inputs "/lib/libpng16.so")) |
4fa16c9a RW |
1898 | (("png_copy_headers_to_destination") "") |
1899 | ||
1900 | ;; JPEG | |
1901 | (("include\\(jpeg\\)") "") | |
1902 | (("\\$\\{jpeg_STATIC_LIBRARIES\\}") | |
377e9453 | 1903 | (search-input-file inputs "/lib/libjpeg.so")) |
4fa16c9a RW |
1904 | (("jpeg_copy_headers_to_destination") "") |
1905 | ||
1906 | ;; GIF | |
1907 | (("include\\(gif\\)") "") | |
1908 | (("\\$\\{gif_STATIC_LIBRARIES\\}") | |
377e9453 | 1909 | (search-input-file inputs "/lib/libgif.so")) |
4fa16c9a RW |
1910 | (("gif_copy_headers_to_destination") "") |
1911 | ||
1912 | ;; lmdb | |
1913 | (("include\\(lmdb\\)") "") | |
1914 | (("\\$\\{lmdb_STATIC_LIBRARIES\\}") | |
377e9453 | 1915 | (search-input-file inputs "/lib/liblmdb.so")) |
4fa16c9a RW |
1916 | (("lmdb_copy_headers_to_destination") "") |
1917 | ||
1918 | ;; Protobuf | |
1919 | (("include\\(protobuf\\)") "") | |
1920 | (("protobuf_copy_headers_to_destination") "") | |
1921 | (("^ +protobuf") "") | |
1922 | ||
1923 | ;; gRPC | |
1924 | (("include\\(grpc\\)") | |
1925 | "find_package(grpc REQUIRED NAMES gRPC)") | |
1926 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "") | |
1927 | ||
1928 | ;; Eigen | |
1929 | (("include\\(eigen\\)") | |
1930 | (string-append "find_package(eigen REQUIRED NAMES Eigen3) | |
1931 | set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " | |
1932 | (assoc-ref inputs "eigen") "/include/eigen3)")) | |
1933 | (("^ +eigen") "") | |
1934 | ||
1935 | ;; snappy | |
1936 | (("include\\(snappy\\)") | |
1937 | "add_definitions(-DTF_USE_SNAPPY)") | |
1938 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "") | |
1939 | ||
1940 | ;; jsoncpp | |
1941 | (("include\\(jsoncpp\\)") "") | |
1942 | (("^ +jsoncpp") "")) | |
1943 | ||
1944 | (substitute* "tf_core_framework.cmake" | |
1945 | ((" grpc") "") | |
1946 | (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin") | |
1947 | (which "grpc_cpp_plugin")) | |
1948 | ;; Link with gRPC libraries | |
1949 | (("add_library\\(tf_protos_cc.*" m) | |
1950 | (string-append m | |
1951 | (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \ | |
1952 | ~a/lib/libgrpc++_unsecure.a \ | |
1953 | ~a/lib/libgrpc_unsecure.a \ | |
1954 | ~a/lib/libaddress_sorting.a \ | |
1955 | ~a/lib/libgpr.a \ | |
1956 | ~a//lib/libcares.so | |
1957 | )\n" | |
1958 | grpc grpc grpc grpc | |
1959 | (assoc-ref inputs "c-ares")))))) | |
1960 | (substitute* "tf_tools.cmake" | |
1961 | (("add_dependencies\\(\\$\\{proto_text.*") "")) | |
1962 | ;; Remove dependency on bundled grpc | |
1963 | (substitute* "tf_core_distributed_runtime.cmake" | |
1964 | (("tf_core_cpu grpc") "tf_core_cpu")) | |
1965 | ||
1966 | ;; This directory is a dependency of many targets. | |
92c3d1c3 | 1967 | (mkdir-p "protobuf"))) |
4fa16c9a | 1968 | (add-after 'configure 'unpack-third-party-sources |
9e644d97 | 1969 | (lambda* (#:key inputs outputs #:allow-other-keys) |
4fa16c9a RW |
1970 | ;; This is needed to configure bundled packages properly. |
1971 | (setenv "CONFIG_SHELL" (which "bash")) | |
1972 | (for-each | |
1973 | (lambda (name) | |
1974 | (let* ((what (assoc-ref inputs (string-append name "-src"))) | |
1975 | (name* (string-map (lambda (c) | |
1976 | (if (char=? c #\-) | |
1977 | #\_ c)) name)) | |
1978 | (where (string-append "../build/" name* "/src/" name*))) | |
1979 | (cond | |
1980 | ((string-suffix? ".zip" what) | |
1981 | (mkdir-p where) | |
1982 | (with-directory-excursion where | |
1983 | (invoke "unzip" what))) | |
1984 | ((string-suffix? ".tar.gz" what) | |
1985 | (mkdir-p where) | |
1986 | (invoke "tar" "xf" what | |
1987 | "-C" where "--strip-components=1")) | |
1988 | (else | |
1989 | (let ((parent (dirname where))) | |
1990 | (mkdir-p parent) | |
1991 | (with-directory-excursion parent | |
1992 | (when (file-exists? name*) | |
1993 | (delete-file-recursively name*)) | |
1994 | (copy-recursively what name*) | |
1995 | (map make-file-writable | |
1996 | (find-files name* ".*")))))))) | |
1997 | (list "boringssl" | |
1998 | "cub" | |
1999 | "double-conversion" | |
2000 | "farmhash" | |
2001 | "fft2d" | |
2002 | "highwayhash" | |
2003 | "nsync" | |
2004 | "re2")) | |
2005 | ||
2006 | (rename-file "../build/cub/src/cub/cub-1.8.0/" | |
9e644d97 RW |
2007 | "../build/cub/src/cub/cub/") |
2008 | ||
2009 | (setenv "LDFLAGS" | |
2010 | (string-append "-Wl,-rpath=" | |
2011 | (assoc-ref outputs "out") "/lib")))) | |
4fa16c9a RW |
2012 | (add-after 'unpack 'fix-python-build |
2013 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
2014 | (mkdir-p "protobuf-src") | |
2015 | (invoke "tar" "xf" (assoc-ref inputs "protobuf:src") | |
2016 | "-C" "protobuf-src" "--strip-components=1") | |
2017 | (mkdir-p "eigen-src") | |
76ab15a7 | 2018 | (copy-recursively (assoc-ref inputs "eigen:src") "eigen-src") |
4fa16c9a RW |
2019 | |
2020 | (substitute* "tensorflow/contrib/cmake/tf_python.cmake" | |
4fa16c9a RW |
2021 | ;; Take protobuf source files from our source package. |
2022 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google") | |
2023 | (string-append (getcwd) "/protobuf-src/src/google"))) | |
2024 | ||
2025 | (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake" | |
2026 | "tensorflow/contrib/cmake/tf_python.cmake") | |
2027 | ;; Take Eigen source files from our source package. | |
2028 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/") | |
2029 | (string-append (getcwd) "/eigen-src/")) | |
2030 | ;; Take Eigen headers from our own package. | |
2031 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive") | |
1ec13efb | 2032 | (search-input-directory inputs "/include/eigen3"))) |
4fa16c9a RW |
2033 | |
2034 | ;; Correct the RUNPATH of ops libraries generated for Python. | |
2035 | ;; TODO: this doesn't work :( | |
2036 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
2037 | ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build") | |
2038 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
2039 | ;; error: depends on 'libpywrap_tensorflow_internal.so', which | |
2040 | ;; cannot be found in RUNPATH ... | |
2041 | (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake" | |
2042 | (("set_target_properties.*") | |
2043 | (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \ | |
2044 | COMPILE_FLAGS ${target_compile_flags} \ | |
2045 | INSTALL_RPATH_USE_LINK_PATH TRUE \ | |
4327f06e | 2046 | INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))))) |
9e644d97 RW |
2047 | (add-after 'unpack 'patch-cmake-file-to-install-c-headers |
2048 | (lambda _ | |
2049 | (substitute* "tensorflow/contrib/cmake/tf_c.cmake" | |
2050 | (("if\\(tensorflow_BUILD_PYTHON_BINDINGS" m) | |
2051 | (string-append | |
2052 | "install(DIRECTORY ${tensorflow_source_dir}/tensorflow/c/ \ | |
2053 | DESTINATION include/tensorflow/c FILES_MATCHING PATTERN \"*.h\")\n" m))))) | |
2054 | (add-after 'build 'build-c-bindings | |
2055 | (lambda* (#:key outputs parallel-build? #:allow-other-keys) | |
2056 | (invoke "make" "-j" (if parallel-build? | |
2057 | (number->string (parallel-job-count)) | |
2058 | "1") | |
2059 | "tf_c"))) | |
2060 | (add-after 'install 'build-pip-package | |
92c3d1c3 | 2061 | (lambda* (#:key outputs parallel-build? #:allow-other-keys) |
92c3d1c3 MC |
2062 | (invoke "make" "-j" (if parallel-build? |
2063 | (number->string (parallel-job-count)) | |
2064 | "1") | |
2065 | "tf_python_build_pip_package"))) | |
4fa16c9a | 2066 | (add-after 'build-pip-package 'install-python |
0b967058 | 2067 | (lambda* (#:key inputs outputs #:allow-other-keys) |
4fa16c9a | 2068 | (let ((out (assoc-ref outputs "out")) |
0b967058 EF |
2069 | (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))) |
2070 | (python-version (python-version | |
92c3d1c3 | 2071 | (assoc-ref inputs "python")))) |
4fa16c9a RW |
2072 | (invoke "python" "-m" "pip" "install" wheel |
2073 | (string-append "--prefix=" out)) | |
2074 | ||
2075 | ;; XXX: broken RUNPATH, see fix-python-build phase. | |
2076 | (delete-file | |
2077 | (string-append | |
0b967058 EF |
2078 | out "/lib/python" python-version |
2079 | "/site-packages/tensorflow/contrib/" | |
4327f06e | 2080 | "seq2seq/python/ops/lib_beam_search_ops.so")))))))) |
4fa16c9a RW |
2081 | (native-inputs |
2082 | `(("pkg-config" ,pkg-config) | |
7373eb83 MB |
2083 | ("protobuf:native" ,protobuf-3.6) ; protoc |
2084 | ("protobuf:src" ,(package-source protobuf-3.6)) | |
4fa16c9a | 2085 | ("eigen:src" ,(package-source eigen-for-tensorflow)) |
0fdec2a3 MB |
2086 | ;; install_pip_packages.sh wants setuptools 39.1.0 specifically. |
2087 | ("python-setuptools" ,python-setuptools-for-tensorflow) | |
2088 | ||
4fa16c9a RW |
2089 | ;; The commit hashes and URLs for third-party source code are taken |
2090 | ;; from "tensorflow/workspace.bzl". | |
2091 | ("boringssl-src" | |
2092 | ,(let ((commit "ee7aa02") | |
2093 | (revision "1")) | |
2094 | (origin | |
2095 | (method git-fetch) | |
2096 | (uri (git-reference | |
2097 | (url "https://boringssl.googlesource.com/boringssl") | |
2098 | (commit commit))) | |
2099 | (file-name (string-append "boringssl-0-" revision | |
2100 | (string-take commit 7) | |
2101 | "-checkout")) | |
2102 | (sha256 | |
2103 | (base32 | |
2104 | "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw"))))) | |
2105 | ("cub-src" | |
2106 | ,(let ((version "1.8.0")) | |
2107 | (origin | |
2108 | (method url-fetch) | |
2109 | (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/" | |
2110 | "cub/archive/" version ".zip")) | |
2111 | (file-name (string-append "cub-" version ".zip")) | |
2112 | (sha256 | |
2113 | (base32 | |
2114 | "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb"))))) | |
2115 | ("double-conversion-src" | |
2116 | ,(let ((commit "5664746") | |
2117 | (revision "1")) | |
2118 | (origin | |
2119 | (method git-fetch) | |
2120 | (uri (git-reference | |
b0e7b699 | 2121 | (url "https://github.com/google/double-conversion") |
4fa16c9a RW |
2122 | (commit commit))) |
2123 | (file-name | |
2124 | (git-file-name "double-conversion" | |
2125 | (string-append "0-" revision "." | |
2126 | (string-take commit 7)))) | |
2127 | (sha256 | |
2128 | (base32 | |
2129 | "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1"))))) | |
2130 | ("farmhash-src" | |
2131 | ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")) | |
2132 | (origin | |
2133 | (method url-fetch) | |
2134 | (uri (string-append | |
2135 | "https://mirror.bazel.build/github.com/google/farmhash/archive/" | |
2136 | commit ".tar.gz")) | |
2137 | (file-name (string-append "farmhash-0-" (string-take commit 7) | |
2138 | ".tar.gz")) | |
2139 | (sha256 | |
2140 | (base32 | |
2141 | "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35"))))) | |
2142 | ;; The license notice on the home page at | |
2143 | ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says: | |
2144 | ;; Copyright Takuya OOURA, 1996-2001 | |
2145 | ;; | |
2146 | ;; You may use, copy, modify and distribute this code for any purpose | |
2147 | ;; (include commercial use) and without fee. Please refer to this | |
2148 | ;; package when you modify this code. | |
2149 | ;; | |
2150 | ;; We take the identical tarball from the Bazel mirror, because the URL | |
2151 | ;; at the home page is not versioned and might change. | |
2152 | ("fft2d-src" | |
2153 | ,(origin | |
2154 | (method url-fetch) | |
2155 | (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz") | |
2156 | (file-name "fft2d.tar.gz") | |
2157 | (sha256 | |
2158 | (base32 | |
2159 | "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj")))) | |
2160 | ("highwayhash-src" | |
2161 | ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee") | |
2162 | (revision "1")) | |
2163 | (origin | |
2164 | (method git-fetch) | |
2165 | (uri (git-reference | |
b0e7b699 | 2166 | (url "https://github.com/google/highwayhash") |
4fa16c9a RW |
2167 | (commit commit))) |
2168 | (file-name (string-append "highwayhash-0-" revision | |
2169 | (string-take commit 7) | |
2170 | "-checkout")) | |
2171 | (sha256 | |
2172 | (base32 | |
2173 | "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6"))))) | |
2174 | ("nsync-src" | |
2175 | ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777") | |
2176 | (revision "1")) | |
2177 | (origin | |
2178 | (method url-fetch) | |
2179 | (uri (string-append "https://mirror.bazel.build/" | |
2180 | "github.com/google/nsync/archive/" | |
2181 | version ".tar.gz")) | |
2182 | (file-name (string-append "nsync-0." revision | |
2183 | "-" (string-take version 7) | |
2184 | ".tar.gz")) | |
2185 | (sha256 | |
2186 | (base32 | |
2187 | "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132"))))) | |
2188 | ("re2-src" | |
2189 | ,(let ((commit "e7efc48") | |
2190 | (revision "1")) | |
2191 | (origin | |
2192 | (method git-fetch) | |
2193 | (uri (git-reference | |
2194 | (url "https://github.com/google/re2") | |
2195 | (commit commit))) | |
2196 | (file-name (string-append "re2-0-" revision | |
2197 | (string-take commit 7) | |
2198 | "-checkout")) | |
2199 | (sha256 | |
2200 | (base32 | |
2201 | "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign"))))) | |
2202 | ("googletest" ,googletest) | |
2203 | ("swig" ,swig) | |
2204 | ("unzip" ,unzip))) | |
2205 | (propagated-inputs | |
2206 | `(("python-absl-py" ,python-absl-py) | |
2207 | ("python-astor" ,python-astor) | |
2208 | ("python-gast" ,python-gast) | |
2209 | ("python-grpcio" ,python-grpcio) | |
2210 | ("python-numpy" ,python-numpy) | |
7373eb83 | 2211 | ("python-protobuf" ,python-protobuf-3.6) |
4fa16c9a RW |
2212 | ("python-six" ,python-six) |
2213 | ("python-termcolo" ,python-termcolor) | |
2214 | ("python-wheel" ,python-wheel))) | |
2215 | (inputs | |
3b458d54 | 2216 | `(("c-ares" ,c-ares) |
4fa16c9a RW |
2217 | ("eigen" ,eigen-for-tensorflow) |
2218 | ("gemmlowp" ,gemmlowp-for-tensorflow) | |
2219 | ("lmdb" ,lmdb) | |
4bd428a7 | 2220 | ("libjpeg" ,libjpeg-turbo) |
4fa16c9a RW |
2221 | ("libpng" ,libpng) |
2222 | ("giflib" ,giflib) | |
80a8583a | 2223 | ("grpc" ,grpc-1.16.1 "static") |
447fafe3 | 2224 | ("grpc:bin" ,grpc-1.16.1) |
4fa16c9a RW |
2225 | ("jsoncpp" ,jsoncpp-for-tensorflow) |
2226 | ("snappy" ,snappy) | |
2227 | ("sqlite" ,sqlite) | |
7373eb83 | 2228 | ("protobuf" ,protobuf-3.6) |
4fa16c9a RW |
2229 | ("python" ,python-wrapper) |
2230 | ("zlib" ,zlib))) | |
2231 | (home-page "https://tensorflow.org") | |
2232 | (synopsis "Machine learning framework") | |
2233 | (description | |
2234 | "TensorFlow is a flexible platform for building and training machine | |
2235 | learning models. It provides a library for high performance numerical | |
2236 | computation and includes high level Python APIs, including both a sequential | |
2237 | API for beginners that allows users to build models quickly by plugging | |
2238 | together building blocks and a subclassing API with an imperative style for | |
2239 | advanced research.") | |
2240 | (license license:asl2.0))) | |
d60b064d | 2241 | |
c1e41109 RW |
2242 | (define-public tensorflow-lite |
2243 | (package | |
2244 | (name "tensorflow-lite") | |
2245 | (version "2.5.0") | |
2246 | (source | |
2247 | (origin | |
2248 | (method git-fetch) | |
2249 | (uri (git-reference | |
2250 | (url "https://github.com/tensorflow/tensorflow") | |
2251 | (commit (string-append "v" version)))) | |
2252 | (file-name (git-file-name name version)) | |
2253 | (sha256 | |
2254 | (base32 | |
2255 | "1jdw2i1rq06zqd6aabh7bbm0avsg4pygnfmd7gviv0blhih9054l")))) | |
2256 | (build-system cmake-build-system) | |
2257 | (arguments | |
2258 | `(#:tests? #false ; no "check" target | |
2259 | #:build-type "Release" | |
2260 | #:configure-flags | |
2261 | (list | |
2262 | "-DTFLITE_ENABLE_GPU=OFF" | |
2263 | "-DTFLITE_ENABLE_RUY=OFF" | |
2264 | ||
2265 | ;; TODO: The build system attempts to build xnnpack from source. We | |
2266 | ;; would like to use our xnnpack package here, but this requires more | |
2267 | ;; work. | |
2268 | "-DTFLITE_ENABLE_XNNPACK=OFF" | |
2269 | ||
2270 | ;; Pretend we've already fetched abseil. We won't actually build it | |
2271 | ;; but use the existing package. | |
2272 | "-Dabseil-cpp_POPULATED=TRUE" | |
2273 | ||
2274 | ;; Don't fetch the sources. We have already built flatbuffers. | |
2275 | "-Dflatbuffers_POPULATED=TRUE" | |
2276 | ||
2277 | "-DFFT2D_SOURCE_DIR=/tmp/fft2d" | |
2278 | "-Dneon2sse_SOURCE_DIR=/tmp/neon2sse" | |
2279 | "-Dneon2sse_BINARY_DIR=/tmp/neon2sse-bin" | |
2280 | "-DFARMHASH_SOURCE_DIR=/tmp/farmhash" | |
2281 | "-Dgemmlowp_SOURCE_DIR=/tmp/gemmlowp" | |
2282 | (string-append "-DRUY_SOURCE_DIR=" | |
2283 | (assoc-ref %build-inputs "ruy-src"))) | |
2284 | #:phases | |
2285 | (modify-phases %standard-phases | |
2286 | (add-after 'unpack 'chdir | |
2287 | (lambda _ (chdir "tensorflow/lite"))) | |
2288 | (add-after 'chdir 'copy-sources | |
2289 | (lambda* (#:key inputs #:allow-other-keys) | |
2290 | ;; Use external cmake finders instead of these stubs that won't | |
2291 | ;; find anything but the bundled sources. | |
2292 | (delete-file "tools/cmake/modules/Findabsl.cmake") | |
2293 | (delete-file "tools/cmake/modules/Findeigen.cmake") | |
2294 | ||
2295 | (substitute* "CMakeLists.txt" | |
2296 | (("find_package\\(eigen REQUIRED") | |
2297 | "find_package(eigen REQUIRED NAMES Eigen3")) | |
2298 | (substitute* "tools/cmake/modules/Findflatbuffers.cmake" | |
2299 | (("get_target_property.*") | |
2300 | (format #false "set(FLATBUFFERS_INCLUDE_DIRS ~a/include)\n" | |
2301 | (assoc-ref inputs "flatbuffers")))) | |
2302 | ||
2303 | ;; Don't fetch source code; we already have everything we need. | |
2304 | (substitute* '("tools/cmake/modules/fft2d.cmake" | |
2305 | "tools/cmake/modules/ruy.cmake" | |
2306 | "tools/cmake/modules/farmhash.cmake" | |
2307 | "tools/cmake/modules/neon2sse.cmake" | |
2308 | "tools/cmake/modules/gemmlowp.cmake") | |
2309 | (("OverridableFetchContent_Populate.*") "")) | |
2310 | ||
2311 | (mkdir-p "/tmp/farmhash") | |
2312 | (with-directory-excursion "/tmp/farmhash" | |
2313 | (invoke "tar" "--strip-components=1" | |
2314 | "-xf" (assoc-ref inputs "farmhash-src"))) | |
2315 | ||
2316 | (mkdir-p "/tmp/fft2d") | |
2317 | (with-directory-excursion "/tmp/fft2d" | |
2318 | (invoke "tar" "--strip-components=1" | |
2319 | "-xf" (assoc-ref inputs "fft2d-src"))) | |
2320 | ||
2321 | (copy-recursively (assoc-ref inputs "neon2sse-src") | |
2322 | "/tmp/neon2sse/") | |
2323 | (copy-recursively (assoc-ref inputs "gemmlowp-src") | |
2324 | "/tmp/gemmlowp/"))) | |
2325 | (add-after 'copy-sources 'prepare-shared-library-build | |
2326 | (lambda _ (chdir "c"))) | |
2327 | (replace 'install | |
2328 | (lambda* (#:key outputs #:allow-other-keys) | |
2329 | (let* ((out (assoc-ref outputs "out")) | |
2330 | (lib (string-append out "/lib")) | |
2331 | (headers (string-append out "/include/tensorflow/lite"))) | |
2332 | (install-file "../build/libtensorflowlite_c.so" lib) | |
2333 | (with-directory-excursion ".." | |
2334 | (for-each | |
2335 | (lambda (file) | |
2336 | (let ((target-dir (string-append headers "/" (dirname file)))) | |
2337 | (install-file file target-dir))) | |
2338 | (find-files "." "\\.h$"))))))))) | |
2339 | (inputs | |
f0ce5a60 | 2340 | `(("abseil-cpp" ,abseil-cpp-20200923.3) |
c1e41109 RW |
2341 | ("eigen" ,eigen-for-tensorflow-lite) |
2342 | ("flatbuffers" ,flatbuffers) | |
2343 | ("python" ,python))) | |
2344 | (native-inputs | |
2345 | `(("pkg-config" ,pkg-config) | |
2346 | ("gemmlowp-src" | |
2347 | ;; The commit hash is taken from | |
2348 | ;; "tensorflow/lite/tools/cmake/modules/gemmlowp.cmake". | |
2349 | ,(let ((commit "fda83bdc38b118cc6b56753bd540caa49e570745")) | |
2350 | (origin | |
2351 | (method git-fetch) | |
2352 | (uri (git-reference | |
2353 | (url "https://github.com/google/gemmlowp") | |
2354 | (commit commit))) | |
2355 | (file-name (git-file-name "gemmlowp" (string-take commit 8))) | |
2356 | (sha256 | |
2357 | (base32 | |
2358 | "1sbp8kmr2azwlvfbzryy1frxi99jhsh1nc93bdbxdf8zdgpv0kxl"))))) | |
2359 | ("neon2sse-src" | |
2360 | ,(let ((commit "a1652fd5253afbf3e39357b012974f93511f6108")) | |
2361 | (origin | |
2362 | (method git-fetch) | |
2363 | (uri (git-reference | |
2364 | (url "https://github.com/intel/ARM_NEON_2_x86_SSE") | |
2365 | (commit commit))) | |
2366 | (file-name (git-file-name "neon2sse" (string-take commit 8))) | |
2367 | (sha256 | |
2368 | (base32 | |
2369 | "1q8gkxag9wlnwdwad2pclsrkwzrdjy94hyrkayrsvxyj7szb5y8i"))))) | |
2370 | ("farmhash-src" | |
2371 | ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")) | |
2372 | (origin | |
2373 | (method url-fetch) | |
2374 | (uri (string-append | |
2375 | "https://mirror.bazel.build/github.com/google/farmhash/archive/" | |
2376 | commit ".tar.gz")) | |
2377 | (file-name (git-file-name "farmhash" (string-take commit 8))) | |
2378 | (sha256 | |
2379 | (base32 | |
2380 | "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35"))))) | |
2381 | ("fft2d-src" | |
2382 | ,(origin | |
2383 | (method url-fetch) | |
2384 | (uri (string-append "https://storage.googleapis.com/" | |
2385 | "mirror.tensorflow.org/" | |
2386 | "www.kurims.kyoto-u.ac.jp/~ooura/fft2d.tgz")) | |
2387 | (file-name "fft2d.tar.gz") | |
2388 | (sha256 | |
2389 | (base32 | |
2390 | "1jfflzi74fag9z4qmgwvp90aif4dpbr1657izmxlgvf4hy8fk9xd")))) | |
2391 | ("ruy-src" | |
2392 | ,(let ((commit "9c56af3fce210a8a103eda19bd6f47c08a9e3d90")) | |
2393 | (origin | |
2394 | (method git-fetch) | |
2395 | (uri (git-reference | |
2396 | (url "https://github.com/google/ruy") | |
2397 | (commit commit) | |
2398 | (recursive? #true))) | |
2399 | (file-name (git-file-name "ruy" (string-take commit 8))) | |
2400 | (sha256 | |
2401 | (base32 | |
2402 | "1cfd5gk6kaj8kbl3h98gx1ap8czd59y6p8qq8nr28fklpyzf5cis"))))))) | |
2403 | (home-page "https://tensorflow.org") | |
2404 | (synopsis "Machine learning framework") | |
2405 | (description | |
2406 | "TensorFlow is a flexible platform for building and training machine | |
2407 | learning models. This package provides the \"lite\" variant for mobile | |
2408 | devices.") | |
2409 | (license license:asl2.0))) | |
2410 | ||
7e73fc3b VM |
2411 | (define-public dmlc-core |
2412 | (package | |
2413 | (name "dmlc-core") | |
2414 | (version "0.5") | |
2415 | (source | |
2416 | (origin | |
2417 | (method git-fetch) | |
2418 | (uri (git-reference | |
2419 | (url "https://github.com/dmlc/dmlc-core") | |
2420 | (commit (string-append "v" version)))) | |
2421 | (file-name (git-file-name name version)) | |
2422 | (sha256 | |
2423 | (base32 "1x4ad1jhn84fywlk031fmv1kxyiscclmrqn9hhj8gz0mh7z9vcrh")))) | |
2424 | (build-system cmake-build-system) | |
2425 | (arguments | |
2426 | `(#:configure-flags | |
2427 | (list "-DGOOGLE_TEST=ON"))) | |
2428 | (native-inputs | |
2429 | `(("googletest" ,googletest) | |
2430 | ("python" ,python-wrapper))) | |
2431 | (home-page "https://github.com/dmlc/dmlc-core") | |
2432 | (synopsis "Common bricks library for machine learning") | |
2433 | (description | |
2434 | "DMLC-Core is the backbone library to support all DMLC projects, | |
2435 | offers the bricks to build efficient and scalable distributed machine | |
2436 | learning libraries.") | |
2437 | (license license:asl2.0))) | |
2438 | ||
6e5e60a2 VM |
2439 | (define-public xgboost |
2440 | (package | |
2441 | (name "xgboost") | |
c30fa177 | 2442 | (version "1.5.2") |
6e5e60a2 VM |
2443 | (source |
2444 | (origin | |
2445 | (method git-fetch) | |
2446 | (uri (git-reference | |
2447 | (url "https://github.com/dmlc/xgboost") | |
2448 | (commit (string-append "v" version)))) | |
2449 | (file-name (git-file-name name version)) | |
2450 | (patches (search-patches "xgboost-use-system-dmlc-core.patch")) | |
2451 | (sha256 | |
c30fa177 | 2452 | (base32 "0qx04y7cz8z7qv6bk9q7d7ba9b7xzj53l83l2x9ykdwhzacc3dn0")))) |
6e5e60a2 VM |
2453 | (build-system cmake-build-system) |
2454 | (arguments | |
2455 | `(#:configure-flags (list "-DGOOGLE_TEST=ON"))) | |
2456 | (native-inputs | |
2457 | `(("googletest" ,googletest) | |
2458 | ("python" ,python-wrapper))) | |
2459 | (inputs | |
8394619b | 2460 | (list dmlc-core)) |
6e5e60a2 VM |
2461 | (home-page "https://xgboost.ai/") |
2462 | (synopsis "Gradient boosting (GBDT, GBRT or GBM) library") | |
2463 | (description | |
2464 | "XGBoost is an optimized distributed gradient boosting library designed | |
2465 | to be highly efficient, flexible and portable. It implements machine learning | |
2466 | algorithms under the Gradient Boosting framework. XGBoost provides a parallel | |
2467 | tree boosting (also known as GBDT, GBM) that solve many data science problems | |
2468 | in a fast and accurate way.") | |
2469 | (license license:asl2.0))) | |
2470 | ||
40a6d8eb VM |
2471 | (define-public python-xgboost |
2472 | (package | |
2473 | (inherit xgboost) | |
2474 | (name "python-xgboost") | |
2475 | (source (package-source xgboost)) | |
2476 | (build-system python-build-system) | |
2477 | (arguments | |
2478 | `(#:phases | |
2479 | (modify-phases %standard-phases | |
2480 | (add-after 'unpack 'preparations | |
2481 | (lambda _ | |
2482 | ;; Move python-package content to parent directory to silence | |
2483 | ;; some warnings about files not being found if we chdir. | |
2484 | (rename-file "python-package/xgboost" "xgboost") | |
2485 | (rename-file "python-package/README.rst" "README.rst") | |
2486 | (rename-file "python-package/setup.cfg" "setup.cfg") | |
2487 | (rename-file "python-package/setup.py" "setup.py") | |
2488 | ;; Skip rebuilding libxgboost.so. | |
2489 | (substitute* "setup.py" | |
2490 | (("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "") | |
2491 | (("'install_lib': InstallLib,") "")))) | |
2492 | (add-after 'install 'install-version-and-libxgboost | |
2493 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
2494 | (let* ((out (assoc-ref outputs "out")) | |
2495 | (pylib (string-append out "/lib/python" | |
2496 | ,(version-major+minor | |
2497 | (package-version python)) | |
2498 | "/site-packages")) | |
2499 | (xgbdir (string-append pylib "/xgboost")) | |
2500 | (version-file (string-append xgbdir "/VERSION")) | |
2501 | (libxgboost (string-append (assoc-ref inputs "xgboost") | |
2502 | "/lib/libxgboost.so"))) | |
2503 | (with-output-to-file version-file | |
2504 | (lambda () | |
2505 | (display ,(package-version xgboost)))) | |
2506 | (mkdir-p (string-append xgbdir "/lib")) | |
2507 | (symlink libxgboost (string-append xgbdir "/lib" | |
2508 | "/libxgboost.so"))))) | |
2509 | (replace 'check | |
2510 | ;; Python-specific tests are located in tests/python. | |
2511 | (lambda* (#:key inputs outputs tests? #:allow-other-keys) | |
2512 | (when tests? | |
2513 | (add-installed-pythonpath inputs outputs) | |
2514 | (invoke "pytest" "tests/python" | |
2515 | ;; FIXME: CLI tests fail with PermissionError. | |
2516 | "--ignore" "tests/python/test_cli.py" "-k" | |
2517 | (string-append | |
2518 | "not test_cli_regression_demo" | |
2519 | ;; The tests below open a network connection. | |
2520 | " and not test_model_compatibility" | |
2521 | " and not test_get_group" | |
2522 | " and not test_cv_no_shuffle" | |
2523 | " and not test_cv" | |
2524 | " and not test_training" | |
40a6d8eb VM |
2525 | ;; "'['./runexp.sh']' returned non-zero exit status 1" |
2526 | " and not test_cli_binary_classification")))))))) | |
2527 | (native-inputs | |
8394619b | 2528 | (list python-pandas python-pytest python-scikit-learn)) |
40a6d8eb | 2529 | (inputs |
8394619b | 2530 | (list xgboost)) |
40a6d8eb | 2531 | (propagated-inputs |
8394619b | 2532 | (list python-numpy python-scipy)) |
40a6d8eb VM |
2533 | (synopsis "Python interface for the XGBoost library"))) |
2534 | ||
d60b064d NG |
2535 | (define-public python-iml |
2536 | (package | |
2537 | (name "python-iml") | |
2538 | (version "0.6.2") | |
2539 | (source | |
2540 | (origin | |
2541 | (method url-fetch) | |
2542 | (uri (pypi-uri "iml" version)) | |
2543 | (sha256 | |
2544 | (base32 | |
2545 | "1k8szlpm19rcwcxdny9qdm3gmaqq8akb4xlvrzyz8c2d679aak6l")))) | |
2546 | (build-system python-build-system) | |
2547 | (propagated-inputs | |
e3196755 | 2548 | (list python-ipython python-numpy python-pandas python-scipy)) |
bcbd6340 | 2549 | (native-inputs |
e3196755 | 2550 | (list python-nose)) |
dd003125 | 2551 | (home-page "https://github.com/interpretable-ml/iml") |
d60b064d NG |
2552 | (synopsis "Interpretable Machine Learning (iML) package") |
2553 | (description "Interpretable ML (iML) is a set of data type objects, | |
2554 | visualizations, and interfaces that can be used by any method designed to | |
2555 | explain the predictions of machine learning models (or really the output of | |
2556 | any function). It currently contains the interface and IO code from the Shap | |
2557 | project, and it will potentially also do the same for the Lime project.") | |
2558 | (license license:expat))) | |
d93ad191 RW |
2559 | |
2560 | (define-public python-keras-applications | |
2561 | (package | |
2562 | (name "python-keras-applications") | |
2563 | (version "1.0.8") | |
2564 | (source | |
2565 | (origin | |
2566 | (method url-fetch) | |
2567 | (uri (pypi-uri "Keras_Applications" version)) | |
2568 | (sha256 | |
2569 | (base32 | |
2570 | "1rcz31ca4axa6kzhjx4lwqxbg4wvlljkj8qj9a7p9sfd5fhzjyam")))) | |
2571 | (build-system python-build-system) | |
2572 | ;; The tests require Keras, but this package is needed to build Keras. | |
2573 | (arguments '(#:tests? #f)) | |
2574 | (propagated-inputs | |
8394619b | 2575 | (list python-h5py python-numpy)) |
d93ad191 | 2576 | (native-inputs |
8394619b LC |
2577 | (list python-pytest python-pytest-cov python-pytest-pep8 |
2578 | python-pytest-xdist)) | |
d93ad191 RW |
2579 | (home-page "https://github.com/keras-team/keras-applications") |
2580 | (synopsis "Reference implementations of popular deep learning models") | |
2581 | (description | |
2582 | "This package provides reference implementations of popular deep learning | |
2583 | models for use with the Keras deep learning framework.") | |
2584 | (license license:expat))) | |
4abc5066 RW |
2585 | |
2586 | (define-public python-keras-preprocessing | |
2587 | (package | |
2588 | (name "python-keras-preprocessing") | |
2589 | (version "1.1.0") | |
2590 | (source | |
2591 | (origin | |
2592 | (method url-fetch) | |
2593 | (uri (pypi-uri "Keras_Preprocessing" version)) | |
2594 | (sha256 | |
2595 | (base32 | |
2596 | "1r98nm4k1svsqjyaqkfk23i31bl1kcfcyp7094yyj3c43phfp3as")))) | |
2597 | (build-system python-build-system) | |
2598 | (propagated-inputs | |
8394619b | 2599 | (list python-numpy python-six)) |
4abc5066 | 2600 | (native-inputs |
8394619b LC |
2601 | (list python-pandas |
2602 | python-pillow | |
2603 | python-pytest | |
2604 | python-pytest-cov | |
2605 | python-pytest-xdist | |
2606 | tensorflow)) | |
4abc5066 RW |
2607 | (home-page "https://github.com/keras-team/keras-preprocessing/") |
2608 | (synopsis "Data preprocessing and augmentation for deep learning models") | |
2609 | (description | |
2610 | "Keras Preprocessing is the data preprocessing and data augmentation | |
2611 | module of the Keras deep learning library. It provides utilities for working | |
2612 | with image data, text data, and sequence data.") | |
2613 | (license license:expat))) | |
f1765b57 RW |
2614 | |
2615 | (define-public python-keras | |
2616 | (package | |
2617 | (name "python-keras") | |
2618 | (version "2.2.4") | |
2619 | (source | |
2620 | (origin | |
2621 | (method url-fetch) | |
2622 | (uri (pypi-uri "Keras" version)) | |
b16e0827 | 2623 | (patches (search-patches "python-keras-integration-test.patch")) |
f1765b57 RW |
2624 | (sha256 |
2625 | (base32 | |
2626 | "1j8bsqzh49vjdxy6l1k4iwax5vpjzniynyd041xjavdzvfii1dlh")))) | |
2627 | (build-system python-build-system) | |
2628 | (arguments | |
2629 | `(#:phases | |
2630 | (modify-phases %standard-phases | |
2631 | (add-after 'unpack 'remove-tests-for-unavailable-features | |
2632 | (lambda _ | |
2633 | (delete-file "keras/backend/theano_backend.py") | |
2634 | (delete-file "keras/backend/cntk_backend.py") | |
2635 | (delete-file "tests/keras/backend/backend_test.py") | |
f1765b57 RW |
2636 | ;; FIXME: This doesn't work because Tensorflow is missing the |
2637 | ;; coder ops library. | |
11e7a534 | 2638 | (delete-file "tests/keras/test_callbacks.py"))) |
f1765b57 | 2639 | (replace 'check |
11e7a534 MC |
2640 | (lambda* (#:key tests? #:allow-other-keys) |
2641 | (when tests? | |
2642 | ;; These tests attempt to download data files from the internet. | |
2643 | (delete-file "tests/integration_tests/test_datasets.py") | |
2644 | (delete-file "tests/integration_tests/imagenet_utils_test.py") | |
2645 | ;; Backport https://github.com/keras-team/keras/pull/12479. | |
2646 | (substitute* "tests/keras/engine/test_topology.py" | |
2647 | (("np.ones\\(\\(3, 2\\)\\)") | |
2648 | "1.")) | |
2649 | (invoke "python" "-m" "pytest" "tests" | |
2650 | "-p" "no:pep8" | |
2651 | ;; FIXME: python-build-system lacks PARALLEL-TESTS? | |
2652 | "-n" (number->string (parallel-job-count)) | |
8b11b4a8 MC |
2653 | "-k" |
2654 | (string-append | |
2655 | ;; The following test fails only in the build | |
2656 | ;; container; skip it. | |
2657 | "not test_selu " | |
2658 | ;; The following test was found flaky and removed in | |
2659 | ;; recent versions. | |
2660 | "and not test_stateful_metrics")))))))) | |
f1765b57 | 2661 | (propagated-inputs |
8394619b LC |
2662 | (list python-h5py |
2663 | python-keras-applications | |
2664 | python-keras-preprocessing | |
2665 | python-numpy | |
2666 | python-pydot | |
2667 | python-pyyaml | |
2668 | python-scipy | |
2669 | python-six | |
2670 | tensorflow | |
2671 | graphviz)) | |
f1765b57 | 2672 | (native-inputs |
8394619b LC |
2673 | (list python-pandas |
2674 | python-pytest | |
2675 | python-pytest-cov | |
2676 | python-pytest-pep8 | |
2677 | python-pytest-timeout | |
2678 | python-pytest-xdist | |
2679 | python-sphinx | |
2680 | python-requests)) | |
f1765b57 RW |
2681 | (home-page "https://github.com/keras-team/keras") |
2682 | (synopsis "High-level deep learning framework") | |
2683 | (description "Keras is a high-level neural networks API, written in Python | |
2684 | and capable of running on top of TensorFlow. It was developed with a focus on | |
2685 | enabling fast experimentation. Use Keras if you need a deep learning library | |
2686 | that: | |
f1765b57 RW |
2687 | @itemize |
2688 | @item Allows for easy and fast prototyping (through user friendliness, | |
2689 | modularity, and extensibility). | |
2690 | @item Supports both convolutional networks and recurrent networks, as well as | |
2691 | combinations of the two. | |
2692 | @item Runs seamlessly on CPU and GPU. | |
2693 | @end itemize\n") | |
2694 | (license license:expat))) | |
6e760872 | 2695 | |
58b13287 GL |
2696 | (define-public gloo |
2697 | (let ((version "0.0.0") ; no proper version tag | |
36f7e1d7 LC |
2698 | (commit "c22a5cfba94edf8ea4f53a174d38aa0c629d070f") |
2699 | (revision "1")) | |
58b13287 GL |
2700 | (package |
2701 | (name "gloo") | |
2702 | (version (git-version version revision commit)) | |
2703 | (source | |
2704 | (origin | |
2705 | (method git-fetch) | |
2706 | (uri (git-reference | |
b0e7b699 | 2707 | (url "https://github.com/facebookincubator/gloo") |
58b13287 GL |
2708 | (commit commit))) |
2709 | (file-name (git-file-name name version)) | |
2710 | (sha256 | |
2711 | (base32 | |
36f7e1d7 | 2712 | "1crmqgybzkgkpbmcx16912gsl5qsj49swa0ikx6mhqgph0chrh11")))) |
58b13287 GL |
2713 | (build-system cmake-build-system) |
2714 | (native-inputs | |
8394619b | 2715 | (list googletest)) |
36f7e1d7 | 2716 | (inputs |
8394619b | 2717 | (list openssl)) |
58b13287 GL |
2718 | (arguments |
2719 | `(#:configure-flags '("-DBUILD_TEST=1") | |
2720 | #:phases | |
2721 | (modify-phases %standard-phases | |
2722 | (replace 'check | |
c83d7d68 LC |
2723 | (lambda* (#:key tests? #:allow-other-keys) |
2724 | (when tests? | |
2725 | (invoke "make" "gloo_test"))))))) | |
58b13287 GL |
2726 | (synopsis "Collective communications library") |
2727 | (description | |
2728 | "Gloo is a collective communications library. It comes with a | |
2729 | number of collective algorithms useful for machine learning applications. | |
2730 | These include a barrier, broadcast, and allreduce.") | |
2731 | (home-page "https://github.com/facebookincubator/gloo") | |
2732 | (license license:bsd-3)))) | |
5e42d197 BG |
2733 | |
2734 | (define-public python-umap-learn | |
2735 | (package | |
2736 | (name "python-umap-learn") | |
34106c85 | 2737 | (version "0.5.3") |
5e42d197 BG |
2738 | (source |
2739 | (origin | |
34106c85 MC |
2740 | (method git-fetch) ;no tests in pypi release |
2741 | (uri (git-reference | |
2742 | (url "https://github.com/lmcinnes/umap") | |
2743 | (commit version))) | |
2744 | (file-name (git-file-name name version)) | |
5e42d197 BG |
2745 | (sha256 |
2746 | (base32 | |
34106c85 | 2747 | "1315jkb0h1b579y9m59632f0nnpksilm01nxx46in0rq8zna8vsb")))) |
5e42d197 | 2748 | (build-system python-build-system) |
34106c85 MC |
2749 | (arguments |
2750 | (list | |
2751 | #:phases | |
2752 | #~(modify-phases %standard-phases | |
a69f2cd0 RW |
2753 | ;; Numba needs a writable dir to cache functions. |
2754 | (add-before 'check 'set-numba-cache-dir | |
2755 | (lambda _ | |
2756 | (setenv "NUMBA_CACHE_DIR" "/tmp"))) | |
34106c85 MC |
2757 | (replace 'check |
2758 | (lambda* (#:key tests? #:allow-other-keys) | |
2759 | (when tests? | |
2760 | (setenv "HOME" "/tmp") | |
9b1a2dcd RW |
2761 | (invoke "pytest" "-vv" "umap" |
2762 | ;; This test can fail because trust may only be | |
2763 | ;; 0.9679405204460967 >= 0.97 | |
2764 | "-k" "not test_densmap_trustworthiness_on_iris_supervised"))))))) | |
34106c85 | 2765 | (native-inputs (list python-pytest)) |
5e42d197 | 2766 | (propagated-inputs |
34106c85 MC |
2767 | (list python-numba |
2768 | python-numpy | |
2769 | python-pynndescent | |
2770 | python-scikit-learn | |
2771 | python-scipy | |
2772 | python-tqdm)) | |
5e42d197 | 2773 | (home-page "https://github.com/lmcinnes/umap") |
34106c85 MC |
2774 | (synopsis "Uniform Manifold Approximation and Projection") |
2775 | (description "Uniform Manifold Approximation and Projection is a dimension | |
2776 | reduction technique that can be used for visualization similarly to t-SNE, but | |
2777 | also for general non-linear dimension reduction.") | |
5e42d197 | 2778 | (license license:bsd-3))) |
b402a3ec | 2779 | |
8df301d4 LC |
2780 | (define-public nnpack |
2781 | (let ((version "0.0") | |
2782 | (commit "c07e3a0400713d546e0dea2d5466dd22ea389c73") | |
2783 | (revision "1")) | |
2784 | (package | |
2785 | (name "nnpack") | |
2786 | (version (git-version version revision commit)) | |
2787 | (home-page "https://github.com/Maratyszcza/NNPACK") | |
2788 | (source (origin | |
2789 | (method git-fetch) | |
2790 | (uri (git-reference (url home-page) (commit commit))) | |
2791 | (file-name (git-file-name name version)) | |
2792 | (sha256 | |
2793 | (base32 | |
2794 | "0s0kk3a35w3yzf0q447p72350sbsh4qhg6vm3y2djbj4xpg7jc8v")) | |
2795 | (patches (search-patches "nnpack-system-libraries.patch")))) | |
2796 | (build-system cmake-build-system) | |
2797 | ;; XXX: The test suite runs but it's very expensive, and on x86_64 CPUs | |
2798 | ;; that lack the right ISA extensions, tests fail with: | |
2799 | ;; | |
2800 | ;; Expected equality of these values: | |
2801 | ;; nnp_status_success | |
2802 | ;; Which is: 0 | |
2803 | ;; status | |
2804 | ;; Which is: 51 | |
2805 | ;; | |
2806 | ;; where 51 is 'nnp_status_unsupported_hardware'. | |
2807 | (arguments '(#:tests? #f)) | |
2808 | (synopsis "Acceleration package for neural network computations") | |
2809 | (description | |
2810 | "NNPACK is an acceleration package for neural network computations. | |
2811 | NNPACK aims to provide high-performance implementations of convnet layers for | |
2812 | multi-core CPUs. | |
2813 | ||
2814 | NNPACK is not intended to be directly used by machine learning researchers; | |
2815 | instead it provides low-level performance primitives leveraged in leading deep | |
2816 | learning frameworks, such as PyTorch, Caffe2, MXNet, tiny-dnn, Caffe, Torch, | |
2817 | and Darknet.") | |
2818 | (inputs | |
8394619b LC |
2819 | (list cpuinfo |
2820 | fp16 | |
2821 | fxdiv | |
2822 | psimd | |
2823 | pthreadpool | |
2824 | googletest)) | |
8df301d4 | 2825 | (native-inputs |
8394619b | 2826 | (list python python-peachpy python-six)) |
8df301d4 LC |
2827 | (license license:bsd-2)))) |
2828 | ||
b402a3ec LC |
2829 | (define-public xnnpack |
2830 | ;; There's currently no tag on this repo. | |
2831 | (let ((version "0.0") | |
87b43ab5 RW |
2832 | (commit "ae108ef49aa5623b896fc93d4298c49d1750d9ba") |
2833 | (revision "2")) | |
b402a3ec LC |
2834 | (package |
2835 | (name "xnnpack") | |
2836 | (version (git-version version revision commit)) | |
dd55ad7f | 2837 | (home-page "https://github.com/google/XNNPACK") ;fork of QNNPACK |
b402a3ec LC |
2838 | (source (origin |
2839 | (method git-fetch) | |
2840 | (uri (git-reference (url home-page) (commit commit))) | |
2841 | (file-name (git-file-name name version)) | |
2842 | (sha256 | |
2843 | (base32 | |
87b43ab5 | 2844 | "0q68q2jxiiiblx45q4337k13ppgh5vqjwrwznchcnpb8hawjj3zl")) |
b402a3ec LC |
2845 | (patches (search-patches "xnnpack-system-libraries.patch")))) |
2846 | (build-system cmake-build-system) | |
2847 | (arguments | |
2848 | '(#:configure-flags '("-DXNNPACK_USE_SYSTEM_LIBS=YES" | |
2849 | "-DBUILD_SHARED_LIBS=ON" | |
2850 | "-DXNNPACK_LIBRARY_TYPE=shared" | |
2851 | "-DXNNPACK_BUILD_TESTS=FALSE" ;FIXME: see below | |
2852 | "-DXNNPACK_BUILD_BENCHMARKS=FALSE") | |
2853 | ||
2854 | ;; FIXME: Building tests leads to a CMake error: | |
2855 | ;; | |
2856 | ;; ADD_LIBRARY cannot create target "all_microkernels" because | |
2857 | ;; another target with the same name already exists. | |
2858 | #:tests? #f)) | |
2859 | (inputs | |
8394619b LC |
2860 | (list cpuinfo |
2861 | pthreadpool | |
2862 | googletest | |
2863 | googlebenchmark | |
2864 | fxdiv | |
2865 | fp16 | |
2866 | psimd)) | |
b402a3ec LC |
2867 | (synopsis "Optimized floating-point neural network inference operators") |
2868 | (description | |
2869 | "XNNPACK is a highly optimized library of floating-point neural network | |
2870 | inference operators for ARM, WebAssembly, and x86 platforms. XNNPACK is not | |
2871 | intended for direct use by deep learning practitioners and researchers; | |
2872 | instead it provides low-level performance primitives for accelerating | |
2873 | high-level machine learning frameworks, such as TensorFlow Lite, | |
2874 | TensorFlow.js, PyTorch, and MediaPipe.") | |
2875 | (license license:bsd-3)))) | |
2876 | ||
563bb6ea | 2877 | ;; Please also update python-torchvision when updating this package. |
dd55ad7f LC |
2878 | (define-public python-pytorch |
2879 | (package | |
2880 | (name "python-pytorch") | |
deae5d0d | 2881 | (version "1.12.0") |
dd55ad7f LC |
2882 | (source (origin |
2883 | (method git-fetch) | |
2884 | (uri (git-reference | |
2885 | (url "https://github.com/pytorch/pytorch") | |
2886 | (commit (string-append "v" version)) | |
2887 | (recursive? #t))) | |
2888 | (file-name (git-file-name name version)) | |
2889 | (sha256 | |
2890 | (base32 | |
deae5d0d | 2891 | "0pdqi91qzgyx947zv4pw2fdj9vpqvdhfzw1ydjd4mpqm8g5njgnz")) |
dd55ad7f LC |
2892 | (patches (search-patches "python-pytorch-system-libraries.patch" |
2893 | "python-pytorch-runpath.patch")) | |
2894 | (modules '((guix build utils))) | |
2895 | (snippet | |
2896 | '(begin | |
2897 | ;; XXX: Let's be clear: this package is a bundling fest. We | |
2898 | ;; delete as much as we can, but there's still a lot left. | |
2899 | (for-each (lambda (directory) | |
2900 | (delete-file-recursively | |
2901 | (string-append "third_party/" directory))) | |
2902 | '("benchmark" "cpuinfo" "eigen" | |
2903 | ||
2904 | ;; FIXME: QNNPACK (of which XNNPACK is a fork) | |
2905 | ;; needs these. | |
2906 | ;; "FP16" "FXdiv" "gemmlowp" "psimd" | |
2907 | ||
d326dec8 | 2908 | "gloo" "googletest" "ios-cmake" "NNPACK" |
dd55ad7f LC |
2909 | "onnx" "protobuf" "pthreadpool" |
2910 | "pybind11" "python-enum" "python-peachpy" | |
20f55375 | 2911 | "python-six" "tbb" "XNNPACK" "zstd")))))) |
dd55ad7f LC |
2912 | (build-system python-build-system) |
2913 | (arguments | |
2914 | '(#:phases (modify-phases %standard-phases | |
2915 | (add-before 'build 'use-system-libraries | |
2916 | (lambda* (#:key outputs #:allow-other-keys) | |
2917 | ;; Tell 'setup.py' to let 'CMakeLists.txt' know that we | |
2918 | ;; want to use "system libraries" instead of the bundled | |
2919 | ;; ones. | |
2920 | (setenv "USE_SYSTEM_LIBS" "1") | |
2921 | ||
deae5d0d RW |
2922 | (substitute* "cmake/Dependencies.cmake" |
2923 | (("if\\(USE_SYSTEM_BIND11\\)") | |
2924 | "if(TRUE)")) | |
2925 | ||
dd55ad7f | 2926 | ;; XXX: Disable that for simplicity for now. |
a537ef5e | 2927 | (setenv "USE_FBGEMM" "0"))) |
dd55ad7f LC |
2928 | (add-before 'build 'make-things-writable |
2929 | (lambda _ | |
2930 | ;; The 'build_caffe2' function in | |
2931 | ;; 'tools/build_pytorch_libs.py', called from the | |
2932 | ;; top-level 'setup.py', needs write access to this | |
2933 | ;; directory. | |
2934 | (for-each make-file-writable | |
2935 | (find-files "caffe2/proto" "." | |
2936 | #:directories? #t)))) | |
2937 | (replace 'check | |
2938 | (lambda* (#:key inputs outputs tests? #:allow-other-keys) | |
2939 | ;; Run the test suite following the instructions in | |
2940 | ;; 'CONTRIBUTING.md'. XXX: Unfortunately this doesn't | |
1e13f736 | 2941 | ;; work, unless you set GUIX_PYTHONPATH presumably. |
dd55ad7f | 2942 | (when tests? |
1e13f736 RW |
2943 | (add-installed-pythonpath inputs outputs) |
2944 | (invoke "python" "test/run_test.py")))) | |
dd55ad7f LC |
2945 | (add-after 'install 'remove-test-executables |
2946 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
2947 | ;; Remove test executables, but keep other executables | |
2948 | ;; such as 'torch_shm_manager' and and .so files such as | |
2949 | ;; 'libtorch_global_deps.so'. | |
2950 | (let ((python-site (site-packages inputs outputs))) | |
2951 | (for-each delete-file | |
2952 | (find-files python-site | |
20f55375 LC |
2953 | "(^test_cpp_rpc|_test)$"))))) |
2954 | (add-after 'install 'remove-caffe2-onnx-scripts | |
2955 | (lambda* (#:key outputs #:allow-other-keys) | |
2956 | (let* ((out (assoc-ref outputs "out")) | |
2957 | (bin (string-append out "/bin"))) | |
2958 | ;; Remove 'convert-caffe2-to-onnx' and | |
2959 | ;; 'convert-onnx-to-caffe2': they seem to be | |
2960 | ;; deprecated and they cause a failure of the | |
2961 | ;; 'sanity-check' phase: | |
2962 | ;; | |
2963 | ;; ImportError: cannot import name 'metanet_pb2' from partially initialized module 'caffe2.proto' (most likely due to a circular import) | |
2964 | (for-each delete-file | |
2965 | (find-files bin "^convert-.*caffe2")) | |
2966 | ||
2967 | (substitute* (find-files out "^entry_points\\.txt$") | |
2968 | (("^convert-.*" all) | |
2969 | (string-append "# " all "\n"))))))) | |
dd55ad7f LC |
2970 | |
2971 | ;; XXX: Tests attempt to download data such as | |
2972 | ;; <https://raw.githubusercontent.com/pytorch/test-infra/master/stats/slow-tests.json>. | |
443f3e17 | 2973 | ;; We're also missing some Python modules, such as expecttest. |
dd55ad7f LC |
2974 | #:tests? #f)) |
2975 | (native-inputs | |
8394619b | 2976 | (list cmake ninja)) |
dd55ad7f | 2977 | (inputs |
8394619b LC |
2978 | (list eigen |
2979 | ;; ("fmt" ,fmt) | |
2980 | fp16 | |
2981 | gemmlowp | |
2982 | googletest | |
2983 | googlebenchmark | |
2984 | gloo | |
2985 | nnpack | |
2986 | openblas | |
2987 | openmpi | |
2988 | pthreadpool | |
2989 | protobuf | |
2990 | pybind11 | |
2991 | sleef | |
2992 | xnnpack | |
2993 | zstd)) | |
dd55ad7f | 2994 | (propagated-inputs |
8394619b LC |
2995 | (list python-astunparse |
2996 | python-click | |
2997 | python-numpy | |
2998 | python-pyyaml | |
2999 | python-cffi | |
3000 | python-typing-extensions | |
3001 | python-future | |
3002 | python-six | |
3003 | python-requests | |
20f55375 | 3004 | onnx ;propagated for its Python modules |
8394619b LC |
3005 | onnx-optimizer |
3006 | cpuinfo)) | |
dd55ad7f LC |
3007 | (home-page "https://pytorch.org/") |
3008 | (synopsis "Python library for tensor computation and deep neural networks") | |
3009 | (description | |
3010 | "PyTorch is a Python package that provides two high-level features: | |
3011 | ||
3012 | @itemize | |
3013 | @item tensor computation (like NumPy) with strong GPU acceleration; | |
3014 | @item deep neural networks (DNNs) built on a tape-based autograd system. | |
3015 | @end itemize | |
3016 | ||
3017 | You can reuse Python packages such as NumPy, SciPy, and Cython to extend | |
3018 | PyTorch when needed. | |
3019 | ||
3020 | Note: currently this package does not provide GPU support.") | |
3021 | (license license:bsd-3))) | |
5795fbbd | 3022 | |
c929619b RW |
3023 | (define-public python-pytorch-for-r-torch |
3024 | (package | |
3025 | (inherit python-pytorch) | |
3026 | (name "python-pytorch") | |
3027 | (version "1.11.0") | |
3028 | (source (origin | |
3029 | (method git-fetch) | |
3030 | (uri (git-reference | |
3031 | (url "https://github.com/pytorch/pytorch") | |
3032 | (commit (string-append "v" version)) | |
3033 | (recursive? #t))) | |
3034 | (file-name (git-file-name name version)) | |
3035 | (sha256 | |
3036 | (base32 | |
3037 | "1zbk7y74r0ycsfa7x59jnhwhs1gj5rs3n89p15y0212iszgbljq8")) | |
3038 | (patches (search-patches "python-pytorch-system-libraries.patch" | |
3039 | "python-pytorch-runpath.patch")) | |
3040 | (modules '((guix build utils))) | |
3041 | (snippet | |
3042 | '(begin | |
3043 | ;; XXX: Let's be clear: this package is a bundling fest. We | |
3044 | ;; delete as much as we can, but there's still a lot left. | |
3045 | (for-each (lambda (directory) | |
3046 | (delete-file-recursively | |
3047 | (string-append "third_party/" directory))) | |
3048 | '("benchmark" "cpuinfo" "eigen" | |
3049 | ||
3050 | ;; FIXME: QNNPACK (of which XNNPACK is a fork) | |
3051 | ;; needs these. | |
3052 | ;; "FP16" "FXdiv" "gemmlowp" "psimd" | |
3053 | ||
3054 | "gloo" "googletest" "ios-cmake" "NNPACK" | |
3055 | "onnx" "protobuf" "pthreadpool" | |
3056 | "pybind11" "python-enum" "python-peachpy" | |
3057 | "python-six" "tbb" "XNNPACK" "zstd")))))))) | |
7b676317 | 3058 | |
563bb6ea RW |
3059 | ;; Keep this in sync with python-pytorch |
3060 | (define-public python-torchvision | |
3061 | (package | |
3062 | (name "python-torchvision") | |
ba86c760 | 3063 | (version "0.13.0") |
563bb6ea RW |
3064 | (source (origin |
3065 | (method git-fetch) | |
3066 | (uri (git-reference | |
3067 | (url "https://github.com/pytorch/vision") | |
3068 | (commit (string-append "v" version)) | |
3069 | (recursive? #t))) | |
3070 | (file-name (git-file-name name version)) | |
3071 | (sha256 | |
3072 | (base32 | |
ba86c760 | 3073 | "19f6s3ffwkdvjjbvib18c8n7vhysg58smxzq3rvii1c0z4g3b0cw")))) |
563bb6ea RW |
3074 | (build-system python-build-system) |
3075 | (arguments | |
3076 | `(#:tests? #false ;the test suite is expensive and there is no easy way | |
3077 | ;to subset it. | |
3078 | #:phases | |
3079 | (modify-phases %standard-phases | |
3080 | (replace 'check | |
3081 | (lambda* (#:key tests? #:allow-other-keys) | |
3082 | (when tests? | |
3083 | (invoke "pytest" "-vv"))))))) | |
3084 | (inputs | |
3085 | (list libpng | |
3086 | libjpeg-turbo)) | |
3087 | (propagated-inputs | |
3088 | (list python-numpy | |
3089 | python-typing-extensions | |
3090 | python-requests | |
3091 | python-pillow | |
3092 | python-pillow-simd | |
3093 | python-pytorch)) | |
3094 | (native-inputs | |
3095 | (list which python-pytest)) | |
3096 | (home-page "https://pytorch.org/vision/stable/index.html") | |
3097 | (synopsis " Datasets, transforms and models specific to computer vision") | |
3098 | (description | |
3099 | "The torchvision package consists of popular datasets, model architectures, | |
3100 | and common image transformations for computer vision.") | |
3101 | (license license:bsd-3))) | |
3102 | ||
c6136b48 RW |
3103 | (define-public python-torchfile |
3104 | (package | |
3105 | (name "python-torchfile") | |
3106 | (version "0.1.0") | |
3107 | (source (origin | |
3108 | (method url-fetch) | |
3109 | (uri (pypi-uri "torchfile" version)) | |
3110 | (sha256 | |
3111 | (base32 | |
3112 | "0vhklj6krl9r0kdynb4kcpwp8y1ihl2zw96byallay3k9c9zwgd5")))) | |
3113 | (build-system python-build-system) | |
3114 | (arguments '(#:tests? #false)) ;there are no tests | |
3115 | (propagated-inputs | |
3116 | (list python-numpy)) | |
3117 | (home-page "https://github.com/bshillingford/python-torchfile") | |
3118 | (synopsis "Torch7 binary serialized file parser") | |
3119 | (description "This package enables you to deserialize Lua torch-serialized objects from | |
3120 | Python.") | |
3121 | (license license:bsd-3))) | |
3122 | ||
5795fbbd RW |
3123 | (define-public python-hmmlearn |
3124 | (package | |
3125 | (name "python-hmmlearn") | |
3126 | (version "0.2.6") | |
3127 | (source | |
3128 | (origin | |
3129 | (method url-fetch) | |
3130 | (uri (pypi-uri "hmmlearn" version)) | |
3131 | (sha256 | |
3132 | (base32 | |
53a8e8fd EF |
3133 | "1my0j3rzp17438idr32ssh0j969a98yjblx5igx5kgiiigr9qa1a")) |
3134 | (snippet | |
3135 | #~(begin | |
3136 | (use-modules ((guix build utils))) | |
3137 | (delete-file "lib/hmmlearn/_hmmc.c"))))) | |
5795fbbd RW |
3138 | (build-system python-build-system) |
3139 | (arguments | |
3140 | `(#:phases | |
3141 | (modify-phases %standard-phases | |
3142 | (replace 'check | |
3143 | (lambda* (#:key inputs outputs tests? #:allow-other-keys) | |
3144 | (when tests? | |
3145 | (add-installed-pythonpath inputs outputs) | |
3146 | (with-directory-excursion (string-append (assoc-ref outputs "out") "/lib") | |
3147 | (invoke "python" "-m" "pytest")))))))) | |
3148 | (propagated-inputs | |
8394619b LC |
3149 | (list python-cython python-numpy python-scikit-learn python-scipy |
3150 | python-setuptools-scm)) | |
5795fbbd | 3151 | (native-inputs |
8394619b | 3152 | (list python-pytest)) |
5795fbbd RW |
3153 | (home-page "https://github.com/hmmlearn/hmmlearn") |
3154 | (synopsis "Hidden Markov Models with scikit-learn like API") | |
3155 | (description | |
3156 | "Hmmlearn is a set of algorithms for unsupervised learning and inference | |
3157 | of Hidden Markov Models.") | |
3158 | (license license:bsd-3))) | |
7146e553 RW |
3159 | |
3160 | ;; Keep this in sync with the r-torch package. | |
3161 | (define-public liblantern | |
3162 | (package | |
3163 | (name "liblantern") | |
43cf8861 | 3164 | (version "0.8.0") |
7146e553 RW |
3165 | (source |
3166 | (origin | |
3167 | (method git-fetch) | |
3168 | (uri (git-reference | |
3169 | (url "https://github.com/mlverse/torch") | |
3170 | (commit (string-append "v" version)))) | |
3171 | (file-name (git-file-name name version)) | |
3172 | (sha256 | |
43cf8861 | 3173 | (base32 "1xkqyj1clj1r70yrp5qpbpyf0xmh9c128005idshi7vk883wfp77")))) |
7146e553 RW |
3174 | (build-system cmake-build-system) |
3175 | (arguments | |
3176 | (list | |
3177 | #:tests? #false ;no test target | |
3178 | #:phases | |
3179 | #~(modify-phases %standard-phases | |
3180 | (add-after 'unpack 'chdir | |
3181 | (lambda _ (chdir "lantern"))) | |
3182 | (add-after 'chdir 'do-not-download-binaries | |
3183 | (lambda* (#:key inputs #:allow-other-keys) | |
3184 | (substitute* "CMakeLists.txt" | |
3185 | (("find_package\\(Torch.*") "set(TORCH_CXX_FLAGS \"-ltorch\")\n") | |
3186 | (("retrieve_lib\\(.*") "")) | |
3187 | (setenv "LIBRARY_PATH" | |
3188 | (string-append | |
3189 | (search-input-directory | |
3190 | inputs "/lib/python3.9/site-packages/torch/lib") | |
3191 | ":" (or (getenv "LIBRARY_PATH") ""))) | |
3192 | (setenv "CPLUS_INCLUDE_PATH" | |
3193 | (string-append | |
3194 | (search-input-directory | |
3195 | inputs "lib/python3.9/site-packages/torch/include/torch/csrc/api/include/") | |
3196 | ":" | |
3197 | (search-input-directory | |
3198 | inputs "lib/python3.9/site-packages/torch/include/") | |
3199 | ":" | |
3200 | (or (getenv "CPLUS_INCLUDE_PATH") ""))) | |
3201 | (setenv "C_INCLUDE_PATH" | |
3202 | (string-append | |
3203 | (search-input-directory | |
3204 | inputs "lib/python3.9/site-packages/torch/include/") | |
3205 | ":" | |
3206 | (or (getenv "C_INCLUDE_PATH") ""))))) | |
3207 | (replace 'install | |
3208 | (lambda _ | |
3209 | (install-file | |
3210 | "../build/liblantern.so" | |
3211 | (string-append #$output "/lib")) | |
3212 | (copy-recursively | |
3213 | "../lantern/include" | |
3214 | (string-append #$output "/include"))))))) | |
3215 | (inputs (list python-pytorch-for-r-torch)) | |
3216 | (home-page "https://github.com/mlverse/torch/") | |
3217 | (synopsis "C API to libtorch") | |
3218 | (description | |
3219 | "Lantern provides a C API to the libtorch machine learning library.") | |
3220 | (license license:expat))) | |
bafa7a00 | 3221 | |
2cf138db RW |
3222 | (define-public python-lap |
3223 | (package | |
3224 | (name "python-lap") | |
3225 | (version "0.4.0") | |
3226 | (source (origin | |
3227 | (method url-fetch) | |
3228 | (uri (pypi-uri "lap" version)) | |
3229 | (sha256 | |
3230 | (base32 | |
3231 | "0fqfxpq4jg9h4wxjw540gjmvfg1ccc1nssk7i9njg7qfdybxknn4")))) | |
3232 | (build-system python-build-system) | |
3233 | (arguments | |
3234 | `(#:phases | |
3235 | (modify-phases %standard-phases | |
3236 | (replace 'build | |
3237 | (lambda* (#:key inputs #:allow-other-keys) | |
3238 | (invoke "python" "setup.py" "build" | |
3239 | "--cpu-baseline=sse2"))) | |
3240 | (replace 'check | |
3241 | (lambda* (#:key tests? #:allow-other-keys) | |
3242 | (when tests? | |
3243 | ;; The tests must be run from elsewhere. | |
3244 | (mkdir-p "/tmp/test") | |
3245 | (copy-recursively "lap/tests" "/tmp/test") | |
3246 | (with-directory-excursion "/tmp/test" | |
3247 | (invoke "pytest" "-vv")))))))) | |
3248 | (propagated-inputs | |
3249 | (list python-numpy | |
3250 | python-scipy)) | |
3251 | (native-inputs | |
3252 | (list python-cython python-pytest)) | |
3253 | (home-page "https://github.com/gatagat/lap") | |
3254 | (synopsis "Linear Assignment Problem solver (LAPJV/LAPMOD).") | |
3255 | (description "Lap is a linear assignment problem solver using Jonker-Volgenant | |
3256 | algorithm for dense (LAPJV) or sparse (LAPMOD) matrices.") | |
3257 | (license license:bsd-2))) | |
3258 | ||
ff37afb2 RW |
3259 | (define-public python-visdom |
3260 | (package | |
3261 | (name "python-visdom") | |
3262 | (version "0.1.8.9") | |
3263 | (source (origin | |
3264 | (method url-fetch) | |
3265 | (uri (pypi-uri "visdom" version)) | |
3266 | (sha256 | |
3267 | (base32 | |
3268 | "09kiczx2i5asqsv214fz7sx8wlyldgbqvxwrd0alhjn24cvx4fn7")))) | |
3269 | (build-system python-build-system) | |
3270 | (propagated-inputs | |
3271 | (list python-jsonpatch | |
3272 | python-numpy | |
3273 | python-pillow | |
3274 | python-pyzmq | |
3275 | python-requests | |
3276 | python-scipy | |
3277 | python-six | |
3278 | python-torchfile | |
3279 | python-tornado | |
3280 | python-websocket-client)) | |
3281 | (home-page "https://github.com/fossasia/visdom") | |
3282 | (synopsis "Visualizations of live, rich data for Torch and Numpy") | |
3283 | (description | |
3284 | "This package provides a tool for visualizing live, rich data for Torch | |
3285 | and Numpy.") | |
3286 | (license license:asl2.0))) | |
3287 | ||
bafa7a00 RW |
3288 | (define-public python-pyro-api |
3289 | (package | |
3290 | (name "python-pyro-api") | |
3291 | (version "0.1.2") | |
3292 | (source (origin | |
3293 | (method url-fetch) | |
3294 | (uri (pypi-uri "pyro-api" version)) | |
3295 | (sha256 | |
3296 | (base32 | |
3297 | "086r2h6x9i5d9ayl1x65lx6p84rlydzsn8xingxc588ab3ch1fd1")))) | |
3298 | (build-system python-build-system) | |
3299 | (arguments '(#:tests? #false)) ;requires pyro | |
3300 | (native-inputs | |
3301 | (list python-flake8 | |
3302 | python-ipython | |
3303 | python-pytest | |
3304 | python-sphinx | |
3305 | python-sphinx-rtd-theme)) | |
3306 | (home-page "https://github.com/pyro-ppl/pyro-api") | |
3307 | (synopsis "Generic API for dispatch to Pyro backends.") | |
3308 | (description "This package provides a generic API for dispatch to Pyro backends.") | |
3309 | (license license:asl2.0))) | |
6416e772 RW |
3310 | |
3311 | (define-public python-pyro-ppl | |
3312 | (package | |
3313 | (name "python-pyro-ppl") | |
3314 | (version "1.8.1") | |
3315 | ;; The sources on pypi don't include tests. | |
3316 | (source | |
3317 | (origin | |
3318 | (method git-fetch) | |
3319 | (uri (git-reference | |
3320 | (url "https://github.com/pyro-ppl/pyro") | |
3321 | (commit version))) | |
3322 | (file-name (git-file-name name version)) | |
3323 | (sha256 | |
3324 | (base32 "0ns20mr8qgjshzbplrfzaz1xhb9ldbgvrj2rzlsxvns2bi1ddyl5")))) | |
3325 | (build-system python-build-system) | |
3326 | (arguments | |
3327 | `(#:phases | |
3328 | (modify-phases %standard-phases | |
3329 | (replace 'check | |
3330 | (lambda* (#:key tests? #:allow-other-keys) | |
3331 | ;; This tests features that are only implemented when non-free | |
3332 | ;; software is available (Intel MKL or CUDA). | |
3333 | (for-each delete-file | |
3334 | (list "tests/distributions/test_spanning_tree.py" | |
3335 | "tests/infer/mcmc/test_mcmc_api.py")) | |
3336 | ||
3337 | ;; Four test_gamma_elbo tests fail with bad values for unknown | |
3338 | ;; reasons. | |
3339 | (delete-file "tests/distributions/test_rejector.py") | |
3340 | ;; This test fails sometimes. | |
3341 | (delete-file "tests/optim/test_optim.py") | |
3342 | (invoke "pytest" "-vv" "--stage=unit")))))) | |
3343 | (propagated-inputs | |
3344 | (list python-numpy | |
3345 | python-opt-einsum | |
3346 | python-pyro-api | |
3347 | python-pytorch | |
3348 | python-tqdm)) | |
3349 | (native-inputs | |
3350 | (list ninja | |
3351 | jupyter | |
3352 | python-black | |
3353 | python-flake8 | |
3354 | python-graphviz | |
3355 | python-isort | |
3356 | python-lap | |
3357 | python-matplotlib | |
3358 | python-mypy | |
3359 | python-nbformat | |
3360 | python-nbsphinx | |
3361 | python-nbstripout | |
3362 | python-nbval | |
3363 | python-pandas | |
3364 | python-pillow | |
3365 | python-pypandoc | |
3366 | python-pytest | |
3367 | python-pytest-cov | |
3368 | python-pytest-xdist | |
3369 | python-scikit-learn | |
3370 | python-scipy | |
3371 | python-seaborn | |
3372 | python-sphinx | |
3373 | python-sphinx-rtd-theme | |
3374 | python-torchvision | |
3375 | python-visdom | |
3376 | python-wget | |
3377 | python-yapf)) | |
3378 | (home-page "https://pyro.ai") | |
3379 | (synopsis "Python library for probabilistic modeling and inference") | |
3380 | (description | |
3381 | "This package provides a Python library for probabilistic modeling and | |
3382 | inference.") | |
3383 | (license license:asl2.0))) |