-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathindex.html
More file actions
1224 lines (1157 loc) · 55 KB
/
Copy pathindex.html
File metadata and controls
1224 lines (1157 loc) · 55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>reveal.js</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<link rel="stylesheet" href="genericons.css">
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<style>
.reveal section img {
border: none;
background-color: initial;
margin: 10px;
}
.reveal .normal-paragraph {
text-align: left;
margin: 0 auto 0 auto;
width: 60%;
}
.reveal .normal-paragraph p {
text-align: left;
}
.header-left {
position: absolute;
top: 2%;
left: 2%;
}
.header-right {
position: absolute;
top: 2%;
right: 2%;
}
.footer-left {
position: absolute;
bottom: 2%;
left: 2%;
}
.reveal .genericon {
font-family: "genericons";
}
.reveal .bio-card {
background: #333;
border-radius: 2px;
display: inline-block;
width: 260px;
margin: 1rem;
position: relative;
font-size: 20px;
}
.reveal .card-photo {
display: block;
width: 200px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
margin: 28px auto 0 auto;
}
.reveal .card-header {
width: 100%;
font-size: 20px;
margin-top: 10px;
text-align: center;
}
.reveal .card-info {
width: 100%;
float: left;
font-size: 20px;
margin-top: 0;
padding: 0 4px;
text-align: center;
}
.reveal .card-info a {
text-decoration: none;
color: #999;
}
.reveal .card-info em {
vertical-align: top;
}
.revral .card-info a .genericon {
vertical-align: middle;
}
.reveal .bio-social a {
text-decoration: none;
}
.reveal .bio-photo {
width: 200px;
margin: 0 40px 40px -40px;
float: left;
}
.reveal section img {
box-shadow: none;
}
</style>
</head>
<body>
<div id="common" style="z-index: 2;">
<div class="header-left">
<img alt="QuantStack" src="quantstack-white.svg" width="30%"/>
</div>
<div class="footer-left">
<div style="color: white; font-family: Source Sans Pro, Helvetica, sans-serif;">
<img alt="Twitter" src="twitter-white.svg" height="20px"/>
<img alt="GitHub" src="github-white.svg" height="20px"/>
<p style="display: inline; vertical-align: top; margin-left: 4px; font-size: 20px;">@QuantStack</p>
</div>
</div>
</div>
<div class="reveal">
<div class="slides">
<section>
<img alt="QuantStack" src="quantstack-white.svg" width="55%">
<p>Going native: C++ as a first-class citizen of the Jupyter ecosystem</p>
</section>
<section>
<p>The team</p>
<div class="team-section-content">
<div class="bio-card">
<img class="card-photo" alt="Avatar picture" src="Sylvain.jpg">
<p class="card-header">Sylvain Corlay</p>
<div class="card-info">
<a href="https://github.com/SylvainCorlay" target="_blank">
<span class="genericon genericon-github"></span>
<em>@SylvainCorlay</em>
</a>
</div>
<div class="card-info">
<a href="https://twitter.com/SylvainCorlay" target="_blank">
<span class="genericon genericon-twitter"></span>
<em>@SylvainCorlay</em>
</a>
</div>
</div>
<div class="bio-card">
<img class="card-photo" alt="Avatar picture" src="Johan.jpg">
<p class="card-header">Johan Mabille</p>
<div class="card-info">
<a href="https://github.com/JohanMabille" target="_blank">
<span class="genericon genericon-github"></span>
<em>@JohanMabille</em>
</a>
</div>
<div class="card-info">
<a href="https://twitter.com/JohanMabille" target="_blank">
<span class="genericon genericon-twitter"></span>
<em>@JohanMabille</em>
</a>
</div>
</div>
</div>
</section>
<section>
<h2>Project Jupyter</h2>
<div style="width: 70%; margin: auto; font-size: 24px;">
<ul>
<li>Consistent set of tools to improve and unify scientific computing workflows,</li>
<li>An interface between metal and humans, metal and flesh.</li>
</ul>
<p>From day 1, Jupyter was developed by scientists for scientists and educators</p>
</div>
</section>
<section>
<h3>Interactive workflows</h3>
<div style="width: 70%; margin: auto; font-size: 24px;">
<p style="text-align: left;">Programming languages are not only used to <strong>build complex
systems</strong>, but also to <strong>explore</strong> and <strong>gain insight</strong> about</p>
<ul>
<li>A computing resource</li>
<li>A data set</li>
<li>The outcome of a simulation</li>
</ul>
<div class="fragment">
<p style="text-align: left;">Interactive workflows:<p>
<ul>
<li>Loading some data</li>
<li>Running some code</li>
<li>Showing a visualization</li>
<li>Running some more code...</li>
</ul>
</div>
</div>
</section>
<section>
<h3>The C++ programming language</h3>
<div style="font-size: 28px;">
<ul>
<li>Taylored for performances</li>
<li>With a massive community</li>
<li>Especially in HPC</li>
</ul>
</div>
</section>
<section>
<p><strong>(Outside of ROOT) We lack a good story for interative computing in C++</strong></p>
<div style="width: 60%; margin: auto; font-size: 28px; text-align: left;">
<p>This hurts productivity of C++ software developers.</p>
<ul>
<li>C++ is generally considered as a difficult programming language</li>
<li>Heterogeneous set of tools...</li>
<li>... that don't always play well together</li>
<li>making scientific workflows hard to reproduce</li>
</ul>
</div>
</section>
<section>
<div>
<img alt="xeus-cling" src="xeus-cling.svg" width="25%"/>
</div>
<p>A C++ kernel for Jupyter based on</p>
<ul>
<li class="fragment">
<p>A modern C++ implementation of the Jupyter protocol</p>
<img alt="xeus" src="xeus.svg" width="15%"/>
</li>
<li class="fragment">
<p>Cling, the C++ interpreter developed at CERN</p>
</li>
</ul>
</section>
<section>
<h2>Live demo of Xeus-Cling</h2>
</section>
<section>
<h2>Jupyter interactive widgets</h2>
<p>Another area where Jupyter shines is Jupyter interactive widgets</p>
<img alt="bqplot" src="bqplot-won.gif" width="40%;"/>
</section>
<section>
<p>Jupyter interactive widgets: thick front-end and thin back-end</p>
<img alt="widgets-arch" src="widgets-arch.png" width="60%;"/>
</section>
<section>
<div>
<img alt="xwidgets" src="xwidgets.svg" width="25%"/>
</div>
<ul>
<li>A modern C++ back-end for Jupyter interactive widgets</li>
<li>Uses the front-end implementation of ipywidgets</li>
</ul>
</section>
<section>
<h2>Live demo of xwidgets</h2>
</section>
<section>
<p>Next goal: implement C++ back-end for other widgets libraries</p>
<ul>
<li>bqplot</li>
<li>ipyleaflet</li>
<li>pythreejs</li>
<li>ipyvolume</li>
<li>...</li>
</ul>
</section>
<section>
<div>
<img alt="xleaflet" src="xleaflet.svg" width="25%"/>
</div>
<ul>
<li>A modern C++ back-end for ipyleaflet</li>
<li>Uses the front-end implementation of ipyleaflet</li>
</ul>
</section>
<section>
<h2>Live demo of xleaflet</h2>
</section>
<section>
<h2>Voila</h2>
</section>
<section>
<img alt="xtensor" src="xtensor.svg" width="80%"/>
<p>The Lazy Tensor Algebra Expression System</p>
<div style="width: 70%; margin: auto; font-size: 28px; text-align: left;">
<p>Xtensor is a flexible expression system in which any data structure can be plugged, offering the most expressive API to the users.</p>
</div>
</section>
<section>
<section>
<h2>What is xtensor?</h2>
<div style="margin-left: auto; margin-right: auto; width: 70%; font-size: 24px;">
<ul>
<li class="fragment">
<p>A C++ template library for multi-dimensional array manipulation</p>
<img alt="xtensor" src="xtensor.svg" width="12%"/>
<ul>
<li>
<p>Followings the idioms of the C++ STL</p>
<p>(iterator pairs, clear value semantics)</p>
</li>
<li>But also an API similar to that of numpy</li>
</ul>
</li>
</ul>
</div>
</section>
<section>
<h2>What is xtensor?</h2>
<div style="margin: auto; width: 80%; font-size: 24px;">
<ul>
<li class="fragment">
<p>Python bindings to enable xtensor APIs on numpy arrays.</p>
<img alt="xtensor-python" src="xtensor-python.svg" width="20%"/>
</li>
<li class="fragment">
<p>Julia bindings to enable xtensor APIs on Julia arrays.</p>
<img alt="xtensor-julia" src="xtensor-julia.svg" width="20%"/>
</li>
<li class="fragment">
<p>R bindings to enable xtensor APIs on R arrays.</p>
<img alt="xtensor-r" src="xtensor-r.svg" width="20%"/>
</li>
<li class="fragment">
<p>Cookiecutter projects for authoring of Python, Julia, and R extensions.</p>
<img alt="xtensor-cookiecutter" src="xtensor-cookiecutter.svg" width="20%"/>
</li>
</ul>
</div>
</section>
<section>
<h2>What is xtensor?</h2>
<div style="margin-left: auto; margin-right: auto; width: 70%; font-size: 24px;">
<ul>
<li class="fragment">
<p>BLAS bindings to enable BLAS operations on xtensor expressions.</p>
<img alt="xtensor-blas" src="xtensor-blas.svg" width="20%"/>
</li>
<li class="fragment">
<p>SIMD acceleration kernels.</p>
<img alt="xsimd" src="xsimd.svg" width="20%"/>
</li>
<li class="fragment">All open-source (BSD License).</li>
</ul>
</div>
</section>
</section>
<section>
<style>
div.splitting {
background-color: rgb(20, 98, 135);
width: 50%;
height: 800%;
position: absolute;
top: -200%;
left: 0;
z-index: -1;
}
div.left-panel {
width: 45%;
display: inline-block;
margin-right: 5%;
vertical-align: top;
}
div.right-panel {
width: 45%;
display: inline-block;
}
code.panel {
background-color: initial;
}
pre.panel {
box-shadow: none;
}
</style>
<section>
<div class="splitting"></div>
<div>
<p style="text-align: center; vertical-align: top;">Ever heard of numpy ?</p>
</div>
<div>
<div class="left-panel">
<p style="text-align: center;"><b>Python 3 - numpy</b></p>
</div>
<div class="right-panel">
<p style="text-align: center;"><b>C++ 14 - xtensor</b></p>
</div>
</div>
<div class="fragment">
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.array([[3, 4], [5, 6]])
arr.reshape([3, 4])
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::xarray<double>({{3, 4}, {5, 6}})
xt::xtensor<double, 2>({{3, 4}, {5, 6}})
arr.reshape({3, 4});
</code></pre>
</div>
</div>
<div class="fragment">
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.linspace(1.0, 10.0, 100)
np.logspace(1.0, 10.0, 100)
np.arange(3, 7)
np.eye(4)
np.zeros([3, 4])
np.ones([3, 4])
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::linspace<double>(1.0, 10.0, 100)
xt::logspace<double>(1.0, 10.0, 100)
xt::arange(3, 7)
xt::eye(4)
xt::zeros<double>({3, 4})
xt::ones<double>({3, 4})
</code></pre>
</div>
</div>
</section>
<section>
<div class="splitting"></div>
<div>
<div class="left-panel">
<p style="text-align: center;"><b>Python 3 - numpy</b></p>
</div>
<div class="right-panel">
<p style="text-align: center;"><b>C++ 14 - xtensor</b></p>
</div>
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
a[:, np.newaxis]
a[:5, 1:]
a[5:1:-1, :]
np.broadcast(a, [4, 5, 7])
np.vectorize(f)
a[a > 5]
a[[0, 1], [0, 0]]
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::view(a, xt::all(), xt::newaxis())
xt::view(a, xt::range(_, 5), xt::range(1, _))
xt::view(a, xt::range(5, 1, -1), xt::all())
xt::broadcast(a, {4, 5, 7})
xt::vectorize(f)
xt::filter(a, a > 5)
xt::index_view(a, {{0, 0}, {1, 0}})
</code></pre>
</div>
</div>
<div class="fragment">
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.sum(a, axis=[0, 1])
np.sum(a)
np.prod(a, axis=1)
np.prod(a)
np.mean(a, axis=1)
np.mean(a)
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::sum(a, {0, 1})
xt::sum(a)
xt::prod(a, {1})
xt::prod(a)
xt::mean(a, {1})
xt::mean(a)
</code></pre>
</div>
</div>
</section>
<section>
<div class="splitting"></div>
<div>
<div class="left-panel">
<p style="text-align: center;"><b>Python 3 - numpy</b></p>
</div>
<div class="right-panel">
<p style="text-align: center;"><b>C++ 14 - xtensor</b></p>
</div>
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.where(a > 5, a, b)
np.where(a > 5)
np.any(a)
np.all(a)
np.logical_and(a, b)
np.logical_or(a, b)
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::where(a > 5, a, b)
xt::where(a > 5)
xt::any(a)
xt::all(a)
a && b
a || b
</code></pre>
</div>
</div>
<div class="fragment">
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.absolute(a)
np.exp(a)
np.sqrt(a)
np.cos(a)
np.cosh(a)
scipy.special.erf(a)
np.isnan(a)
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::abs(a)
xt::exp(a)
xt::sqrt(a)
xt::cos(a)
xt::cosh(a)
xt::erf(a)
xt::isnan(a)
</code></pre>
</div>
</div>
</section>
<section>
<div class="splitting"></div>
<div>
<div class="left-panel">
<p style="text-align: center;"><b>Python 3 - numpy</b></p>
</div>
<div class="right-panel">
<p style="text-align: center;"><b>C++ 14 - xtensor</b></p>
</div>
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.random.seed(0)
np.random.randn(10, 10)
np.random.randint(10, 10)
np.random.rand(3, 4)
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::random::seed(0)
xt::random::randn<double>({10, 10})
xt::random::randint<int>({10, 10}})
xt::random::rand<double>({3, 4}})
</code></pre>
</div>
</div>
<div class="fragment">
<div class="left-panel">
<pre class="panel"><code class="python panel" data-trim>
np.stack([a, b, c], axis=1)
np.concatenate([a, b, c], axis=1)
</code></pre>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xt::stack(xtuple(a, b, c), 1)
xt::concatenate(xtuple(a, b, c), 1)
</code></pre>
</div>
</div>
</section>
</section>
<section>
<section>
<div class="splitting"></div>
<p>Broadcasting</p>
<div class="fragment" style="margin-top: 5%;">
<div class="left-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xarray<int> a = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}};
xarray<int> b = { 1, 3, 5, 7};
</code></pre>
</div>
<div class="right-panel">
<img alt="broadcasting4.svg" src="broadcasting4.svg" width="70%"/>
</div>
</div>
<div class="fragment" style="margin-top: 5%;">
<div class="left-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xarray<int> res = a + b;
</code></pre>
</div>
<div class="right-panel">
<img alt="broadcasting5.svg" src="broadcasting5.svg" width="70%"/>
</div>
</div>
</section>
<section>
<div class="splitting"></div>
<p>Broadcasting</p>
<div style="margin-top: 2%;">
<div class="left-panel">
<pre class="panel"><code class="cpp panel" data-trim>
xarray<double> a = {1., 2., 3., 4.};
</code></pre>
</div>
<div class="right-panel">
<img alt="broadcasting1.svg" src="broadcasting1.svg" width="30%"/>
</div>
</div>
<div style="margin-top: 2%;">
<div class="left-panel fragment">
<pre class="panel"><code class="cpp panel" data-trim>
auto res = xt::broadcast(a, {3, 4});
</code></pre>
</div>
<div class="right-panel fragment">
<img alt="broadcasting2.svg" src="broadcasting2.svg" width="30%"/>
</div>
</div>
<div style="margin-top:2%;">
<div class="left-panel fragment">
<pre class="panel"><code class="cpp panel" data-trim>
xarray<double> a, b, c;
// ... initialization of a, b, and c ...
auto res = broadcast(a + b * c, {3, 4});
</code></pre>
</div>
<div class="right-panel fragment">
<img alt="broadcasting3.svg" src="broadcasting3.svg" width="30%"/>
</div>
</div>
</section>
</section>
<section>
<section>
<div class="splitting"></div>
<p>Iteration</p>
<div style="font-size: 24px;">
<div style="margin-top: 2%;">
<div class="left-panel">
Row-major iteration over the array <code>for x in np.nditer(a)</code>
</div>
<div class="right-panel">
<pre class="panel"><code class="cpp panel" data-trim>
for(auto it=a.begin(); it!=a.end(); ++it)
</code></pre>
</div>
</div>
<div style="margin-top: 2%;">
<div class="left-panel fragment">
Iterating over <code>a</code> with a prescribed broadcasting shape
</div>
<div class="right-panel fragment">
<pre class="panel"><code class="cpp panel" data-trim>
a.begin({3, 4})
a.end({3, 4})
</code></pre>
</div>
</div>
<div style="margin-top:2%;">
<div class="left-panel fragment">
Iterating over <code>a</code> in a column-major fashion
</div>
<div class="right-panel fragment">
<pre class="panel"><code class="cpp panel" data-trim>
a.template begin<layout_type::column_major>()
a.template end<layout_type::column_major>()
</code></pre>
</div>
</div>
<div style="margin-top:2%;">
<div class="left-panel fragment">
Iterating over <code>a</code> in a column-major fashion with a prescribed broadcasting shape
</div>
<div class="right-panel fragment">
<pre class="panel"><code class="cpp panel" data-trim>
a.template begin<layout_type::column_major>({3, 4})
a.template end<layout_type::column_major>({3, 4})
</code></pre>
</div>
</div>
</div>
</section>
</section>
</section>
<section>
<h3>How do I try it without installing anything?</h3>
<p>http://quantstack.net/xtensor</pre>
<div>
<img alt="QuantStack website" src="website.png" width="55%"/>
</div>
</section>
<section>
<h3>Live demo</h3>
</section>
<section>
<section>
<h3>Language bindings with xtensor</h3>
<div><img alt="Python bingings" src="xtensor-python.svg" width="35%"/></div>
<div><img alt="JuliaLang bindings" src="xtensor-julia.svg" width="35%"/></div>
<div><img alt="R bindings" src="xtensor-r.svg" width="35%"/></div>
</section>
</section>
<section>
<section>
<img alt="Python bingings" src="xtensor-python.svg" width="35%"/>
<p>A Simple Python extension (1/2)</p>
<div style="font-size: 20px;">
<p>C++: Using an algorithm from the STL on a numpy array</p>
<pre class="panel">
<code class="cpp">
#include <numeric> // Standard library import for std::accumulate
#include "pybind11/pybind11.h" // Pybind11 import to define Python bindings
#include "xtensor/xmath.hpp" // xtensor import for the C++ universal functions
#define FORCE_IMPORT_ARRAY // numpy C api loading
#include "xtensor-python/pyarray.hpp" // Numpy bindings
double sum_of_sines(xt::pyarray<double>& m)
{
auto sines = xt::sin(m);
// sines does not actually hold any value, which are only computed upon access
return std::accumulate(sines.begin(), sines.end(), 0.0);
}
PYBIND11_PLUGIN(xtensor_python_test)
{
xt::import_numpy();
pybind11::module m("xtensor_python_test", "Test module for xtensor python bindings");
m.def("sum_of_sines", sum_of_sines,
"Computes the sum of the sines of the values of the input array");
return m.ptr();
}
</code>
</pre>
</div>
</section>
<section>
<img alt="Python bingings" src="xtensor-python.svg" width="50%"/>
<p>A simple Python extension (1/2)</p>
<div style="font-size: 20px;">
<p>Python: Using an algorithm from the STL on a numpy array</p>
<pre class="panel">
<code class="python">
import numpy as np
import xtensor_python_test as xt
a = np.arange(15).reshape(3, 5)
xt.sum_of_sines(v)
</code>
</pre>
</div>
</section>
</section>
<section>
<section>
<img alt="Python bingings" src="xtensor-python.svg" width="40%"/>
<p>A simple Python extension (2/2)</p>
<div style="font-size: 20px;">
<p>C++: Create a universal function from a C++ scalar function</p>
<pre class="panel">
<code class="cpp">
#include "pybind11/pybind11.h"
#define FORCE_IMPORT_ARRAY
#include "xtensor-python/pyvectorize.hpp"
#include <numeric>
#include <cmath>
namespace py = pybind11;
double scalar_func(double i, double j)
{
return std::sin(i) - std::cos(j);
}
PYBIND11_PLUGIN(xtensor_python_test)
{
xt::import_numpy();
py::module m("xtensor_python_test", "Test module for xtensor python bindings");
m.def("vectorized_func", xt::pyvectorize(scalar_func), "");
return m.ptr();
}
</code>
</pre>
</div>
</section>
<section>
<img alt="Python bingings" src="xtensor-python.svg" width="40%"/>
<p>A simple Python extension (2/2)</p>
<div style="font-size: 20px;">
<p>Python: Create a numpy-style universal function from a C++ scalar function</p>
<pre class="panel">
<code class="python">
import numpy as np
import xtensor_python_test as xt
x = np.arange(15).reshape(3, 5)
y = [1, 2, 3, 4, 5]
xt.vectorized_func(x, y)
</code>
</pre>
</div>
</section>
</section>
<section>
<section>
<img alt="Julia bingings" src="xtensor-julia.svg" width="40%"/>
<p>A Simple Julia extension (1/2)</p>
<div style="font-size: 20px;">
<p>C++: Using an algorithm from the STL on a Julia array</p>
<pre class="panel">
<code class="cpp">
#include <numeric> // Standard library import for std::accumulate
#include "jlcxx/jlcxx.hpp¨ // CxxWrap import to define Julia bindings
#include "xtensor-julia/jltensor.hpp" // Import the jltensor container definition
#include "xtensor/xmath.hpp" // xtensor import for the C++ universal functions
double sum_of_sines(xt::jltensor<double, 2> m)
{
auto sines = xt::sin(m); // sines does not actually hold values.
return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
}
JULIA_CPP_MODULE_BEGIN(registry)
jlcxx::Module mod = registry.create_module("xtensor_julia_test");
mod.method("sum_of_sines", sum_of_sines);
JULIA_CPP_MODULE_END
</code>
</pre>
</div>
</section>
<section>
<img alt="Julia bingings" src="xtensor-julia.svg" width="40%"/>
<p>A simple Julia extension (1/2)</p>
<div style="font-size: 20px;">
<p>Julia: Using an algorithm from the STL on a Julia array</p>
<pre class="panel">
<code class="julia">
using xtensor_julia_test
arr = [[1.0 2.0]
[3.0 4.0]]
sum_of_sines(arr)
</code>
</pre>
</div>
</section>
</section>
<section>
<section>
<img alt="Julia bingings" src="xtensor-julia.svg" width="40%"/>
<p>A simple Julia extension (2/2)</p>
<div style="font-size: 20px;">
<p>C++: Create a numpy-style universal function from a C++ scalar function</p>
<pre class="panel">
<code class="cpp">
#include "jlcxx/jlcxx.hpp"
#include "xtensor-julia/jlvectorize.hpp"
double scalar_func(double i, double j)
{
return std::sin(i) - std::cos(j);
}
JULIA_CPP_MODULE_BEGIN(registry)
jlcxx::Module mod = registry.create_module("xtensor_julia_test");
mod.method("vectorized_func", xt::jlvectorize(scalar_func));
JULIA_CPP_MODULE_END
</code>
</pre>
</div>
</section>
<section>
<img alt="Julia bingings" src="xtensor-julia.svg" width="40%"/>
<p>A simple Julia extension (2/2)</p>
<div style="font-size: 20px;">
<p>Julia: Create a numpy-style universal function from a C++ scalar function</p>
<pre class="panel">
<code class="julia">
using xtensor_julia_test
x = [[ 0.0 1.0 2.0 3.0 4.0]
[ 5.0 6.0 7.0 8.0 9.0]
[10.0 11.0 12.0 13.0 14.0]]
y = [1.0, 2.0, 3.0, 4.0, 5.0]
xt.vectorized_func(x, y)
</code>
</pre>
</div>
</section>
</section>
<section>
<section>
<img alt="R bingings" src="xtensor-r.svg" width="40%"/>
<p>A Simple R extension</p>
<div style="font-size: 20px;">
<p>C++: Using an algorithm from the STL on a R array</p>
<pre class="panel">
<code class="cpp">
// [[Rcpp::export]]
double sum_of_sines(xt::rarray<int> m)
{
auto sines = xt::sin(m); // sines does not actually hold values.
return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
}
</code>
</pre>
</div>
</section>
<section>
<img alt="R bingings" src="xtensor-r.svg" width="40%"/>
<p>A simple R extension</p>
<div style="font-size: 20px;">
<p>R: Using an algorithm from the STL on a R array</p>
<pre class="panel">
<code class="R">
library('xtensor_r_test')
arr <- array(c(c(1, 2), c(3, 4)), dim = c(2, 2)
xtensor_r_test::sum_of_sines(arr)
</code>
</pre>
</div>
</section>
</section>
<section>
<img alt="xtensor-cookiecutter" src="xtensor-cookiecutter.svg" width="70%"/>
<div style="font-size: 24px;">
<p>Generate your packaged xtensor extension</p>
<ul>
<li>With a few examples from the documentation</li>
<li>Unit-tests</li>
<li>HTML documentation</li>
<li>Packaging boilerplate (setup.py, build.jl)</li>
</ul>
</div>
</section>
<section>
<p>Bindings with BLAS libraries</p>
<img alt="xtensor-blas" src="xtensor-blas.svg" width="55%"/>
<div style="font-size: 24px;">
<p>BLAS-based implementation of <code>numpy.linalg</code></p>
<ul>
<li>ISO results with <code>numpy.linalg</code> is main goal</li>
<li>Seeking adoption by Python to C++ compilers (Pythran, Jet)</li>
<li>Works with any BLAS implementation (openblas, mkl, netlib)</li>
<li>See the <a href="http://xtensor.readthedocs.io/en/latest/numpy.html">numpy to xtensor cheat sheet</a></li>
</ul>
</div>
</section>
<section>