cumo 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +16 -36
  3. data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +7 -0
  4. data/CHANGELOG.md +16 -0
  5. data/Dockerfile +34 -0
  6. data/cumo.gemspec +1 -1
  7. data/docker-build.sh +4 -0
  8. data/docker-launch.sh +4 -0
  9. data/docs/src-tree.md +1 -1
  10. data/ext/cumo/cuda/cudnn_impl.cpp +25 -3
  11. data/ext/cumo/cuda/driver.c +8 -0
  12. data/ext/cumo/depend.erb +1 -1
  13. data/ext/cumo/extconf.rb +1 -1
  14. data/ext/cumo/include/cumo/cuda/cumo_thrust.hpp +13 -6
  15. data/ext/cumo/include/cumo/cuda/cumo_thrust_complex.hpp +3 -3
  16. data/ext/cumo/include/cumo/types/complex_macro_kernel.h +15 -4
  17. data/ext/cumo/include/cumo/types/real_accum_kernel.h +15 -4
  18. data/ext/cumo/include/cumo/types/xint_macro_kernel.h +11 -3
  19. data/ext/cumo/include/cumo.h +2 -2
  20. data/ext/cumo/narray/array.c +5 -3
  21. data/ext/cumo/narray/data.c +25 -26
  22. data/ext/cumo/narray/gen/tmpl/accum.c +2 -2
  23. data/ext/cumo/narray/gen/tmpl/accum_binary.c +1 -1
  24. data/ext/cumo/narray/gen/tmpl/aref.c +18 -18
  25. data/ext/cumo/narray/gen/tmpl/aset.c +16 -16
  26. data/ext/cumo/narray/gen/tmpl/batch_norm.c +4 -1
  27. data/ext/cumo/narray/gen/tmpl/batch_norm_backward.c +4 -1
  28. data/ext/cumo/narray/gen/tmpl/bincount.c +7 -7
  29. data/ext/cumo/narray/gen/tmpl/clip.c +11 -15
  30. data/ext/cumo/narray/gen/tmpl/cum.c +1 -1
  31. data/ext/cumo/narray/gen/tmpl/each.c +4 -2
  32. data/ext/cumo/narray/gen/tmpl/each_with_index.c +5 -2
  33. data/ext/cumo/narray/gen/tmpl/fixed_batch_norm.c +4 -1
  34. data/ext/cumo/narray/gen/tmpl/logseq.c +6 -5
  35. data/ext/cumo/narray/gen/tmpl/map_with_index.c +5 -6
  36. data/ext/cumo/narray/gen/tmpl/median.c +2 -2
  37. data/ext/cumo/narray/gen/tmpl/minmax.c +1 -1
  38. data/ext/cumo/narray/gen/tmpl/poly.c +4 -4
  39. data/ext/cumo/narray/gen/tmpl/rand.c +8 -6
  40. data/ext/cumo/narray/gen/tmpl/rand_norm.c +18 -16
  41. data/ext/cumo/narray/gen/tmpl/seq.c +5 -4
  42. data/ext/cumo/narray/gen/tmpl/sort.c +2 -2
  43. data/ext/cumo/narray/gen/tmpl/sort_index.c +2 -2
  44. data/ext/cumo/narray/gen/tmpl_bit/aref.c +26 -32
  45. data/ext/cumo/narray/gen/tmpl_bit/aset.c +18 -30
  46. data/ext/cumo/narray/index.c +1 -1
  47. data/ext/cumo/narray/narray.c +19 -18
  48. data/lib/cumo/narray/extra.rb +160 -156
  49. data/test/cuda/device_test.rb +2 -1
  50. data/test/cudnn_test.rb +2 -2
  51. metadata +5 -2
@@ -47,23 +47,23 @@ module Cumo
47
47
 
48
48
  # Rotate in the plane specified by axes.
49
49
  # @example
50
- # p a = Cumo::Int32.new(2,2).seq
51
- # # Cumo::Int32#shape=[2,2]
50
+ # a = Cumo::Int32.new(2,2).seq
51
+ # # => Cumo::Int32#shape=[2,2]
52
52
  # # [[0, 1],
53
53
  # # [2, 3]]
54
54
  #
55
- # p a.rot90
56
- # # Cumo::Int32(view)#shape=[2,2]
55
+ # a.rot90
56
+ # # => Cumo::Int32(view)#shape=[2,2]
57
57
  # # [[1, 3],
58
58
  # # [0, 2]]
59
59
  #
60
- # p a.rot90(2)
61
- # # Cumo::Int32(view)#shape=[2,2]
60
+ # a.rot90(2)
61
+ # # => Cumo::Int32(view)#shape=[2,2]
62
62
  # # [[3, 2],
63
63
  # # [1, 0]]
64
64
  #
65
- # p a.rot90(3)
66
- # # Cumo::Int32(view)#shape=[2,2]
65
+ # a.rot90(3)
66
+ # # => Cumo::Int32(view)#shape=[2,2]
67
67
  # # [[2, 0],
68
68
  # # [3, 1]]
69
69
  def rot90(k=1, axes=[0, 1])
@@ -129,10 +129,10 @@ module Cumo
129
129
  # 4 9 7
130
130
  # 2 -1 6
131
131
  # ]
132
- # => Cumo::DFloat#shape=[3,3]
133
- # [[2, -3, 5],
134
- # [4, 9, 7],
135
- # [2, -1, 6]]
132
+ # # => Cumo::DFloat#shape=[3,3]
133
+ # # [[2, -3, 5],
134
+ # # [4, 9, 7],
135
+ # # [2, -1, 6]]
136
136
 
137
137
  def self.parse(str, split1d:/\s+/, split2d:/;?$|;/,
138
138
  split3d:/\s*\n(\s*\n)+/m)
@@ -162,7 +162,7 @@ module Cumo
162
162
 
163
163
 
164
164
  # Iterate over an axis
165
- # @ example
165
+ # @example
166
166
  # > a = Cumo::DFloat.new(2,2,2).seq
167
167
  # > p a
168
168
  # Cumo::DFloat#shape=[2,2,2]
@@ -212,19 +212,19 @@ module Cumo
212
212
  # Append values to the end of an narray.
213
213
  # @example
214
214
  # a = Cumo::DFloat[1, 2, 3]
215
- # p a.append([[4, 5, 6], [7, 8, 9]])
216
- # # Cumo::DFloat#shape=[9]
215
+ # a.append([[4, 5, 6], [7, 8, 9]])
216
+ # # => Cumo::DFloat#shape=[9]
217
217
  # # [1, 2, 3, 4, 5, 6, 7, 8, 9]
218
218
  #
219
219
  # a = Cumo::DFloat[[1, 2, 3]]
220
- # p a.append([[4, 5, 6], [7, 8, 9]],axis:0)
221
- # # Cumo::DFloat#shape=[3,3]
220
+ # a.append([[4, 5, 6], [7, 8, 9]],axis:0)
221
+ # # => Cumo::DFloat#shape=[3,3]
222
222
  # # [[1, 2, 3],
223
223
  # # [4, 5, 6],
224
224
  # # [7, 8, 9]]
225
225
  #
226
226
  # a = Cumo::DFloat[[1, 2, 3], [4, 5, 6]]
227
- # p a.append([7, 8, 9], axis:0)
227
+ # a.append([7, 8, 9], axis:0)
228
228
  # # in `append': dimension mismatch (Cumo::NArray::DimensionError)
229
229
 
230
230
  def append(other, axis:nil)
@@ -247,19 +247,19 @@ module Cumo
247
247
 
248
248
  # @example
249
249
  # a = Cumo::DFloat[[1,2,3,4], [5,6,7,8], [9,10,11,12]]
250
- # p a.delete(1,0)
251
- # # Cumo::DFloat(view)#shape=[2,4]
250
+ # a.delete(1,0)
251
+ # # => Cumo::DFloat(view)#shape=[2,4]
252
252
  # # [[1, 2, 3, 4],
253
253
  # # [9, 10, 11, 12]]
254
254
  #
255
- # p a.delete((0..-1).step(2),1)
256
- # # Cumo::DFloat(view)#shape=[3,2]
255
+ # a.delete((0..-1).step(2),1)
256
+ # # => Cumo::DFloat(view)#shape=[3,2]
257
257
  # # [[2, 4],
258
258
  # # [6, 8],
259
259
  # # [10, 12]]
260
260
  #
261
- # p a.delete([1,3,5])
262
- # # Cumo::DFloat(view)#shape=[9]
261
+ # a.delete([1,3,5])
262
+ # # => Cumo::DFloat(view)#shape=[9]
263
263
  # # [1, 3, 5, 7, 8, 9, 10, 11, 12]
264
264
 
265
265
  def delete(indice, axis=nil)
@@ -278,72 +278,72 @@ module Cumo
278
278
 
279
279
  # Insert values along the axis before the indices.
280
280
  # @example
281
- # p a = Cumo::DFloat[[1, 2], [3, 4]]
281
+ # a = Cumo::DFloat[[1, 2], [3, 4]]
282
282
  # a = Cumo::Int32[[1, 1], [2, 2], [3, 3]]
283
283
  #
284
- # p a.insert(1,5)
285
- # # Cumo::Int32#shape=[7]
284
+ # a.insert(1,5)
285
+ # # => Cumo::Int32#shape=[7]
286
286
  # # [1, 5, 1, 2, 2, 3, 3]
287
287
  #
288
- # p a.insert(1, 5, axis:1)
289
- # # Cumo::Int32#shape=[3,3]
288
+ # a.insert(1, 5, axis:1)
289
+ # # => Cumo::Int32#shape=[3,3]
290
290
  # # [[1, 5, 1],
291
291
  # # [2, 5, 2],
292
292
  # # [3, 5, 3]]
293
293
  #
294
- # p a.insert([1], [[11],[12],[13]], axis:1)
295
- # # Cumo::Int32#shape=[3,3]
294
+ # a.insert([1], [[11],[12],[13]], axis:1)
295
+ # # => Cumo::Int32#shape=[3,3]
296
296
  # # [[1, 11, 1],
297
297
  # # [2, 12, 2],
298
298
  # # [3, 13, 3]]
299
299
  #
300
- # p a.insert(1, [11, 12, 13], axis:1)
301
- # # Cumo::Int32#shape=[3,3]
300
+ # a.insert(1, [11, 12, 13], axis:1)
301
+ # # => Cumo::Int32#shape=[3,3]
302
302
  # # [[1, 11, 1],
303
303
  # # [2, 12, 2],
304
304
  # # [3, 13, 3]]
305
305
  #
306
- # p a.insert([1], [11, 12, 13], axis:1)
307
- # # Cumo::Int32#shape=[3,5]
306
+ # a.insert([1], [11, 12, 13], axis:1)
307
+ # # => Cumo::Int32#shape=[3,5]
308
308
  # # [[1, 11, 12, 13, 1],
309
309
  # # [2, 11, 12, 13, 2],
310
310
  # # [3, 11, 12, 13, 3]]
311
311
  #
312
- # p b = a.flatten
313
- # # Cumo::Int32(view)#shape=[6]
312
+ # b = a.flatten
313
+ # # => Cumo::Int32(view)#shape=[6]
314
314
  # # [1, 1, 2, 2, 3, 3]
315
315
  #
316
- # p b.insert(2,[15,16])
317
- # # Cumo::Int32#shape=[8]
316
+ # b.insert(2,[15,16])
317
+ # # => Cumo::Int32#shape=[8]
318
318
  # # [1, 1, 15, 16, 2, 2, 3, 3]
319
319
  #
320
- # p b.insert([2,2],[15,16])
321
- # # Cumo::Int32#shape=[8]
320
+ # b.insert([2,2],[15,16])
321
+ # # => Cumo::Int32#shape=[8]
322
322
  # # [1, 1, 15, 16, 2, 2, 3, 3]
323
323
  #
324
- # p b.insert([2,1],[15,16])
325
- # # Cumo::Int32#shape=[8]
324
+ # b.insert([2,1],[15,16])
325
+ # # => Cumo::Int32#shape=[8]
326
326
  # # [1, 16, 1, 15, 2, 2, 3, 3]
327
327
  #
328
- # p b.insert([2,0,1],[15,16,17])
329
- # # Cumo::Int32#shape=[9]
328
+ # b.insert([2,0,1],[15,16,17])
329
+ # # => Cumo::Int32#shape=[9]
330
330
  # # [16, 1, 17, 1, 15, 2, 2, 3, 3]
331
331
  #
332
- # p b.insert(2..3, [15, 16])
333
- # # Cumo::Int32#shape=[8]
332
+ # b.insert(2..3, [15, 16])
333
+ # # => Cumo::Int32#shape=[8]
334
334
  # # [1, 1, 15, 2, 16, 2, 3, 3]
335
335
  #
336
- # p b.insert(2, [7.13, 0.5])
337
- # # Cumo::Int32#shape=[8]
336
+ # b.insert(2, [7.13, 0.5])
337
+ # # => Cumo::Int32#shape=[8]
338
338
  # # [1, 1, 7, 0, 2, 2, 3, 3]
339
339
  #
340
- # p x = Cumo::DFloat.new(2,4).seq
341
- # # Cumo::DFloat#shape=[2,4]
340
+ # x = Cumo::DFloat.new(2,4).seq
341
+ # # => Cumo::DFloat#shape=[2,4]
342
342
  # # [[0, 1, 2, 3],
343
343
  # # [4, 5, 6, 7]]
344
344
  #
345
- # p x.insert([1,3],999,axis:1)
346
- # # Cumo::DFloat#shape=[2,6]
345
+ # x.insert([1,3],999,axis:1)
346
+ # # => Cumo::DFloat#shape=[2,6]
347
347
  # # [[0, 999, 1, 2, 999, 3],
348
348
  # # [4, 999, 5, 6, 999, 7]]
349
349
 
@@ -393,23 +393,23 @@ module Cumo
393
393
 
394
394
  class << self
395
395
  # @example
396
- # p a = Cumo::DFloat[[1, 2], [3, 4]]
397
- # # Cumo::DFloat#shape=[2,2]
396
+ # a = Cumo::DFloat[[1, 2], [3, 4]]
397
+ # # => Cumo::DFloat#shape=[2,2]
398
398
  # # [[1, 2],
399
399
  # # [3, 4]]
400
400
  #
401
- # p b = Cumo::DFloat[[5, 6]]
402
- # # Cumo::DFloat#shape=[1,2]
401
+ # b = Cumo::DFloat[[5, 6]]
402
+ # # => Cumo::DFloat#shape=[1,2]
403
403
  # # [[5, 6]]
404
404
  #
405
- # p Cumo::NArray.concatenate([a,b],axis:0)
406
- # # Cumo::DFloat#shape=[3,2]
405
+ # Cumo::NArray.concatenate([a,b],axis:0)
406
+ # # => Cumo::DFloat#shape=[3,2]
407
407
  # # [[1, 2],
408
408
  # # [3, 4],
409
409
  # # [5, 6]]
410
410
  #
411
- # p Cumo::NArray.concatenate([a,b.transpose], axis:1)
412
- # # Cumo::DFloat#shape=[2,3]
411
+ # Cumo::NArray.concatenate([a,b.transpose], axis:1)
412
+ # # => Cumo::DFloat#shape=[2,3]
413
413
  # # [[1, 2, 5],
414
414
  # # [3, 4, 6]]
415
415
 
@@ -471,15 +471,15 @@ module Cumo
471
471
  # @example
472
472
  # a = Cumo::Int32[1,2,3]
473
473
  # b = Cumo::Int32[2,3,4]
474
- # p Cumo::NArray.vstack([a,b])
475
- # # Cumo::Int32#shape=[2,3]
474
+ # Cumo::NArray.vstack([a,b])
475
+ # # => Cumo::Int32#shape=[2,3]
476
476
  # # [[1, 2, 3],
477
477
  # # [2, 3, 4]]
478
478
  #
479
479
  # a = Cumo::Int32[[1],[2],[3]]
480
480
  # b = Cumo::Int32[[2],[3],[4]]
481
- # p Cumo::NArray.vstack([a,b])
482
- # # Cumo::Int32#shape=[6,1]
481
+ # Cumo::NArray.vstack([a,b])
482
+ # # => Cumo::Int32#shape=[6,1]
483
483
  # # [[1],
484
484
  # # [2],
485
485
  # # [3],
@@ -498,14 +498,14 @@ module Cumo
498
498
  # @example
499
499
  # a = Cumo::Int32[1,2,3]
500
500
  # b = Cumo::Int32[2,3,4]
501
- # p Cumo::NArray.hstack([a,b])
502
- # # Cumo::Int32#shape=[6]
501
+ # Cumo::NArray.hstack([a,b])
502
+ # # => Cumo::Int32#shape=[6]
503
503
  # # [1, 2, 3, 2, 3, 4]
504
504
  #
505
505
  # a = Cumo::Int32[[1],[2],[3]]
506
506
  # b = Cumo::Int32[[2],[3],[4]]
507
- # p Cumo::NArray.hstack([a,b])
508
- # # Cumo::Int32#shape=[3,2]
507
+ # Cumo::NArray.hstack([a,b])
508
+ # # => Cumo::Int32#shape=[3,2]
509
509
  # # [[1, 2],
510
510
  # # [2, 3],
511
511
  # # [3, 4]]
@@ -526,16 +526,16 @@ module Cumo
526
526
  # @example
527
527
  # a = Cumo::Int32[1,2,3]
528
528
  # b = Cumo::Int32[2,3,4]
529
- # p Cumo::NArray.dstack([a,b])
530
- # # Cumo::Int32#shape=[1,3,2]
529
+ # Cumo::NArray.dstack([a,b])
530
+ # # => Cumo::Int32#shape=[1,3,2]
531
531
  # # [[[1, 2],
532
532
  # # [2, 3],
533
533
  # # [3, 4]]]
534
534
  #
535
535
  # a = Cumo::Int32[[1],[2],[3]]
536
536
  # b = Cumo::Int32[[2],[3],[4]]
537
- # p Cumo::NArray.dstack([a,b])
538
- # # Cumo::Int32#shape=[3,1,2]
537
+ # Cumo::NArray.dstack([a,b])
538
+ # # => Cumo::Int32#shape=[3,1,2]
539
539
  # # [[[1, 2]],
540
540
  # # [[2, 3]],
541
541
  # # [[3, 4]]]
@@ -551,8 +551,8 @@ module Cumo
551
551
  # @example
552
552
  # x = Cumo::Int32[1,2,3]
553
553
  # y = Cumo::Int32[2,3,4]
554
- # p Cumo::NArray.column_stack([x,y])
555
- # # Cumo::Int32#shape=[3,2]
554
+ # Cumo::NArray.column_stack([x,y])
555
+ # # => Cumo::Int32#shape=[3,2]
556
556
  # # [[1, 2],
557
557
  # # [2, 3],
558
558
  # # [3, 4]]
@@ -592,23 +592,23 @@ module Cumo
592
592
  end # class << self
593
593
 
594
594
  # @example
595
- # p a = Cumo::DFloat[[1, 2], [3, 4]]
596
- # # Cumo::DFloat#shape=[2,2]
595
+ # a = Cumo::DFloat[[1, 2], [3, 4]]
596
+ # # => Cumo::DFloat#shape=[2,2]
597
597
  # # [[1, 2],
598
598
  # # [3, 4]]
599
599
  #
600
- # p b = Cumo::DFloat[[5, 6]]
601
- # # Cumo::DFloat#shape=[1,2]
600
+ # b = Cumo::DFloat[[5, 6]]
601
+ # # => Cumo::DFloat#shape=[1,2]
602
602
  # # [[5, 6]]
603
603
  #
604
- # p a.concatenate(b,axis:0)
605
- # # Cumo::DFloat#shape=[3,2]
604
+ # a.concatenate(b,axis:0)
605
+ # # => Cumo::DFloat#shape=[3,2]
606
606
  # # [[1, 2],
607
607
  # # [3, 4],
608
608
  # # [5, 6]]
609
609
  #
610
- # p a.concatenate(b.transpose, axis:1)
611
- # # Cumo::DFloat#shape=[2,3]
610
+ # a.concatenate(b.transpose, axis:1)
611
+ # # => Cumo::DFloat#shape=[2,3]
612
612
  # # [[1, 2, 5],
613
613
  # # [3, 4, 6]]
614
614
 
@@ -654,24 +654,24 @@ module Cumo
654
654
  end
655
655
 
656
656
  # @example
657
- # p x = Cumo::DFloat.new(9).seq
658
- # # Cumo::DFloat#shape=[9]
657
+ # x = Cumo::DFloat.new(9).seq
658
+ # # => Cumo::DFloat#shape=[9]
659
659
  # # [0, 1, 2, 3, 4, 5, 6, 7, 8]
660
660
  #
661
- # pp x.split(3)
662
- # # [Cumo::DFloat(view)#shape=[3]
661
+ # x.split(3)
662
+ # # => [Cumo::DFloat(view)#shape=[3]
663
663
  # # [0, 1, 2],
664
664
  # # Cumo::DFloat(view)#shape=[3]
665
665
  # # [3, 4, 5],
666
666
  # # Cumo::DFloat(view)#shape=[3]
667
667
  # # [6, 7, 8]]
668
668
  #
669
- # p x = Cumo::DFloat.new(8).seq
670
- # # Cumo::DFloat#shape=[8]
669
+ # x = Cumo::DFloat.new(8).seq
670
+ # # => Cumo::DFloat#shape=[8]
671
671
  # # [0, 1, 2, 3, 4, 5, 6, 7]
672
672
  #
673
- # pp x.split([3, 5, 6, 10])
674
- # # [Cumo::DFloat(view)#shape=[3]
673
+ # x.split([3, 5, 6, 10])
674
+ # # => [Cumo::DFloat(view)#shape=[3]
675
675
  # # [0, 1, 2],
676
676
  # # Cumo::DFloat(view)#shape=[2]
677
677
  # # [3, 4],
@@ -718,15 +718,15 @@ module Cumo
718
718
  end
719
719
 
720
720
  # @example
721
- # p x = Cumo::DFloat.new(4,4).seq
722
- # # Cumo::DFloat#shape=[4,4]
721
+ # x = Cumo::DFloat.new(4,4).seq
722
+ # # => Cumo::DFloat#shape=[4,4]
723
723
  # # [[0, 1, 2, 3],
724
724
  # # [4, 5, 6, 7],
725
725
  # # [8, 9, 10, 11],
726
726
  # # [12, 13, 14, 15]]
727
727
  #
728
- # pp x.hsplit(2)
729
- # # [Cumo::DFloat(view)#shape=[4,2]
728
+ # x.hsplit(2)
729
+ # # => [Cumo::DFloat(view)#shape=[4,2]
730
730
  # # [[0, 1],
731
731
  # # [4, 5],
732
732
  # # [8, 9],
@@ -737,8 +737,8 @@ module Cumo
737
737
  # # [10, 11],
738
738
  # # [14, 15]]]
739
739
  #
740
- # pp x.hsplit([3, 6])
741
- # # [Cumo::DFloat(view)#shape=[4,3]
740
+ # x.hsplit([3, 6])
741
+ # # => [Cumo::DFloat(view)#shape=[4,3]
742
742
  # # [[0, 1, 2],
743
743
  # # [4, 5, 6],
744
744
  # # [8, 9, 10],
@@ -763,47 +763,47 @@ module Cumo
763
763
  end
764
764
 
765
765
  # @example
766
- # p a = Cumo::NArray[0,1,2]
767
- # # Cumo::Int32#shape=[3]
766
+ # a = Cumo::NArray[0,1,2]
767
+ # # => Cumo::Int32#shape=[3]
768
768
  # # [0, 1, 2]
769
769
  #
770
- # p a.tile(2)
771
- # # Cumo::Int32#shape=[6]
770
+ # a.tile(2)
771
+ # # => Cumo::Int32#shape=[6]
772
772
  # # [0, 1, 2, 0, 1, 2]
773
773
  #
774
- # p a.tile(2,2)
775
- # # Cumo::Int32#shape=[2,6]
774
+ # a.tile(2,2)
775
+ # # => Cumo::Int32#shape=[2,6]
776
776
  # # [[0, 1, 2, 0, 1, 2],
777
777
  # # [0, 1, 2, 0, 1, 2]]
778
778
  #
779
- # p a.tile(2,1,2)
780
- # # Cumo::Int32#shape=[2,1,6]
779
+ # a.tile(2,1,2)
780
+ # # => Cumo::Int32#shape=[2,1,6]
781
781
  # # [[[0, 1, 2, 0, 1, 2]],
782
782
  # # [[0, 1, 2, 0, 1, 2]]]
783
783
  #
784
- # p b = Cumo::NArray[[1, 2], [3, 4]]
785
- # # Cumo::Int32#shape=[2,2]
784
+ # b = Cumo::NArray[[1, 2], [3, 4]]
785
+ # # => Cumo::Int32#shape=[2,2]
786
786
  # # [[1, 2],
787
787
  # # [3, 4]]
788
788
  #
789
- # p b.tile(2)
790
- # # Cumo::Int32#shape=[2,4]
789
+ # b.tile(2)
790
+ # # => Cumo::Int32#shape=[2,4]
791
791
  # # [[1, 2, 1, 2],
792
792
  # # [3, 4, 3, 4]]
793
793
  #
794
- # p b.tile(2,1)
795
- # # Cumo::Int32#shape=[4,2]
794
+ # b.tile(2,1)
795
+ # # => Cumo::Int32#shape=[4,2]
796
796
  # # [[1, 2],
797
797
  # # [3, 4],
798
798
  # # [1, 2],
799
799
  # # [3, 4]]
800
800
  #
801
- # p c = Cumo::NArray[1,2,3,4]
802
- # # Cumo::Int32#shape=[4]
801
+ # c = Cumo::NArray[1,2,3,4]
802
+ # # => Cumo::Int32#shape=[4]
803
803
  # # [1, 2, 3, 4]
804
804
  #
805
- # p c.tile(4,1)
806
- # # Cumo::Int32#shape=[4,4]
805
+ # c.tile(4,1)
806
+ # # => Cumo::Int32#shape=[4,4]
807
807
  # # [[1, 2, 3, 4],
808
808
  # # [1, 2, 3, 4],
809
809
  # # [1, 2, 3, 4],
@@ -846,26 +846,26 @@ module Cumo
846
846
  end
847
847
 
848
848
  # @example
849
- # p Cumo::NArray[3].repeat(4)
850
- # # Cumo::Int32#shape=[4]
849
+ # Cumo::NArray[3].repeat(4)
850
+ # # => Cumo::Int32#shape=[4]
851
851
  # # [3, 3, 3, 3]
852
852
  #
853
- # p x = Cumo::NArray[[1,2],[3,4]]
854
- # # Cumo::Int32#shape=[2,2]
853
+ # x = Cumo::NArray[[1,2],[3,4]]
854
+ # # => Cumo::Int32#shape=[2,2]
855
855
  # # [[1, 2],
856
856
  # # [3, 4]]
857
857
  #
858
- # p x.repeat(2)
859
- # # Cumo::Int32#shape=[8]
858
+ # x.repeat(2)
859
+ # # => Cumo::Int32#shape=[8]
860
860
  # # [1, 1, 2, 2, 3, 3, 4, 4]
861
861
  #
862
- # p x.repeat(3,axis:1)
863
- # # Cumo::Int32#shape=[2,6]
862
+ # x.repeat(3,axis:1)
863
+ # # => Cumo::Int32#shape=[2,6]
864
864
  # # [[1, 1, 1, 2, 2, 2],
865
865
  # # [3, 3, 3, 4, 4, 4]]
866
866
  #
867
- # p x.repeat([1,2],axis:0)
868
- # # Cumo::Int32#shape=[3,2]
867
+ # x.repeat([1,2],axis:0)
868
+ # # => Cumo::Int32#shape=[3,2]
869
869
  # # [[1, 2],
870
870
  # # [3, 4],
871
871
  # # [3, 4]]
@@ -906,30 +906,30 @@ module Cumo
906
906
 
907
907
  # Calculate the n-th discrete difference along given axis.
908
908
  # @example
909
- # p x = Cumo::DFloat[1, 2, 4, 7, 0]
910
- # # Cumo::DFloat#shape=[5]
909
+ # x = Cumo::DFloat[1, 2, 4, 7, 0]
910
+ # # => Cumo::DFloat#shape=[5]
911
911
  # # [1, 2, 4, 7, 0]
912
912
  #
913
- # p x.diff
914
- # # Cumo::DFloat#shape=[4]
913
+ # x.diff
914
+ # # => Cumo::DFloat#shape=[4]
915
915
  # # [1, 2, 3, -7]
916
916
  #
917
- # p x.diff(2)
918
- # # Cumo::DFloat#shape=[3]
917
+ # x.diff(2)
918
+ # # => Cumo::DFloat#shape=[3]
919
919
  # # [1, 1, -10]
920
920
  #
921
- # p x = Cumo::DFloat[[1, 3, 6, 10], [0, 5, 6, 8]]
922
- # # Cumo::DFloat#shape=[2,4]
921
+ # x = Cumo::DFloat[[1, 3, 6, 10], [0, 5, 6, 8]]
922
+ # # => Cumo::DFloat#shape=[2,4]
923
923
  # # [[1, 3, 6, 10],
924
924
  # # [0, 5, 6, 8]]
925
925
  #
926
- # p x.diff
927
- # # Cumo::DFloat#shape=[2,3]
926
+ # x.diff
927
+ # # => Cumo::DFloat#shape=[2,3]
928
928
  # # [[2, 3, 4],
929
929
  # # [5, 1, 2]]
930
930
  #
931
- # p x.diff(axis:0)
932
- # # Cumo::DFloat#shape=[1,4]
931
+ # x.diff(axis:0)
932
+ # # => Cumo::DFloat#shape=[1,4]
933
933
  # # [[-1, 2, 0, -2]]
934
934
 
935
935
  def diff(n=1, axis:-1)
@@ -1153,18 +1153,20 @@ module Cumo
1153
1153
  # @return [Cumo::NArray] return outer product
1154
1154
  # @example
1155
1155
  # a = Cumo::DFloat.ones(5)
1156
- # => Cumo::DFloat#shape=[5]
1157
- # [1, 1, 1, 1, 1]
1156
+ # # => Cumo::DFloat#shape=[5]
1157
+ # # [1, 1, 1, 1, 1]
1158
+ #
1158
1159
  # b = Cumo::DFloat.linspace(-2,2,5)
1159
- # => Cumo::DFloat#shape=[5]
1160
- # [-2, -1, 0, 1, 2]
1160
+ # # => Cumo::DFloat#shape=[5]
1161
+ # # [-2, -1, 0, 1, 2]
1162
+ #
1161
1163
  # a.outer(b)
1162
- # => Cumo::DFloat#shape=[5,5]
1163
- # [[-2, -1, 0, 1, 2],
1164
- # [-2, -1, 0, 1, 2],
1165
- # [-2, -1, 0, 1, 2],
1166
- # [-2, -1, 0, 1, 2],
1167
- # [-2, -1, 0, 1, 2]]
1164
+ # # => Cumo::DFloat#shape=[5,5]
1165
+ # # [[-2, -1, 0, 1, 2],
1166
+ # # [-2, -1, 0, 1, 2],
1167
+ # # [-2, -1, 0, 1, 2],
1168
+ # # [-2, -1, 0, 1, 2],
1169
+ # # [-2, -1, 0, 1, 2]]
1168
1170
 
1169
1171
  def outer(b, axis:nil)
1170
1172
  b = NArray.cast(b)
@@ -1193,17 +1195,19 @@ module Cumo
1193
1195
  # @return [Cumo::NArray] return Kronecker product
1194
1196
  # @example
1195
1197
  # Cumo::DFloat[1,10,100].kron([5,6,7])
1196
- # => Cumo::DFloat#shape=[9]
1197
- # [5, 6, 7, 50, 60, 70, 500, 600, 700]
1198
+ # # => Cumo::DFloat#shape=[9]
1199
+ # # [5, 6, 7, 50, 60, 70, 500, 600, 700]
1200
+ #
1198
1201
  # Cumo::DFloat[5,6,7].kron([1,10,100])
1199
- # => Cumo::DFloat#shape=[9]
1200
- # [5, 50, 500, 6, 60, 600, 7, 70, 700]
1202
+ # # => Cumo::DFloat#shape=[9]
1203
+ # # [5, 50, 500, 6, 60, 600, 7, 70, 700]
1204
+ #
1201
1205
  # Cumo::DFloat.eye(2).kron(Cumo::DFloat.ones(2,2))
1202
- # => Cumo::DFloat#shape=[4,4]
1203
- # [[1, 1, 0, 0],
1204
- # [1, 1, 0, 0],
1205
- # [0, 0, 1, 1],
1206
- # [0, 0, 1, 1]]
1206
+ # # => Cumo::DFloat#shape=[4,4]
1207
+ # # [[1, 1, 0, 0],
1208
+ # # [1, 1, 0, 0],
1209
+ # # [0, 0, 1, 1],
1210
+ # # [0, 0, 1, 1]]
1207
1211
 
1208
1212
  def kron(b)
1209
1213
  b = NArray.cast(b)
@@ -24,7 +24,8 @@ module Cumo::CUDA
24
24
  end
25
25
 
26
26
  def test_compute_capability
27
- assert { Device.new.compute_capability.size == 2 }
27
+ capability = `nvidia-smi --query-gpu=compute_cap --format=csv,noheader`.strip
28
+ assert { Device.new.compute_capability == capability.delete('.') }
28
29
  end
29
30
  end
30
31
  end
data/test/cudnn_test.rb CHANGED
@@ -255,7 +255,7 @@ class CUDNNTest < Test::Unit::TestCase
255
255
  test "x.batch_norm(gamma, beta) #{dtype}" do
256
256
  y = @x.batch_norm(@gamma, @beta)
257
257
  assert { y.shape == @x_shape }
258
- assert { y == dtype.ones(*@x_shape) }
258
+ assert_in_delta(y, dtype.ones(*@x_shape), 1e-3)
259
259
  end
260
260
 
261
261
  test "x.batch_norm(gamma, beta, axis: [0]) #{dtype}" do
@@ -275,7 +275,7 @@ class CUDNNTest < Test::Unit::TestCase
275
275
  running_var = dtype.ones(*@reduced_shape)
276
276
  y = @x.batch_norm(@gamma, @beta, running_mean: running_mean, running_var: running_var)
277
277
  assert { y.shape == @x_shape }
278
- assert { y == dtype.ones(*@x_shape) }
278
+ assert_in_delta(y, dtype.ones(*@x_shape), 1e-3)
279
279
  end
280
280
 
281
281
  test "x.batch_norm(gamma, beta, mean, inv_std) #{dtype}" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cumo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
@@ -35,6 +35,7 @@ files:
35
35
  - 3rd_party/mkmf-cu/test/test_mkmf-cu.rb
36
36
  - CHANGELOG.md
37
37
  - CODE_OF_CONDUCT.md
38
+ - Dockerfile
38
39
  - Gemfile
39
40
  - LICENSE.txt
40
41
  - README.md
@@ -46,6 +47,8 @@ files:
46
47
  - bin/console
47
48
  - bin/setup
48
49
  - cumo.gemspec
50
+ - docker-build.sh
51
+ - docker-launch.sh
49
52
  - docs/src-tree.md
50
53
  - ext/cumo/cuda/cublas.c
51
54
  - ext/cumo/cuda/cudnn.c
@@ -328,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
331
  - !ruby/object:Gem::Version
329
332
  version: '0'
330
333
  requirements: []
331
- rubygems_version: 3.7.2
334
+ rubygems_version: 3.6.9
332
335
  specification_version: 4
333
336
  summary: Cumo is CUDA aware numerical library whose interface is highly compatible
334
337
  with Ruby Numo