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
@@ -1,41 +1,29 @@
1
1
  /*
2
- Array element(s) set.
2
+ Array element(s) assignment.
3
3
  @overload []=(dim0,..,dimL,val)
4
- @param [Numeric,Range,etc] dim0,..,dimL Multi-dimensional Index.
4
+ @param [Numeric,Range,Array,Cumo::Bit,Cumo::Int32,Cumo::Int64] dim0,..,dimL Multi-dimensional Index.
5
5
  @param [Numeric,Cumo::NArray,etc] val Value(s) to be set to self.
6
- @return [Numeric] returns val (last argument).
6
+ @return [Numeric] returns `val` (last argument).
7
7
 
8
- --- Replace element(s) at +dim0+, +dim1+, ... (index/range/array/true
9
- for each dimention). Broadcasting mechanism is applied.
8
+ Replaces element(s) at `dim0`, `dim1`, ... . Broadcasting mechanism is applied.
10
9
 
11
- @example
12
- a = Cumo::DFloat.new(3,4).seq
13
- => Cumo::DFloat#shape=[3,4]
14
- [[0, 1, 2, 3],
15
- [4, 5, 6, 7],
16
- [8, 9, 10, 11]]
17
-
18
- a[1,2]=99
19
- a
20
- => Cumo::DFloat#shape=[3,4]
21
- [[0, 1, 2, 3],
22
- [4, 5, 99, 7],
23
- [8, 9, 10, 11]]
10
+ @see #[]
24
11
 
25
- a[1,[0,2]] = [101,102]
26
- a
27
- => Cumo::DFloat#shape=[3,4]
28
- [[0, 1, 2, 3],
29
- [101, 5, 102, 7],
30
- [8, 9, 10, 11]]
12
+ @example
13
+ a = Cumo::Bit.new(4,5).fill(0)
14
+ # => Cumo::Bit#shape=[4,5]
15
+ # [[0, 0, 0, 0, 0],
16
+ # [0, 0, 0, 0, 0],
17
+ # [0, 0, 0, 0, 0],
18
+ # [0, 0, 0, 0, 0]]
31
19
 
32
- a[1,true]=99
20
+ a[(0..-1)%2,(1..-1)%2] = 1
33
21
  a
34
- => Cumo::DFloat#shape=[3,4]
35
- [[0, 1, 2, 3],
36
- [99, 99, 99, 99],
37
- [8, 9, 10, 11]]
38
-
22
+ # => Cumo::Bit#shape=[4,5]
23
+ # [[0, 1, 0, 1, 0],
24
+ # [0, 0, 0, 0, 0],
25
+ # [0, 1, 0, 1, 0],
26
+ # [0, 0, 0, 0, 0]]
39
27
  */
40
28
  static VALUE
41
29
  <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
@@ -799,7 +799,7 @@ VALUE cumo_na_aref_md_protected(VALUE data_value)
799
799
  int keep_dim = data->keep_dim;
800
800
  int at_mode = data->at_mode;
801
801
 
802
- int ndim_new;
802
+ size_t ndim_new;
803
803
  VALUE view;
804
804
  cumo_narray_view_t *na2;
805
805
  ssize_t elmsz;
@@ -324,19 +324,19 @@ cumo_na_setup(VALUE self, int ndim, size_t *shape)
324
324
 
325
325
  @example
326
326
  i = Cumo::Int64.new([2,4,3])
327
- #=> Cumo::Int64#shape=[2,4,3](empty)
327
+ # => Cumo::Int64#shape=[2,4,3](empty)
328
328
 
329
329
  f = Cumo::DFloat.new(3,4)
330
- #=> Cumo::DFloat#shape=[3,4](empty)
330
+ # => Cumo::DFloat#shape=[3,4](empty)
331
331
 
332
332
  f.fill(2)
333
- #=> Cumo::DFloat#shape=[3,4]
333
+ # => Cumo::DFloat#shape=[3,4]
334
334
  # [[2, 2, 2, 2],
335
335
  # [2, 2, 2, 2],
336
336
  # [2, 2, 2, 2]]
337
337
 
338
338
  x = Cumo::NArray.new(5)
339
- #=> in `new': allocator undefined for Cumo::NArray (TypeError)
339
+ # => in `new': allocator undefined for Cumo::NArray (TypeError)
340
340
  # from t.rb:9:in `<main>'
341
341
 
342
342
  */
@@ -420,10 +420,10 @@ cumo_na_initialize_copy(VALUE self, VALUE orig)
420
420
  * but for typed NArray subclasses, e.g., DFloat, Int64.
421
421
  * @example
422
422
  * a = Cumo::DFloat.zeros(3,5)
423
- * => Cumo::DFloat#shape=[3,5]
424
- * [[0, 0, 0, 0, 0],
425
- * [0, 0, 0, 0, 0],
426
- * [0, 0, 0, 0, 0]]
423
+ * # => Cumo::DFloat#shape=[3,5]
424
+ * # [[0, 0, 0, 0, 0],
425
+ * # [0, 0, 0, 0, 0],
426
+ * # [0, 0, 0, 0, 0]]
427
427
  */
428
428
  static VALUE
429
429
  cumo_na_s_zeros(int argc, VALUE *argv, VALUE klass)
@@ -471,8 +471,8 @@ cumo_na_s_ones(int argc, VALUE *argv, VALUE klass)
471
471
 
472
472
  @example
473
473
  a = Cumo::DFloat.linspace(-5,5,7)
474
- => Cumo::DFloat#shape=[7]
475
- [-5, -3.33333, -1.66667, 0, 1.66667, 3.33333, 5]
474
+ # => Cumo::DFloat#shape=[7]
475
+ # [-5, -3.33333, -1.66667, 0, 1.66667, 3.33333, 5]
476
476
  */
477
477
  static VALUE
478
478
  cumo_na_s_linspace(int argc, VALUE *argv, VALUE klass)
@@ -510,11 +510,12 @@ cumo_na_s_linspace(int argc, VALUE *argv, VALUE klass)
510
510
 
511
511
  @example
512
512
  Cumo::DFloat.logspace(4,0,5,2)
513
- => Cumo::DFloat#shape=[5]
514
- [16, 8, 4, 2, 1]
513
+ # => Cumo::DFloat#shape=[5]
514
+ # [16, 8, 4, 2, 1]
515
+
515
516
  Cumo::DComplex.logspace(0,1i*Math::PI,5,Math::E)
516
- => Cumo::DComplex#shape=[5]
517
- [1+4.44659e-323i, 0.707107+0.707107i, 6.12323e-17+1i, -0.707107+0.707107i, ...]
517
+ # => Cumo::DComplex#shape=[5]
518
+ # [1+4.44659e-323i, 0.707107+0.707107i, 6.12323e-17+1i, -0.707107+0.707107i, ...]
518
519
  */
519
520
  static VALUE
520
521
  cumo_na_s_logspace(int argc, VALUE *argv, VALUE klass)
@@ -548,10 +549,10 @@ cumo_na_s_logspace(int argc, VALUE *argv, VALUE klass)
548
549
  @return [Cumo::NArray] created NArray.
549
550
  @example
550
551
  a = Cumo::DFloat.eye(3)
551
- => Cumo::DFloat#shape=[3,3]
552
- [[1, 0, 0],
553
- [0, 1, 0],
554
- [0, 0, 1]]
552
+ # => Cumo::DFloat#shape=[3,3]
553
+ # [[1, 0, 0],
554
+ # [0, 1, 0],
555
+ # [0, 0, 1]]
555
556
  */
556
557
  static VALUE
557
558
  cumo_na_s_eye(int argc, VALUE *argv, VALUE klass)