gnu: libelf: Use archived home page and mirrored source.
[jackhill/guix/guix.git] / gnu / packages / machine-learning.scm
CommitLineData
741115b6 1;;; GNU Guix --- Functional package management for GNU
7d4cab74 2;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
25e0037a 3;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
be6eb2f1
RW
4;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com>
5;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
5ed72097 6;;; Copyright © 2018, 2019 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>
741115b6
RW
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages machine-learning)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
23aab4ab 34 #:use-module (guix svn-download)
c1670a81 35 #:use-module (guix build-system cmake)
741115b6 36 #:use-module (guix build-system gnu)
0a3063d6 37 #:use-module (guix build-system ocaml)
be6eb2f1 38 #:use-module (guix build-system python)
8406138b 39 #:use-module (guix build-system r)
a9b34762 40 #:use-module (guix git-download)
71f80f54 41 #:use-module (gnu packages)
0dfeb285 42 #:use-module (gnu packages adns)
5a14e81e 43 #:use-module (gnu packages algebra)
b9445d0b 44 #:use-module (gnu packages audio)
23aab4ab 45 #:use-module (gnu packages autotools)
b9445d0b 46 #:use-module (gnu packages base)
99260014 47 #:use-module (gnu packages bash)
0931c609 48 #:use-module (gnu packages boost)
be6eb2f1 49 #:use-module (gnu packages check)
0931c609 50 #:use-module (gnu packages compression)
9e37e537 51 #:use-module (gnu packages cran)
4fa16c9a 52 #:use-module (gnu packages databases)
23aab4ab 53 #:use-module (gnu packages dejagnu)
0931c609 54 #:use-module (gnu packages gcc)
b9445d0b
RW
55 #:use-module (gnu packages glib)
56 #:use-module (gnu packages gstreamer)
5f0ff6a9 57 #:use-module (gnu packages image)
b9445d0b 58 #:use-module (gnu packages linux)
0931c609 59 #:use-module (gnu packages maths)
112c2c01 60 #:use-module (gnu packages mpi)
0a3063d6 61 #:use-module (gnu packages ocaml)
3929f46c 62 #:use-module (gnu packages onc-rpc)
791c11d6 63 #:use-module (gnu packages perl)
c1670a81 64 #:use-module (gnu packages pkg-config)
0dfeb285 65 #:use-module (gnu packages protobuf)
0931c609 66 #:use-module (gnu packages python)
10451f6b 67 #:use-module (gnu packages python-web)
44d10b1f 68 #:use-module (gnu packages python-xyz)
4fa16c9a 69 #:use-module (gnu packages serialization)
c1670a81 70 #:use-module (gnu packages statistics)
4fa16c9a 71 #:use-module (gnu packages sqlite)
c1670a81 72 #:use-module (gnu packages swig)
0dfeb285 73 #:use-module (gnu packages tls)
99260014 74 #:use-module (gnu packages web)
5f0ff6a9 75 #:use-module (gnu packages xml)
39bb4937
RW
76 #:use-module (gnu packages xorg)
77 #:use-module (ice-9 match))
741115b6 78
a9b34762
MM
79(define-public fann
80 ;; The last release is >100 commits behind, so we package from git.
81 (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7"))
82 (package
83 (name "fann")
84 (version (string-append "2.2.0-1." (string-take commit 8)))
85 (source (origin
86 (method git-fetch)
87 (uri (git-reference
88 (url "https://github.com/libfann/fann.git")
89 (commit commit)))
90 (file-name (string-append name "-" version "-checkout"))
91 (sha256
92 (base32
93 "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x"))))
94 (build-system cmake-build-system)
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (replace 'check
99 (lambda* (#:key outputs #:allow-other-keys)
100 (let* ((out (assoc-ref outputs "out")))
101 (with-directory-excursion (string-append (getcwd) "/tests")
102 (invoke "./fann_tests"))))))))
103 (home-page "http://leenissen.dk/fann/wp/")
104 (synopsis "Fast Artificial Neural Network")
105 (description
106 "FANN is a free open source neural network library, which implements
107multilayer artificial neural networks in C with support for both fully
108connected and sparsely connected networks.")
109 (license license:lgpl2.1))))
110
741115b6
RW
111(define-public libsvm
112 (package
113 (name "libsvm")
2cffa2f2 114 (version "3.23")
741115b6
RW
115 (source
116 (origin
117 (method url-fetch)
d1308c5e
TGR
118 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
119 name "-" version ".tar.gz"))
741115b6 120 (sha256
2cffa2f2 121 (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5"))))
741115b6
RW
122 (build-system gnu-build-system)
123 (arguments
2cffa2f2 124 `(#:tests? #f ; no "check" target
741115b6
RW
125 #:phases (modify-phases %standard-phases
126 (delete 'configure)
127 (replace
d1308c5e 128 'install ; no ‘install’ target
741115b6
RW
129 (lambda* (#:key outputs #:allow-other-keys)
130 (let* ((out (assoc-ref outputs "out"))
131 (bin (string-append out "/bin/")))
132 (mkdir-p bin)
133 (for-each (lambda (file)
134 (copy-file file (string-append bin file)))
135 '("svm-train"
136 "svm-predict"
137 "svm-scale")))
138 #t)))))
139 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
140 (synopsis "Library for Support Vector Machines")
141 (description
142 "LIBSVM is a machine learning library for support vector
143classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
144distribution estimation (one-class SVM). It supports multi-class
145classification.")
146 (license license:bsd-3)))
71f80f54
RW
147
148(define-public python-libsvm
149 (package (inherit libsvm)
150 (name "python-libsvm")
151 (build-system gnu-build-system)
152 (arguments
2cffa2f2 153 `(#:tests? #f ; no "check" target
71f80f54
RW
154 #:make-flags '("-C" "python")
155 #:phases
156 (modify-phases %standard-phases
157 (delete 'configure)
158 (replace
d1308c5e 159 'install ; no ‘install’ target
71f80f54
RW
160 (lambda* (#:key inputs outputs #:allow-other-keys)
161 (let ((site (string-append (assoc-ref outputs "out")
162 "/lib/python"
163 (string-take
164 (string-take-right
165 (assoc-ref inputs "python") 5) 3)
166 "/site-packages/")))
167 (substitute* "python/svm.py"
168 (("../libsvm.so.2") "libsvm.so.2"))
169 (mkdir-p site)
170 (for-each (lambda (file)
171 (copy-file file (string-append site (basename file))))
172 (find-files "python" "\\.py"))
173 (copy-file "libsvm.so.2"
174 (string-append site "libsvm.so.2")))
175 #t)))))
176 (inputs
177 `(("python" ,python)))
178 (synopsis "Python bindings of libSVM")))
0931c609 179
23aab4ab
RW
180(define-public ghmm
181 ;; The latest release candidate is several years and a couple of fixes have
182 ;; been published since. This is why we download the sources from the SVN
183 ;; repository.
184 (let ((svn-revision 2341))
185 (package
186 (name "ghmm")
187 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
188 (source (origin
189 (method svn-fetch)
190 (uri (svn-reference
191 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
192 (revision svn-revision)))
193 (file-name (string-append name "-" version))
194 (sha256
195 (base32
196 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
197 (build-system gnu-build-system)
198 (arguments
ced12a7b
RW
199 `(#:imported-modules (,@%gnu-build-system-modules
200 (guix build python-build-system))
201 #:phases
23aab4ab
RW
202 (modify-phases %standard-phases
203 (add-after 'unpack 'enter-dir
204 (lambda _ (chdir "ghmm") #t))
ced12a7b
RW
205 (delete 'check)
206 (add-after 'install 'check
207 (assoc-ref %standard-phases 'check))
208 (add-before 'check 'fix-PYTHONPATH
209 (lambda* (#:key inputs outputs #:allow-other-keys)
210 (let ((python-version ((@@ (guix build python-build-system)
211 get-python-version)
212 (assoc-ref inputs "python"))))
213 (setenv "PYTHONPATH"
214 (string-append (getenv "PYTHONPATH")
215 ":" (assoc-ref outputs "out")
216 "/lib/python" python-version
217 "/site-packages")))
23aab4ab
RW
218 #t))
219 (add-after 'enter-dir 'fix-runpath
220 (lambda* (#:key outputs #:allow-other-keys)
221 (substitute* "ghmmwrapper/setup.py"
222 (("^(.*)extra_compile_args = \\[" line indent)
223 (string-append indent
224 "extra_link_args = [\"-Wl,-rpath="
225 (assoc-ref outputs "out") "/lib\"],\n"
226 line
227 "\"-Wl,-rpath="
228 (assoc-ref outputs "out")
229 "/lib\", ")))
230 #t))
231 (add-after 'enter-dir 'disable-broken-tests
232 (lambda _
233 (substitute* "tests/Makefile.am"
234 ;; GHMM_SILENT_TESTS is assumed to be a command.
235 (("TESTS_ENVIRONMENT.*") "")
236 ;; Do not build broken tests.
237 (("chmm .*") "")
238 (("read_fa .*") "")
239 (("mcmc .*") "")
240 (("label_higher_order_test.*$")
241 "label_higher_order_test\n"))
242
243 ;; These Python unittests are broken as there is no gato.
244 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
245 (substitute* "ghmmwrapper/ghmmunittests.py"
246 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
247 line indent)
248 (string-append indent
249 "@unittest.skip(\"Disabled by Guix\")\n"
250 line)))
251 #t))
d10092b8 252 (add-after 'disable-broken-tests 'autogen
23aab4ab 253 (lambda _
3107259f 254 (invoke "bash" "autogen.sh"))))))
23aab4ab
RW
255 (inputs
256 `(("python" ,python-2) ; only Python 2 is supported
257 ("libxml2" ,libxml2)))
258 (native-inputs
259 `(("pkg-config" ,pkg-config)
260 ("dejagnu" ,dejagnu)
261 ("swig" ,swig)
262 ("autoconf" ,autoconf)
263 ("automake" ,automake)
264 ("libtool" ,libtool)))
265 (home-page "http://ghmm.org")
266 (synopsis "Hidden Markov Model library")
267 (description
268 "The General Hidden Markov Model library (GHMM) is a C library with
269additional Python bindings implementing a wide range of types of @dfn{Hidden
d1e4ad1b 270Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
23aab4ab
RW
271training, HMM clustering, HMM mixtures.")
272 (license license:lgpl2.0+))))
273
791c11d6
BW
274(define-public mcl
275 (package
276 (name "mcl")
277 (version "14.137")
278 (source (origin
279 (method url-fetch)
280 (uri (string-append
281 "http://micans.org/mcl/src/mcl-"
282 (string-replace-substring version "." "-")
283 ".tar.gz"))
284 (sha256
285 (base32
286 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
287 (build-system gnu-build-system)
288 (arguments
289 `(#:configure-flags (list "--enable-blast")))
290 (inputs
291 `(("perl" ,perl)))
292 (home-page "http://micans.org/mcl/")
293 (synopsis "Clustering algorithm for graphs")
294 (description
295 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
296fast and scalable unsupervised cluster algorithm for graphs (also known as
297networks) based on simulation of (stochastic) flow in graphs.")
298 ;; In the LICENCE file and web page it says "The software is licensed
299 ;; under the GNU General Public License, version 3.", but in several of
300 ;; the source code files it suggests GPL3 or later.
301 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
302 (license license:gpl3)))
303
0a3063d6
BW
304(define-public ocaml-mcl
305 (package
306 (name "ocaml-mcl")
307 (version "12-068oasis4")
308 (source
309 (origin
fb168a31
RW
310 (method git-fetch)
311 (uri (git-reference
312 (url "https://github.com/fhcrc/mcl.git")
313 (commit version)))
314 (file-name (git-file-name name version))
0a3063d6
BW
315 (sha256
316 (base32
fb168a31 317 "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p"))))
0a3063d6
BW
318 (build-system ocaml-build-system)
319 (arguments
b24aaeec 320 `(#:phases
0a3063d6
BW
321 (modify-phases %standard-phases
322 (add-before 'configure 'patch-paths
323 (lambda _
324 (substitute* "configure"
b24aaeec 325 (("/bin/sh") (which "sh")))
0a3063d6
BW
326 (substitute* "setup.ml"
327 (("LDFLAGS=-fPIC")
b24aaeec
RW
328 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh")))
329 (("-std=c89") "-std=gnu99")
330
331 ;; This is a mutable string, which is no longer supported. Use
332 ;; a byte buffer instead.
333 (("String.make \\(String.length s\\)")
334 "Bytes.make (String.length s)")
335
336 ;; These two belong together.
337 (("OASISString.replace_chars")
338 "Bytes.to_string (OASISString.replace_chars")
339 ((" s;")
340 " s);"))
341 (substitute* "myocamlbuild.ml"
342 (("std=c89") "std=gnu99"))
343 ;; Since we build with a more recent OCaml, we have to use C99 or
344 ;; later. This causes problems with the old C code.
345 (substitute* "src/impala/matrix.c"
346 (("restrict") "restrict_"))
0a3063d6 347 #t)))))
b24aaeec
RW
348 (native-inputs
349 `(("ocamlbuild" ,ocamlbuild)))
0a3063d6
BW
350 (home-page "https://github.com/fhcrc/mcl")
351 (synopsis "OCaml wrappers around MCL")
352 (description
353 "This package provides OCaml bindings for the MCL graph clustering
354algorithm.")
355 (license license:gpl3)))
356
0931c609
RW
357(define-public randomjungle
358 (package
359 (name "randomjungle")
360 (version "2.1.0")
361 (source
362 (origin
363 (method url-fetch)
364 (uri (string-append
df4c8434
BH
365 "https://www.imbs.uni-luebeck.de/fileadmin/files/Software"
366 "/randomjungle/randomjungle-" version ".tar_.gz"))
1e92d311 367 (patches (search-patches "randomjungle-disable-static-build.patch"))
0931c609
RW
368 (sha256
369 (base32
370 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
371 (build-system gnu-build-system)
372 (arguments
373 `(#:configure-flags
1e92d311
MB
374 (list "--disable-static"
375 (string-append "--with-boost="
0931c609
RW
376 (assoc-ref %build-inputs "boost")))
377 #:phases
378 (modify-phases %standard-phases
379 (add-before
380 'configure 'set-CXXFLAGS
381 (lambda _
382 (setenv "CXXFLAGS" "-fpermissive ")
383 #t)))))
384 (inputs
385 `(("boost" ,boost)
386 ("gsl" ,gsl)
387 ("libxml2" ,libxml2)
388 ("zlib" ,zlib)))
389 (native-inputs
25e0037a
EF
390 `(("gfortran" ,gfortran)
391 ("gfortran:lib" ,gfortran "lib")))
47818201
RW
392 ;; Non-portable assembly instructions are used so building fails on
393 ;; platforms other than x86_64 or i686.
394 (supported-systems '("x86_64-linux" "i686-linux"))
df4c8434 395 (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224")
0931c609
RW
396 (synopsis "Implementation of the Random Forests machine learning method")
397 (description
398 "Random Jungle is an implementation of Random Forests. It is supposed to
399analyse high dimensional data. In genetics, it can be used for analysing big
400Genome Wide Association (GWA) data. Random Forests is a powerful machine
401learning method. Most interesting features are variable selection, missing
402value imputation, classifier creation, generalization error estimation and
403sample proximities between pairs of cases.")
404 (license license:gpl3+)))
c1670a81 405
7d4cab74
RW
406(define-public openfst
407 (package
408 (name "openfst")
5ed72097 409 (version "1.7.2")
7d4cab74
RW
410 (source (origin
411 (method url-fetch)
412 (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
413 "FstDownload/openfst-" version ".tar.gz"))
414 (sha256
415 (base32
5ed72097 416 "0fqgk8195kz21is09gwzwnrg7fr9526bi9mh4apyskapz27pbhr1"))))
7d4cab74
RW
417 (build-system gnu-build-system)
418 (home-page "http://www.openfst.org")
419 (synopsis "Library for weighted finite-state transducers")
420 (description "OpenFst is a library for constructing, combining,
421optimizing, and searching weighted finite-state transducers (FSTs).")
422 (license license:asl2.0)))
423
c1670a81
RW
424(define-public shogun
425 (package
426 (name "shogun")
5a14e81e 427 (version "6.1.3")
c1670a81
RW
428 (source
429 (origin
430 (method url-fetch)
431 (uri (string-append
432 "ftp://shogun-toolbox.org/shogun/releases/"
433 (version-major+minor version)
434 "/sources/shogun-" version ".tar.bz2"))
435 (sha256
436 (base32
5a14e81e 437 "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp"))
c1670a81
RW
438 (modules '((guix build utils)
439 (ice-9 rdelim)))
440 (snippet
441 '(begin
442 ;; Remove non-free sources and files referencing them
443 (for-each delete-file
444 (find-files "src/shogun/classifier/svm/"
445 "SVMLight\\.(cpp|h)"))
446 (for-each delete-file
447 (find-files "examples/undocumented/libshogun/"
448 (string-append
449 "(classifier_.*svmlight.*|"
450 "evaluation_cross_validation_locked_comparison).cpp")))
451 ;; Remove non-free functions.
452 (define (delete-ifdefs file)
453 (with-atomic-file-replacement file
454 (lambda (in out)
455 (let loop ((line (read-line in 'concat))
456 (skipping? #f))
457 (if (eof-object? line)
458 #t
459 (let ((skip-next?
460 (or (and skipping?
461 (not (string-prefix?
462 "#endif //USE_SVMLIGHT" line)))
463 (string-prefix?
464 "#ifdef USE_SVMLIGHT" line))))
465 (when (or (not skipping?)
466 (and skipping? (not skip-next?)))
467 (display line out))
468 (loop (read-line in 'concat) skip-next?)))))))
5a14e81e
KK
469 (for-each delete-ifdefs
470 (append
471 (find-files "src/shogun/classifier/mkl"
472 "^MKLClassification\\.cpp")
473 (find-files "src/shogun/classifier/svm"
474 "^SVMLightOneClass\\.(cpp|h)")
475 (find-files "src/shogun/multiclass"
476 "^ScatterSVM\\.(cpp|h)")
477 (find-files "src/shogun/kernel/"
478 "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)")
479 (find-files "src/shogun/regression/svr"
480 "^(MKLRegression|SVRLight)\\.(cpp|h)")
481 (find-files "src/shogun/transfer/domain_adaptation"
c0d7c124 482 "^DomainAdaptationSVM\\.(cpp|h)")))
6cbee49d 483 #t))))
c1670a81
RW
484 (build-system cmake-build-system)
485 (arguments
486 '(#:tests? #f ;no check target
487 #:phases
dc1d3cde
KK
488 (modify-phases %standard-phases
489 (add-after 'unpack 'delete-broken-symlinks
490 (lambda _
491 (for-each delete-file '("applications/arts/data"
492 "applications/asp/data"
493 "applications/easysvm/data"
494 "applications/msplicer/data"
495 "applications/ocr/data"
5a14e81e
KK
496 "examples/meta/data"
497 "examples/undocumented/data"))
dc1d3cde
KK
498 #t))
499 (add-after 'unpack 'change-R-target-path
500 (lambda* (#:key outputs #:allow-other-keys)
5a14e81e
KK
501 (substitute* '("src/interfaces/r/CMakeLists.txt"
502 "examples/meta/r/CMakeLists.txt")
dc1d3cde
KK
503 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
504 (string-append (assoc-ref outputs "out")
505 "/lib/R/library/")))
506 #t))
507 (add-after 'unpack 'fix-octave-modules
508 (lambda* (#:key outputs #:allow-other-keys)
5a14e81e 509 (substitute* "src/interfaces/octave/CMakeLists.txt"
dc1d3cde 510 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
5a14e81e
KK
511 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave")
512 ;; change target directory
dc1d3cde
KK
513 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
514 (string-append (assoc-ref outputs "out")
515 "/share/octave/packages")))
5a14e81e
KK
516 (substitute* '("src/interfaces/octave/swig_typemaps.i"
517 "src/interfaces/octave/sg_print_functions.cpp")
518 ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave.
519 (("octave/config\\.h") "octave/octave-config.h")
520 (("octave/oct-obj.h") "octave/ovl.h"))
dc1d3cde 521 #t))
5a14e81e
KK
522 (add-after 'unpack 'move-rxcpp
523 (lambda* (#:key inputs #:allow-other-keys)
524 (let ((rxcpp-dir "shogun/third-party/rxcpp"))
525 (mkdir-p rxcpp-dir)
526 (install-file (assoc-ref inputs "rxcpp") rxcpp-dir)
527 #t)))
dc1d3cde 528 (add-before 'build 'set-HOME
c1670a81 529 ;; $HOME needs to be set at some point during the build phase
dc1d3cde 530 (lambda _ (setenv "HOME" "/tmp") #t)))
c1670a81
RW
531 #:configure-flags
532 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
533 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
5a14e81e
KK
534 "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags
535 ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas
536 ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray
537 ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist
538 ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file
539 "-DINTERFACE_OCTAVE=ON"
540 "-DINTERFACE_PYTHON=ON"
541 "-DINTERFACE_R=ON")))
c1670a81
RW
542 (inputs
543 `(("python" ,python)
544 ("numpy" ,python-numpy)
2d7c4ae3 545 ("r-minimal" ,r-minimal)
5537603f 546 ("octave" ,octave-cli)
c1670a81 547 ("swig" ,swig)
5a14e81e 548 ("eigen" ,eigen)
c1670a81
RW
549 ("hdf5" ,hdf5)
550 ("atlas" ,atlas)
551 ("arpack" ,arpack-ng)
552 ("lapack" ,lapack)
553 ("glpk" ,glpk)
554 ("libxml2" ,libxml2)
555 ("lzo" ,lzo)
556 ("zlib" ,zlib)))
557 (native-inputs
5a14e81e
KK
558 `(("pkg-config" ,pkg-config)
559 ("rxcpp" ,rxcpp)))
6b5b656f
RW
560 ;; Non-portable SSE instructions are used so building fails on platforms
561 ;; other than x86_64.
562 (supported-systems '("x86_64-linux"))
c1670a81
RW
563 (home-page "http://shogun-toolbox.org/")
564 (synopsis "Machine learning toolbox")
565 (description
566 "The Shogun Machine learning toolbox provides a wide range of unified and
567efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
568combine multiple data representations, algorithm classes, and general purpose
569tools. This enables both rapid prototyping of data pipelines and extensibility
570in terms of new algorithms.")
571 (license license:gpl3+)))
8406138b 572
3a354e10
KK
573(define-public rxcpp
574 (package
575 (name "rxcpp")
576 (version "4.0.0")
577 (source
578 (origin
579 (method url-fetch)
580 (uri (string-append "https://github.com/ReactiveX/RxCpp/archive/v"
581 version ".tar.gz"))
582 (sha256
583 (base32
584 "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh"))
585 (file-name (string-append name "-" version ".tar.gz"))))
586 (build-system cmake-build-system)
587 (arguments
588 `(#:phases
589 (modify-phases %standard-phases
590 (add-after 'unpack 'remove-werror
591 (lambda _
592 (substitute* (find-files ".")
593 (("-Werror") ""))
594 #t))
595 (replace 'check
596 (lambda _
597 (invoke "ctest"))))))
598 (native-inputs
599 `(("catch" ,catch-framework)))
600 (home-page "http://reactivex.io/")
601 (synopsis "Reactive Extensions for C++")
602 (description
603 "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for
604values-distributed-in-time. ReactiveX is a library for composing asynchronous
605and event-based programs by using observable sequences.
606
607It extends the observer pattern to support sequences of data and/or events and
608adds operators that allow you to compose sequences together declaratively while
609abstracting away concerns about things like low-level threading,
610synchronization, thread-safety, concurrent data structures, and non-blocking
611I/O.")
612 (license license:asl2.0)))
613
8406138b
RW
614(define-public r-adaptivesparsity
615 (package
616 (name "r-adaptivesparsity")
c0608f81 617 (version "1.6")
8406138b
RW
618 (source (origin
619 (method url-fetch)
620 (uri (cran-uri "AdaptiveSparsity" version))
621 (sha256
622 (base32
c0608f81 623 "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91"))))
8406138b
RW
624 (properties
625 `((upstream-name . "AdaptiveSparsity")))
626 (build-system r-build-system)
627 (arguments
628 `(#:phases
629 (modify-phases %standard-phases
630 (add-after 'unpack 'link-against-armadillo
631 (lambda _
632 (substitute* "src/Makevars"
633 (("PKG_LIBS=" prefix)
634 (string-append prefix "-larmadillo"))))))))
635 (propagated-inputs
c0608f81
RW
636 `(("r-mass" ,r-mass)
637 ("r-matrix" ,r-matrix)
638 ("r-rcpp" ,r-rcpp)
8406138b 639 ("r-rcpparmadillo" ,r-rcpparmadillo)))
60e36bff
LC
640 (inputs
641 `(("armadillo" ,armadillo)))
e9960d8c 642 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
8406138b
RW
643 (synopsis "Adaptive sparsity models")
644 (description
645 "This package implements the Figueiredo machine learning algorithm for
646adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
647geometric models.")
648 (license license:lgpl3+)))
e4785eb8 649
39bb4937
RW
650(define-public gemmlowp-for-tensorflow
651 ;; The commit hash is taken from "tensorflow/workspace.bzl".
652 (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98")
653 (revision "2"))
654 (package
655 (name "gemmlowp")
656 (version (git-version "0" revision commit))
657 (source (origin
658 (method url-fetch)
659 (uri (string-append "https://mirror.bazel.build/"
660 "github.com/google/gemmlowp/archive/"
661 commit ".zip"))
662 (file-name (string-append "gemmlowp-" version ".zip"))
663 (sha256
664 (base32
665 "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq"))))
666 (build-system cmake-build-system)
667 (arguments
668 `(#:configure-flags
669 (list ,@(match (%current-system)
670 ((or "x86_64-linux" "i686-linux")
671 '("-DCMAKE_CXX_FLAGS=-msse4.1"))
672 (_ '())))
673 #:phases
674 (modify-phases %standard-phases
675 ;; This directory contains the CMakeLists.txt.
676 (add-after 'unpack 'chdir
677 (lambda _ (chdir "contrib") #t))
678 ;; There is no install target
679 (replace 'install
680 (lambda* (#:key outputs #:allow-other-keys)
681 (let* ((out (assoc-ref outputs "out"))
682 (lib (string-append out "/lib/"))
683 (inc (string-append out "/include/")))
684 (install-file "../build/libeight_bit_int_gemm.so" lib)
685 (for-each (lambda (dir)
686 (let ((target (string-append inc "/" dir)))
687 (mkdir-p target)
688 (for-each (lambda (h)
689 (install-file h target))
690 (find-files (string-append "../" dir)
691 "\\.h$"))))
692 '("meta" "profiling" "public" "fixedpoint"
693 "eight_bit_int_gemm" "internal"))
694 #t))))))
695 (native-inputs
696 `(("unzip" ,unzip)))
697 (home-page "https://github.com/google/gemmlowp")
698 (synopsis "Small self-contained low-precision GEMM library")
699 (description
700 "This is a small self-contained low-precision @dfn{general matrix
701multiplication} (GEMM) library. It is not a full linear algebra library.
702Low-precision means that the input and output matrix entries are integers on
703at most 8 bits. To avoid overflow, results are internally accumulated on more
704than 8 bits, and at the end only some significant 8 bits are kept.")
705 (license license:asl2.0))))
706
5f0ff6a9
MB
707(define-public dlib
708 (package
709 (name "dlib")
abe97a58 710 (version "19.7")
5f0ff6a9
MB
711 (source (origin
712 (method url-fetch)
713 (uri (string-append
714 "http://dlib.net/files/dlib-" version ".tar.bz2"))
715 (sha256
716 (base32
abe97a58 717 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
5f0ff6a9
MB
718 (modules '((guix build utils)))
719 (snippet
720 '(begin
721 ;; Delete ~13MB of bundled dependencies.
722 (delete-file-recursively "dlib/external")
0ef7ea66
MB
723 (delete-file-recursively "docs/dlib/external")
724 #t))))
5f0ff6a9
MB
725 (build-system cmake-build-system)
726 (arguments
677bc34d 727 `(#:phases
5f0ff6a9
MB
728 (modify-phases %standard-phases
729 (add-after 'unpack 'disable-asserts
730 (lambda _
731 ;; config.h recommends explicitly enabling or disabling asserts
732 ;; when building as a shared library. By default neither is set.
733 (substitute* "dlib/config.h"
734 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
735 #t))
4fba38db
MB
736 (add-after 'disable-asserts 'disable-failing-tests
737 (lambda _
738 ;; One test times out on MIPS, so we need to disable it.
0ef7ea66 739 ;; Others are flaky on some platforms.
4fba38db
MB
740 (let* ((system ,(or (%current-target-system)
741 (%current-system)))
742 (disabled-tests (cond
743 ((string-prefix? "mips64" system)
744 '("object_detector" ; timeout
745 "data_io"))
746 ((string-prefix? "armhf" system)
a343c461 747 '("learning_to_track"))
4fba38db 748 ((string-prefix? "i686" system)
0ef7ea66 749 '("optimization"))
4fba38db 750 (else '()))))
4fba38db
MB
751 (for-each
752 (lambda (test)
753 (substitute* "dlib/test/makefile"
0ef7ea66
MB
754 (((string-append "SRC \\+= " test "\\.cpp")) "")))
755 disabled-tests)
756 #t)))
5f0ff6a9
MB
757 (replace 'check
758 (lambda _
759 ;; No test target, so we build and run the unit tests here.
8eaf53e3 760 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
5f0ff6a9 761 (with-directory-excursion test-dir
8448e6bf
TGR
762 (invoke "make" "-j" (number->string (parallel-job-count)))
763 (invoke "./dtest" "--runall"))
764 #t)))
5f0ff6a9
MB
765 (add-after 'install 'delete-static-library
766 (lambda* (#:key outputs #:allow-other-keys)
0ef7ea66
MB
767 (delete-file (string-append (assoc-ref outputs "out")
768 "/lib/libdlib.a"))
769 #t)))))
5f0ff6a9 770 (native-inputs
3929f46c
TGR
771 `(("pkg-config" ,pkg-config)
772 ;; For tests.
773 ("libnsl" ,libnsl)))
5f0ff6a9 774 (inputs
f40841e9 775 `(("giflib" ,giflib)
4fba38db 776 ("lapack" ,lapack)
5f0ff6a9
MB
777 ("libjpeg" ,libjpeg)
778 ("libpng" ,libpng)
779 ("libx11" ,libx11)
780 ("openblas" ,openblas)
781 ("zlib" ,zlib)))
782 (synopsis
783 "Toolkit for making machine learning and data analysis applications in C++")
784 (description
785 "Dlib is a modern C++ toolkit containing machine learning algorithms and
786tools. It is used in both industry and academia in a wide range of domains
787including robotics, embedded devices, mobile phones, and large high performance
788computing environments.")
789 (home-page "http://dlib.net")
790 (license license:boost1.0)))
be6eb2f1
RW
791
792(define-public python-scikit-learn
793 (package
794 (name "python-scikit-learn")
7ff3f3d2 795 (version "0.20.1")
be6eb2f1
RW
796 (source
797 (origin
4a89bdd1
RW
798 (method git-fetch)
799 (uri (git-reference
800 (url "https://github.com/scikit-learn/scikit-learn.git")
801 (commit version)))
802 (file-name (git-file-name name version))
be6eb2f1
RW
803 (sha256
804 (base32
650bc942 805 "0fkhwg3xn1s7ln9q1szq6kwc4jhwvjh8w4kmv9wcrqy7cq3lbv0d"))))
be6eb2f1
RW
806 (build-system python-build-system)
807 (arguments
808 `(#:phases
809 (modify-phases %standard-phases
4a89bdd1
RW
810 (add-after 'build 'build-ext
811 (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t))
812 (replace 'check
813 (lambda _
814 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
815 (setenv "OPENBLAS_NUM_THREADS" "1")
7ff3f3d2
MB
816
817 ;; Some tests require write access to $HOME.
818 (setenv "HOME" "/tmp")
819
820 (invoke "pytest" "sklearn" "-m" "not network")))
4a89bdd1
RW
821 ;; FIXME: This fails with permission denied
822 (delete 'reset-gzip-timestamps))))
be6eb2f1
RW
823 (inputs
824 `(("openblas" ,openblas)))
825 (native-inputs
4a89bdd1
RW
826 `(("python-pytest" ,python-pytest)
827 ("python-pandas" ,python-pandas) ;for tests
be6eb2f1
RW
828 ("python-cython" ,python-cython)))
829 (propagated-inputs
830 `(("python-numpy" ,python-numpy)
831 ("python-scipy" ,python-scipy)))
832 (home-page "http://scikit-learn.org/")
833 (synopsis "Machine Learning in Python")
834 (description
4a89bdd1
RW
835 "Scikit-learn provides simple and efficient tools for data mining and
836data analysis.")
be6eb2f1
RW
837 (license license:bsd-3)))
838
839(define-public python2-scikit-learn
7ff3f3d2 840 (package-with-python2 python-scikit-learn))
2dab4188
FT
841
842(define-public python-autograd
843 (let* ((commit "442205dfefe407beffb33550846434baa90c4de7")
844 (revision "0")
845 (version (git-version "0.0.0" revision commit)))
846 (package
847 (name "python-autograd")
848 (home-page "https://github.com/HIPS/autograd")
849 (source (origin
850 (method git-fetch)
851 (uri (git-reference
852 (url home-page)
853 (commit commit)))
854 (sha256
855 (base32
856 "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4"))
857 (file-name (git-file-name name version))))
858 (version version)
859 (build-system python-build-system)
860 (native-inputs
861 `(("python-nose" ,python-nose)
862 ("python-pytest" ,python-pytest)))
863 (propagated-inputs
864 `(("python-future" ,python-future)
865 ("python-numpy" ,python-numpy)))
866 (arguments
867 `(#:phases (modify-phases %standard-phases
868 (replace 'check
869 (lambda _
870 (invoke "py.test" "-v"))))))
871 (synopsis "Efficiently computes derivatives of NumPy code")
872 (description "Autograd can automatically differentiate native Python and
873NumPy code. It can handle a large subset of Python's features, including loops,
874ifs, recursion and closures, and it can even take derivatives of derivatives
875of derivatives. It supports reverse-mode differentiation
876(a.k.a. backpropagation), which means it can efficiently take gradients of
877scalar-valued functions with respect to array-valued arguments, as well as
878forward-mode differentiation, and the two can be composed arbitrarily. The
879main intended application of Autograd is gradient-based optimization.")
880 (license license:expat))))
881
882(define-public python2-autograd
883 (package-with-python2 python-autograd))
112c2c01
FT
884
885(define-public lightgbm
886 (package
887 (name "lightgbm")
888 (version "2.0.12")
889 (source (origin
890 (method url-fetch)
891 (uri (string-append
892 "https://github.com/Microsoft/LightGBM/archive/v"
893 version ".tar.gz"))
894 (sha256
895 (base32
896 "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1"))
897 (file-name (string-append name "-" version ".tar.gz"))))
898 (native-inputs
899 `(("python-pytest" ,python-pytest)
900 ("python-nose" ,python-nose)))
901 (inputs
902 `(("openmpi" ,openmpi)))
903 (propagated-inputs
904 `(("python-numpy" ,python-numpy)
905 ("python-scipy" ,python-scipy)))
906 (arguments
907 `(#:configure-flags
908 '("-DUSE_MPI=ON")
909 #:phases
910 (modify-phases %standard-phases
911 (replace 'check
912 (lambda* (#:key outputs #:allow-other-keys)
913 (with-directory-excursion ,(string-append "../LightGBM-" version)
914 (invoke "pytest" "tests/c_api_test/test_.py")))))))
915 (build-system cmake-build-system)
916 (home-page "https://github.com/Microsoft/LightGBM")
917 (synopsis "Gradient boosting framework based on decision tree algorithms")
918 (description "LightGBM is a gradient boosting framework that uses tree
919based learning algorithms. It is designed to be distributed and efficient with
920the following advantages:
921
922@itemize
923@item Faster training speed and higher efficiency
924@item Lower memory usage
925@item Better accuracy
926@item Parallel and GPU learning supported (not enabled in this package)
927@item Capable of handling large-scale data
928@end itemize\n")
929 (license license:expat)))
a8fb82a8
FT
930
931(define-public vowpal-wabbit
932 ;; Language bindings not included.
933 (package
934 (name "vowpal-wabbit")
935 (version "8.5.0")
936 (source (origin
937 (method url-fetch)
938 (uri (string-append
939 "https://github.com/JohnLangford/vowpal_wabbit/archive/"
940 version ".tar.gz"))
941 (sha256
942 (base32
943 "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr"))
944 (file-name (string-append name "-" version ".tar.gz"))))
945 (inputs
946 `(("boost" ,boost)
947 ("zlib" ,zlib)))
948 (arguments
949 `(#:configure-flags
950 (list (string-append "--with-boost="
951 (assoc-ref %build-inputs "boost")))))
952 (build-system gnu-build-system)
953 (home-page "https://github.com/JohnLangford/vowpal_wabbit")
954 (synopsis "Fast machine learning library for online learning")
955 (description "Vowpal Wabbit is a machine learning system with techniques
956such as online, hashing, allreduce, reductions, learning2search, active, and
957interactive learning.")
958 (license license:bsd-3)))
915c6bf6
LC
959
960(define-public python2-fastlmm
961 (package
962 (name "python2-fastlmm")
963 (version "0.2.21")
964 (source
965 (origin
966 (method url-fetch)
967 (uri (pypi-uri "fastlmm" version ".zip"))
968 (sha256
969 (base32
970 "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m"))))
971 (build-system python-build-system)
972 (arguments
237ee6f2
RW
973 `(#:tests? #f ; some test files are missing
974 #:python ,python-2)) ; only Python 2.7 is supported
915c6bf6
LC
975 (propagated-inputs
976 `(("python2-numpy" ,python2-numpy)
977 ("python2-scipy" ,python2-scipy)
978 ("python2-matplotlib" ,python2-matplotlib)
979 ("python2-pandas" ,python2-pandas)
980 ("python2-scikit-learn" ,python2-scikit-learn)
981 ("python2-pysnptools" ,python2-pysnptools)))
982 (native-inputs
983 `(("unzip" ,unzip)
984 ("python2-cython" ,python2-cython)
985 ("python2-mock" ,python2-mock)
986 ("python2-nose" ,python2-nose)))
987 (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/")
988 (synopsis "Perform genome-wide association studies on large data sets")
989 (description
990 "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed
991Models, is a program for performing both single-SNP and SNP-set genome-wide
992association studies (GWAS) on extremely large data sets.")
993 (license license:asl2.0)))
b9445d0b
RW
994
995;; There have been no proper releases yet.
996(define-public kaldi
997 (let ((commit "2f95609f0bb085bd3a1dc5eb0a39f3edea59e606")
998 (revision "1"))
999 (package
1000 (name "kaldi")
1001 (version (git-version "0" revision commit))
1002 (source (origin
1003 (method git-fetch)
1004 (uri (git-reference
1005 (url "https://github.com/kaldi-asr/kaldi.git")
1006 (commit commit)))
1007 (file-name (git-file-name name version))
1008 (sha256
1009 (base32
1010 "082qh3pfi7hvncylp4xsmkfahbd7gb0whdfa4rwrx7fxk9rdh3kz"))))
1011 (build-system gnu-build-system)
1012 (arguments
1013 `(#:test-target "test"
1014 #:phases
1015 (modify-phases %standard-phases
1016 (add-after 'unpack 'chdir
1017 (lambda _ (chdir "src") #t))
1018 (replace 'configure
1019 (lambda* (#:key build system inputs outputs #:allow-other-keys)
1020 (when (not (or (string-prefix? "x86_64" system)
1021 (string-prefix? "i686" system)))
1022 (substitute* "makefiles/linux_openblas.mk"
1023 (("-msse -msse2") "")))
1024 (substitute* "makefiles/default_rules.mk"
1025 (("/bin/bash") (which "bash")))
1026 (substitute* "Makefile"
1027 (("ext_depend: check_portaudio")
1028 "ext_depend:"))
1029 (substitute* '("online/Makefile"
1030 "onlinebin/Makefile"
1031 "gst-plugin/Makefile")
1032 (("../../tools/portaudio/install")
1033 (assoc-ref inputs "portaudio")))
1034
1035 ;; This `configure' script doesn't support variables passed as
1036 ;; arguments, nor does it support "prefix".
1037 (let ((out (assoc-ref outputs "out"))
1038 (openblas (assoc-ref inputs "openblas"))
1039 (openfst (assoc-ref inputs "openfst")))
1040 (substitute* "configure"
1041 (("check_for_slow_expf;") "")
1042 ;; This affects the RPATH and also serves as the installation
1043 ;; directory.
1044 (("KALDILIBDIR=`pwd`/lib")
1045 (string-append "KALDILIBDIR=" out "/lib")))
1046 (mkdir-p out) ; must exist
1047 (setenv "CONFIG_SHELL" (which "bash"))
1048 (setenv "OPENFST_VER" ,(package-version openfst))
1049 (invoke "./configure"
1050 "--use-cuda=no"
1051 "--shared"
1052 (string-append "--openblas-root=" openblas)
1053 (string-append "--fst-root=" openfst)))))
1054 (add-after 'build 'build-ext-and-gstreamer-plugin
1055 (lambda _
1056 (invoke "make" "-C" "online" "depend")
1057 (invoke "make" "-C" "online")
1058 (invoke "make" "-C" "onlinebin" "depend")
1059 (invoke "make" "-C" "onlinebin")
1060 (invoke "make" "-C" "gst-plugin" "depend")
1061 (invoke "make" "-C" "gst-plugin")
1062 #t))
1063 ;; TODO: also install the executables.
1064 (replace 'install
1065 (lambda* (#:key outputs #:allow-other-keys)
1066 (let* ((out (assoc-ref outputs "out"))
1fdd20c7 1067 (inc (string-append out "/include"))
b9445d0b
RW
1068 (lib (string-append out "/lib")))
1069 (mkdir-p lib)
1fdd20c7
RW
1070 ;; The build phase installed symlinks to the actual
1071 ;; libraries. Install the actual targets.
1072 (for-each (lambda (file)
1073 (let ((target (readlink file)))
1074 (delete-file file)
1075 (install-file target lib)))
1076 (find-files lib "\\.so"))
1077 ;; Install headers
1078 (for-each (lambda (file)
1079 (let ((target-dir (string-append inc "/" (dirname file))))
1080 (install-file file target-dir)))
1081 (find-files "." "\\.h"))
1082 (install-file "gst-plugin/libgstonlinegmmdecodefaster.so"
1083 (string-append lib "/gstreamer-1.0"))
b9445d0b
RW
1084 #t))))))
1085 (inputs
1086 `(("alsa-lib" ,alsa-lib)
1087 ("gfortran" ,gfortran "lib")
1088 ("glib" ,glib)
1089 ("gstreamer" ,gstreamer)
1090 ("jack" ,jack-1)
1091 ("openblas" ,openblas)
1092 ("openfst" ,openfst)
1093 ("portaudio" ,portaudio)
1094 ("python" ,python)))
1095 (native-inputs
1096 `(("glib" ,glib "bin") ; glib-genmarshal
1097 ("grep" ,grep)
1098 ("sed" ,sed)
1099 ("pkg-config" ,pkg-config)
1100 ("which" ,which)))
1101 (home-page "https://kaldi-asr.org/")
1102 (synopsis "Speech recognition toolkit")
1103 (description "Kaldi is an extensible toolkit for speech recognition
1104written in C++.")
1105 (license license:asl2.0))))
99260014
RW
1106
1107(define-public gst-kaldi-nnet2-online
1108 (let ((commit "617e43e73c7cc45eb9119028c02bd4178f738c4a")
1109 (revision "1"))
1110 (package
1111 (name "gst-kaldi-nnet2-online")
1112 (version (git-version "0" revision commit))
1113 (source (origin
1114 (method git-fetch)
1115 (uri (git-reference
1116 (url "https://github.com/alumae/gst-kaldi-nnet2-online.git")
1117 (commit commit)))
1118 (file-name (git-file-name name version))
1119 (sha256
1120 (base32
1121 "0xh3w67b69818s6ib02ara4lw7wamjdmh4jznvkpzrs4skbs9jx9"))))
1122 (build-system gnu-build-system)
1123 (arguments
1124 `(#:tests? #f ; there are none
1125 #:make-flags
1126 (list (string-append "SHELL="
1127 (assoc-ref %build-inputs "bash") "/bin/bash")
1128 (string-append "KALDI_ROOT="
1129 (assoc-ref %build-inputs "kaldi-src"))
1130 (string-append "KALDILIBDIR="
1131 (assoc-ref %build-inputs "kaldi") "/lib")
1132 "KALDI_FLAVOR=dynamic")
1133 #:phases
1134 (modify-phases %standard-phases
1135 (add-after 'unpack 'chdir
1136 (lambda _ (chdir "src") #t))
1137 (replace 'configure
1138 (lambda* (#:key inputs #:allow-other-keys)
1139 (let ((glib (assoc-ref inputs "glib")))
1140 (setenv "CXXFLAGS" "-std=c++11 -fPIC")
1141 (setenv "CPLUS_INCLUDE_PATH"
1142 (string-append glib "/include/glib-2.0:"
1143 glib "/lib/glib-2.0/include:"
1144 (assoc-ref inputs "gstreamer")
1145 "/include/gstreamer-1.0:"
1146 (getenv "CPLUS_INCLUDE_PATH"))))
1147 (substitute* "Makefile"
1148 (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "")
1149 (("\\$\\(error Cannot find") "#"))))
1150 (add-before 'build 'build-depend
1151 (lambda* (#:key make-flags #:allow-other-keys)
1152 (apply invoke "make" "depend" make-flags)))
1153 (replace 'install
1154 (lambda* (#:key outputs #:allow-other-keys)
1155 (let* ((out (assoc-ref outputs "out"))
1156 (lib (string-append out "/lib/gstreamer-1.0")))
1157 (install-file "libgstkaldinnet2onlinedecoder.so" lib)
1158 #t))))))
1159 (inputs
1160 `(("glib" ,glib)
1161 ("gstreamer" ,gstreamer)
1162 ("jansson" ,jansson)
1163 ("openfst" ,openfst)
1164 ("kaldi" ,kaldi)))
1165 (native-inputs
1166 `(("bash" ,bash)
1167 ("glib:bin" ,glib "bin") ; glib-genmarshal
1168 ("kaldi-src" ,(package-source kaldi))
1169 ("pkg-config" ,pkg-config)))
1170 (home-page "https://kaldi-asr.org/")
1171 (synopsis "Gstreamer plugin for decoding speech")
1172 (description "This package provides a GStreamer plugin that wraps
1173Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN
1174acoustic models. The iVectors are adapted to the current audio stream
1175automatically.")
1176 (license license:asl2.0))))
10451f6b
RW
1177
1178(define-public kaldi-gstreamer-server
1179 (let ((commit "1735ba49c5dc0ebfc184e45105fc600cd9f1f508")
1180 (revision "1"))
1181 (package
1182 (name "kaldi-gstreamer-server")
1183 (version (git-version "0" revision commit))
1184 (source (origin
1185 (method git-fetch)
1186 (uri (git-reference
1187 (url "https://github.com/alumae/kaldi-gstreamer-server.git")
1188 (commit commit)))
1189 (file-name (git-file-name name version))
1190 (sha256
1191 (base32
1192 "0j701m7lbwmzqxsfanj882v7881hrbmpqybbczbxqpcbg8q34w0k"))))
1193 (build-system gnu-build-system)
1194 (arguments
1195 `(#:tests? #f ; there are no tests that can be run automatically
1196 #:modules ((guix build utils)
1197 (guix build gnu-build-system)
1198 (srfi srfi-26))
1199 #:phases
1200 (modify-phases %standard-phases
1201 (delete 'configure)
1202 (replace 'build
1203 (lambda* (#:key outputs #:allow-other-keys)
1204 ;; Disable hash randomization to ensure the generated .pycs
1205 ;; are reproducible.
1206 (setenv "PYTHONHASHSEED" "0")
1207 (with-directory-excursion "kaldigstserver"
1208 (for-each (lambda (file)
1209 (apply invoke
1210 `("python"
1211 "-m" "compileall"
1212 "-f" ; force rebuild
1213 ,file)))
1214 (find-files "." "\\.py$")))
1215 #t))
1216 (replace 'install
1217 (lambda* (#:key inputs outputs #:allow-other-keys)
1218 (let* ((out (assoc-ref outputs "out"))
1219 (bin (string-append out "/bin"))
1220 (share (string-append out "/share/kaldi-gstreamer-server/")))
1221 ;; Install Python files
1222 (with-directory-excursion "kaldigstserver"
1223 (for-each (cut install-file <> share)
1224 (find-files "." ".*")))
1225
1226 ;; Install sample configuration files
1227 (for-each (cut install-file <> share)
1228 (find-files "." "\\.yaml"))
1229
1230 ;; Install executables
1231 (mkdir-p bin)
1232 (let* ((server (string-append bin "/kaldi-gst-server"))
1233 (client (string-append bin "/kaldi-gst-client"))
1234 (worker (string-append bin "/kaldi-gst-worker"))
1235 (PYTHONPATH (getenv "PYTHONPATH"))
1236 (GST_PLUGIN_PATH (string-append
1237 (assoc-ref inputs "gst-kaldi-nnet2-online")
1238 "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}"))
1239 (wrap (lambda (wrapper what)
1240 (with-output-to-file wrapper
1241 (lambda _
1242 (format #t
1243 "#!~a
1244export PYTHONPATH=~a
1245export GST_PLUGIN_PATH=~a
1246exec ~a ~a/~a \"$@\"~%"
1247 (which "bash") PYTHONPATH GST_PLUGIN_PATH
1248 (which "python") share what)))
1249 (chmod wrapper #o555))))
1250 (for-each wrap
1251 (list server client worker)
1252 (list "master_server.py"
1253 "client.py"
1254 "worker.py")))
1255 #t))))))
1256 (inputs
1257 `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online)
1258 ("python2" ,python-2)
1259 ("python2-futures" ,python2-futures)
1260 ("python2-pygobject" ,python2-pygobject)
1261 ("python2-pyyaml" ,python2-pyyaml)
1262 ("python2-tornado" ,python2-tornado)
1263 ("python2-ws4py" ,python2-ws4py-for-kaldi-gstreamer-server)))
1264 (home-page "https://github.com/alumae/kaldi-gstreamer-server")
1265 (synopsis "Real-time full-duplex speech recognition server")
1266 (description "This is a real-time full-duplex speech recognition server,
1267based on the Kaldi toolkit and the GStreamer framework and implemented in
1268Python.")
1269 (license license:bsd-2))))
0dfeb285
RW
1270
1271(define-public grpc
1272 (package
1273 (name "grpc")
1274 (version "1.16.1")
1275 (source (origin
1276 (method git-fetch)
1277 (uri (git-reference
1278 (url "https://github.com/grpc/grpc.git")
1279 (commit (string-append "v" version))))
1280 (file-name (git-file-name name version))
1281 (sha256
1282 (base32
1283 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
1284 (build-system cmake-build-system)
1285 (arguments
1286 `(#:tests? #f ; no test target
1287 #:configure-flags
1288 (list "-DgRPC_ZLIB_PROVIDER=package"
1289 "-DgRPC_CARES_PROVIDER=package"
1290 "-DgRPC_SSL_PROVIDER=package"
1291 "-DgRPC_PROTOBUF_PROVIDER=package")))
1292 (inputs
1293 `(("c-ares" ,c-ares-next)
1294 ("openssl" ,openssl)
1295 ("zlib" ,zlib)))
1296 (native-inputs
1297 `(("protobuf" ,protobuf-next)
1298 ("python" ,python-wrapper)))
1299 (home-page "https://grpc.io")
1300 (synopsis "High performance universal RPC framework")
1301 (description "gRPC is a modern open source high performance @dfn{Remote
1302Procedure Call} (RPC) framework that can run in any environment. It can
1303efficiently connect services in and across data centers with pluggable support
1304for load balancing, tracing, health checking and authentication. It is also
1305applicable in last mile of distributed computing to connect devices, mobile
1306applications and browsers to backend services.")
1307 (license license:asl2.0)))
4fa16c9a
RW
1308
1309;; Note that Tensorflow includes a "third_party" directory, which seems to not
1310;; only contain modified subsets of upstream library source code, but also
1311;; adapter headers provided by Google (such as the fft.h header, which is not
1312;; part of the upstream project code). The Tensorflow code includes headers
1313;; from the "third_party" directory. It does not look like we can replace
1314;; these headers with unmodified upstream files, so we keep them.
1315(define-public tensorflow
1316 (package
1317 (name "tensorflow")
1318 (version "1.9.0")
1319 (source
1320 (origin
1321 (method git-fetch)
1322 (uri (git-reference
1323 (url "https://github.com/tensorflow/tensorflow.git")
1324 (commit (string-append "v" version))))
1325 (file-name (string-append "tensorflow-" version "-checkout"))
1326 (sha256
1327 (base32
1328 "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa"))))
1329 (build-system cmake-build-system)
1330 (arguments
1331 `(#:tests? #f ; no "check" target
1332 #:build-type "Release"
1333 #:configure-flags
1334 (let ((protobuf (assoc-ref %build-inputs "protobuf"))
1335 (protobuf:native (assoc-ref %build-inputs "protobuf:native"))
1336 (jsoncpp (assoc-ref %build-inputs "jsoncpp"))
1337 (snappy (assoc-ref %build-inputs "snappy"))
1338 (sqlite (assoc-ref %build-inputs "sqlite")))
1339 (list
1340 ;; Use protobuf from Guix
1341 (string-append "-Dprotobuf_STATIC_LIBRARIES="
1342 protobuf "/lib/libprotobuf.so")
1343 (string-append "-DPROTOBUF_PROTOC_EXECUTABLE="
1344 protobuf:native "/bin/protoc")
1345
1346 ;; Use snappy from Guix
1347 (string-append "-Dsnappy_STATIC_LIBRARIES="
1348 snappy "/lib/libsnappy.so")
1349 ;; Yes, this is not actually the include directory but a prefix...
1350 (string-append "-Dsnappy_INCLUDE_DIR=" snappy)
1351
1352 ;; Use jsoncpp from Guix
1353 (string-append "-Djsoncpp_STATIC_LIBRARIES="
1354 jsoncpp "/lib/libjsoncpp.so")
1355 ;; Yes, this is not actually the include directory but a prefix...
1356 (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp)
1357
1358 ;; Use sqlite from Guix
1359 (string-append "-Dsqlite_STATIC_LIBRARIES="
1360 sqlite "/lib/libsqlite.a")
1361
1362 ;; Use system libraries wherever possible. Currently, this
1363 ;; only affects zlib.
1364 "-Dsystemlib_ALL=ON"
1365 "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON"
1366 "-Dtensorflow_BUILD_SHARED_LIB=ON"
1367 "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF"
1368 "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF"
1369 "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF"))
1370 #:make-flags
1371 (list "CC=gcc")
1372 #:modules ((ice-9 ftw)
1373 (guix build utils)
1374 (guix build cmake-build-system))
1375 #:phases
1376 (modify-phases %standard-phases
1377 (add-after 'unpack 'set-source-file-times-to-1980
1378 ;; At the end of the tf_python_build_pip_package target, a ZIP
1379 ;; archive should be generated via bdist_wheel, but it fails with
1380 ;; "ZIP does not support timestamps before 1980". Luckily,
1381 ;; SOURCE_DATE_EPOCH is respected, which we set to some time in
1382 ;; 1980.
1383 (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t))
1384 ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913
1385 (add-after 'unpack 'python3.7-compatibility
1386 (lambda _
1387 (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc"
1388 "tensorflow/python/lib/core/ndarray_tensor.cc"
1389 "tensorflow/python/lib/core/py_func.cc")
1390 (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8"))
1391 (substitute* "tensorflow/c/eager/c_api.h"
1392 (("unsigned char async")
1393 "unsigned char is_async"))
1394
1395 ;; Remove dependency on tensorboard, a complicated but probably
1396 ;; optional package.
1397 (substitute* "tensorflow/tools/pip_package/setup.py"
1398 ((".*'tensorboard >.*") ""))
1399 #t))
1400 (add-after 'python3.7-compatibility 'chdir
1401 (lambda _ (chdir "tensorflow/contrib/cmake") #t))
1402 (add-after 'chdir 'disable-downloads
1403 (lambda* (#:key inputs #:allow-other-keys)
1404 (substitute* (find-files "external" "\\.cmake$")
1405 (("GIT_REPOSITORY.*") "")
1406 (("GIT_TAG.*") "")
1407 (("PREFIX ")
1408 "DOWNLOAD_COMMAND \"\"\nPREFIX "))
1409
1410 ;; Use packages from Guix
1411 (let ((grpc (assoc-ref inputs "grpc")))
1412 (substitute* "CMakeLists.txt"
1413 ;; Sqlite
1414 (("include\\(sqlite\\)") "")
1415 (("\\$\\{sqlite_STATIC_LIBRARIES\\}")
1416 (string-append (assoc-ref inputs "sqlite")
1417 "/lib/libsqlite3.so"))
1418 (("sqlite_copy_headers_to_destination") "")
1419
1420 ;; PNG
1421 (("include\\(png\\)") "")
1422 (("\\$\\{png_STATIC_LIBRARIES\\}")
1423 (string-append (assoc-ref inputs "libpng")
1424 "/lib/libpng16.so"))
1425 (("png_copy_headers_to_destination") "")
1426
1427 ;; JPEG
1428 (("include\\(jpeg\\)") "")
1429 (("\\$\\{jpeg_STATIC_LIBRARIES\\}")
1430 (string-append (assoc-ref inputs "libjpeg")
1431 "/lib/libjpeg.so"))
1432 (("jpeg_copy_headers_to_destination") "")
1433
1434 ;; GIF
1435 (("include\\(gif\\)") "")
1436 (("\\$\\{gif_STATIC_LIBRARIES\\}")
1437 (string-append (assoc-ref inputs "giflib")
1438 "/lib/libgif.so"))
1439 (("gif_copy_headers_to_destination") "")
1440
1441 ;; lmdb
1442 (("include\\(lmdb\\)") "")
1443 (("\\$\\{lmdb_STATIC_LIBRARIES\\}")
1444 (string-append (assoc-ref inputs "lmdb")
1445 "/lib/liblmdb.so"))
1446 (("lmdb_copy_headers_to_destination") "")
1447
1448 ;; Protobuf
1449 (("include\\(protobuf\\)") "")
1450 (("protobuf_copy_headers_to_destination") "")
1451 (("^ +protobuf") "")
1452
1453 ;; gRPC
1454 (("include\\(grpc\\)")
1455 "find_package(grpc REQUIRED NAMES gRPC)")
1456 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "")
1457
1458 ;; Eigen
1459 (("include\\(eigen\\)")
1460 (string-append "find_package(eigen REQUIRED NAMES Eigen3)
1461set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive "
1462 (assoc-ref inputs "eigen") "/include/eigen3)"))
1463 (("^ +eigen") "")
1464
1465 ;; snappy
1466 (("include\\(snappy\\)")
1467 "add_definitions(-DTF_USE_SNAPPY)")
1468 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "")
1469
1470 ;; jsoncpp
1471 (("include\\(jsoncpp\\)") "")
1472 (("^ +jsoncpp") ""))
1473
1474 (substitute* "tf_core_framework.cmake"
1475 ((" grpc") "")
1476 (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin")
1477 (which "grpc_cpp_plugin"))
1478 ;; Link with gRPC libraries
1479 (("add_library\\(tf_protos_cc.*" m)
1480 (string-append m
1481 (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \
1482~a/lib/libgrpc++_unsecure.a \
1483~a/lib/libgrpc_unsecure.a \
1484~a/lib/libaddress_sorting.a \
1485~a/lib/libgpr.a \
1486~a//lib/libcares.so
1487)\n"
1488 grpc grpc grpc grpc
1489 (assoc-ref inputs "c-ares"))))))
1490 (substitute* "tf_tools.cmake"
1491 (("add_dependencies\\(\\$\\{proto_text.*") ""))
1492 ;; Remove dependency on bundled grpc
1493 (substitute* "tf_core_distributed_runtime.cmake"
1494 (("tf_core_cpu grpc") "tf_core_cpu"))
1495
1496 ;; This directory is a dependency of many targets.
1497 (mkdir-p "protobuf")
1498 #t))
1499 (add-after 'configure 'unpack-third-party-sources
1500 (lambda* (#:key inputs #:allow-other-keys)
1501 ;; This is needed to configure bundled packages properly.
1502 (setenv "CONFIG_SHELL" (which "bash"))
1503 (for-each
1504 (lambda (name)
1505 (let* ((what (assoc-ref inputs (string-append name "-src")))
1506 (name* (string-map (lambda (c)
1507 (if (char=? c #\-)
1508 #\_ c)) name))
1509 (where (string-append "../build/" name* "/src/" name*)))
1510 (cond
1511 ((string-suffix? ".zip" what)
1512 (mkdir-p where)
1513 (with-directory-excursion where
1514 (invoke "unzip" what)))
1515 ((string-suffix? ".tar.gz" what)
1516 (mkdir-p where)
1517 (invoke "tar" "xf" what
1518 "-C" where "--strip-components=1"))
1519 (else
1520 (let ((parent (dirname where)))
1521 (mkdir-p parent)
1522 (with-directory-excursion parent
1523 (when (file-exists? name*)
1524 (delete-file-recursively name*))
1525 (copy-recursively what name*)
1526 (map make-file-writable
1527 (find-files name* ".*"))))))))
1528 (list "boringssl"
1529 "cub"
1530 "double-conversion"
1531 "farmhash"
1532 "fft2d"
1533 "highwayhash"
1534 "nsync"
1535 "re2"))
1536
1537 (rename-file "../build/cub/src/cub/cub-1.8.0/"
1538 "../build/cub/src/cub/cub/")
1539 #t))
1540 (add-after 'unpack 'fix-python-build
1541 (lambda* (#:key inputs outputs #:allow-other-keys)
1542 (mkdir-p "protobuf-src")
1543 (invoke "tar" "xf" (assoc-ref inputs "protobuf:src")
1544 "-C" "protobuf-src" "--strip-components=1")
1545 (mkdir-p "eigen-src")
1546 (invoke "tar" "xf" (assoc-ref inputs "eigen:src")
1547 "-C" "eigen-src" "--strip-components=1")
1548
1549 (substitute* "tensorflow/contrib/cmake/tf_python.cmake"
1550 ;; Ensure that all Python dependencies can be found at build time.
1551 (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m)
1552 (string-append m ":" (getenv "PYTHONPATH")))
1553 ;; Take protobuf source files from our source package.
1554 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google")
1555 (string-append (getcwd) "/protobuf-src/src/google")))
1556
1557 (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake"
1558 "tensorflow/contrib/cmake/tf_python.cmake")
1559 ;; Take Eigen source files from our source package.
1560 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/")
1561 (string-append (getcwd) "/eigen-src/"))
1562 ;; Take Eigen headers from our own package.
1563 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive")
1564 (string-append (assoc-ref inputs "eigen") "/include/eigen3")))
1565
1566 ;; Correct the RUNPATH of ops libraries generated for Python.
1567 ;; TODO: this doesn't work :(
1568 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1569 ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build")
1570 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1571 ;; error: depends on 'libpywrap_tensorflow_internal.so', which
1572 ;; cannot be found in RUNPATH ...
1573 (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake"
1574 (("set_target_properties.*")
1575 (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \
1576COMPILE_FLAGS ${target_compile_flags} \
1577INSTALL_RPATH_USE_LINK_PATH TRUE \
1578INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n")))
1579 #t))
1580 (add-after 'build 'build-pip-package
1581 (lambda* (#:key outputs #:allow-other-keys)
1582 (setenv "LDFLAGS"
1583 (string-append "-Wl,-rpath="
1584 (assoc-ref outputs "out") "/lib"))
1585 (invoke "make" "tf_python_build_pip_package")
1586 #t))
1587 (add-after 'build-pip-package 'install-python
1588 (lambda* (#:key outputs #:allow-other-keys)
1589 (let ((out (assoc-ref outputs "out"))
1590 (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))))
1591 (invoke "python" "-m" "pip" "install" wheel
1592 (string-append "--prefix=" out))
1593
1594 ;; XXX: broken RUNPATH, see fix-python-build phase.
1595 (delete-file
1596 (string-append
1597 out "/lib/python3.7/site-packages/tensorflow/contrib/"
1598 "seq2seq/python/ops/lib_beam_search_ops.so"))
1599 #t))))))
1600 (native-inputs
1601 `(("pkg-config" ,pkg-config)
1602 ("protobuf:native" ,protobuf-next) ; protoc
1603 ("protobuf:src" ,(package-source protobuf-next))
1604 ("eigen:src" ,(package-source eigen-for-tensorflow))
1605 ;; The commit hashes and URLs for third-party source code are taken
1606 ;; from "tensorflow/workspace.bzl".
1607 ("boringssl-src"
1608 ,(let ((commit "ee7aa02")
1609 (revision "1"))
1610 (origin
1611 (method git-fetch)
1612 (uri (git-reference
1613 (url "https://boringssl.googlesource.com/boringssl")
1614 (commit commit)))
1615 (file-name (string-append "boringssl-0-" revision
1616 (string-take commit 7)
1617 "-checkout"))
1618 (sha256
1619 (base32
1620 "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw")))))
1621 ("cub-src"
1622 ,(let ((version "1.8.0"))
1623 (origin
1624 (method url-fetch)
1625 (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/"
1626 "cub/archive/" version ".zip"))
1627 (file-name (string-append "cub-" version ".zip"))
1628 (sha256
1629 (base32
1630 "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb")))))
1631 ("double-conversion-src"
1632 ,(let ((commit "5664746")
1633 (revision "1"))
1634 (origin
1635 (method git-fetch)
1636 (uri (git-reference
1637 (url "https://github.com/google/double-conversion.git")
1638 (commit commit)))
1639 (file-name
1640 (git-file-name "double-conversion"
1641 (string-append "0-" revision "."
1642 (string-take commit 7))))
1643 (sha256
1644 (base32
1645 "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1")))))
1646 ("farmhash-src"
1647 ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
1648 (origin
1649 (method url-fetch)
1650 (uri (string-append
1651 "https://mirror.bazel.build/github.com/google/farmhash/archive/"
1652 commit ".tar.gz"))
1653 (file-name (string-append "farmhash-0-" (string-take commit 7)
1654 ".tar.gz"))
1655 (sha256
1656 (base32
1657 "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35")))))
1658 ;; The license notice on the home page at
1659 ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says:
1660 ;; Copyright Takuya OOURA, 1996-2001
1661 ;;
1662 ;; You may use, copy, modify and distribute this code for any purpose
1663 ;; (include commercial use) and without fee. Please refer to this
1664 ;; package when you modify this code.
1665 ;;
1666 ;; We take the identical tarball from the Bazel mirror, because the URL
1667 ;; at the home page is not versioned and might change.
1668 ("fft2d-src"
1669 ,(origin
1670 (method url-fetch)
1671 (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz")
1672 (file-name "fft2d.tar.gz")
1673 (sha256
1674 (base32
1675 "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj"))))
1676 ("highwayhash-src"
1677 ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee")
1678 (revision "1"))
1679 (origin
1680 (method git-fetch)
1681 (uri (git-reference
1682 (url "https://github.com/google/highwayhash.git")
1683 (commit commit)))
1684 (file-name (string-append "highwayhash-0-" revision
1685 (string-take commit 7)
1686 "-checkout"))
1687 (sha256
1688 (base32
1689 "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6")))))
1690 ("nsync-src"
1691 ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777")
1692 (revision "1"))
1693 (origin
1694 (method url-fetch)
1695 (uri (string-append "https://mirror.bazel.build/"
1696 "github.com/google/nsync/archive/"
1697 version ".tar.gz"))
1698 (file-name (string-append "nsync-0." revision
1699 "-" (string-take version 7)
1700 ".tar.gz"))
1701 (sha256
1702 (base32
1703 "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132")))))
1704 ("re2-src"
1705 ,(let ((commit "e7efc48")
1706 (revision "1"))
1707 (origin
1708 (method git-fetch)
1709 (uri (git-reference
1710 (url "https://github.com/google/re2")
1711 (commit commit)))
1712 (file-name (string-append "re2-0-" revision
1713 (string-take commit 7)
1714 "-checkout"))
1715 (sha256
1716 (base32
1717 "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign")))))
1718 ("googletest" ,googletest)
1719 ("swig" ,swig)
1720 ("unzip" ,unzip)))
1721 (propagated-inputs
1722 `(("python-absl-py" ,python-absl-py)
1723 ("python-astor" ,python-astor)
1724 ("python-gast" ,python-gast)
1725 ("python-grpcio" ,python-grpcio)
1726 ("python-numpy" ,python-numpy)
1727 ("python-protobuf" ,python-protobuf-next)
1728 ("python-six" ,python-six)
1729 ("python-termcolo" ,python-termcolor)
1730 ("python-wheel" ,python-wheel)))
1731 (inputs
1732 `(("c-ares" ,c-ares-next)
1733 ("eigen" ,eigen-for-tensorflow)
1734 ("gemmlowp" ,gemmlowp-for-tensorflow)
1735 ("lmdb" ,lmdb)
1736 ("libjpeg" ,libjpeg)
1737 ("libpng" ,libpng)
1738 ("giflib" ,giflib)
1739 ("grpc" ,grpc)
1740 ("jsoncpp" ,jsoncpp-for-tensorflow)
1741 ("snappy" ,snappy)
1742 ("sqlite" ,sqlite)
1743 ("protobuf" ,protobuf-next)
1744 ("python" ,python-wrapper)
1745 ("zlib" ,zlib)))
1746 (home-page "https://tensorflow.org")
1747 (synopsis "Machine learning framework")
1748 (description
1749 "TensorFlow is a flexible platform for building and training machine
1750learning models. It provides a library for high performance numerical
1751computation and includes high level Python APIs, including both a sequential
1752API for beginners that allows users to build models quickly by plugging
1753together building blocks and a subclassing API with an imperative style for
1754advanced research.")
1755 (license license:asl2.0)))