cumo 0.2.5 → 0.3.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +12 -1
- data/cumo.gemspec +1 -1
- data/ext/cumo/cuda/cudnn.c +80 -0
- data/ext/cumo/cuda/cudnn_impl.cpp +572 -0
- data/ext/cumo/cuda/runtime.c +1 -0
- data/ext/cumo/cumo.c +5 -0
- data/ext/cumo/extconf.rb +8 -2
- data/ext/cumo/include/cumo.h +2 -2
- data/ext/cumo/include/cumo/cuda/cudnn.h +205 -0
- data/ext/cumo/include/cumo/hash_combine.hpp +17 -0
- data/ext/cumo/include/cumo/intern.h +5 -0
- data/ext/cumo/include/cumo/types/dfloat.h +1 -0
- data/ext/cumo/include/cumo/types/sfloat.h +1 -0
- data/ext/cumo/narray/gen/spec.rb +21 -0
- data/ext/cumo/narray/gen/tmpl/batch_norm.c +197 -0
- data/ext/cumo/narray/gen/tmpl/batch_norm_backward.c +191 -0
- data/ext/cumo/narray/gen/tmpl/conv.c +216 -0
- data/ext/cumo/narray/gen/tmpl/conv_grad_w.c +183 -0
- data/ext/cumo/narray/gen/tmpl/conv_transpose.c +244 -0
- data/ext/cumo/narray/gen/tmpl/gemm.c +14 -0
- data/ext/cumo/narray/gen/tmpl/pooling_backward.c +136 -0
- data/ext/cumo/narray/gen/tmpl/pooling_forward.c +136 -0
- data/ext/cumo/narray/narray.c +29 -0
- data/lib/cumo/cuda.rb +1 -0
- data/lib/cumo/cuda/cudnn.rb +88 -0
- metadata +18 -5
data/ext/cumo/narray/narray.c
CHANGED
@@ -769,6 +769,29 @@ cumo_na_get_offset(VALUE self)
|
|
769
769
|
return 0;
|
770
770
|
}
|
771
771
|
|
772
|
+
char*
|
773
|
+
cumo_na_get_offset_pointer(VALUE a)
|
774
|
+
{
|
775
|
+
return cumo_na_get_pointer(a) + cumo_na_get_offset(a);
|
776
|
+
}
|
777
|
+
|
778
|
+
char*
|
779
|
+
cumo_na_get_offset_pointer_for_write(VALUE a)
|
780
|
+
{
|
781
|
+
return cumo_na_get_pointer_for_write(a) + cumo_na_get_offset(a);
|
782
|
+
}
|
783
|
+
|
784
|
+
char*
|
785
|
+
cumo_na_get_offset_pointer_for_read(VALUE a)
|
786
|
+
{
|
787
|
+
return cumo_na_get_pointer_for_read(a) + cumo_na_get_offset(a);
|
788
|
+
}
|
789
|
+
|
790
|
+
char*
|
791
|
+
cumo_na_get_offset_pointer_for_read_write(VALUE a)
|
792
|
+
{
|
793
|
+
return cumo_na_get_pointer_for_read_write(a) + cumo_na_get_offset(a);
|
794
|
+
}
|
772
795
|
|
773
796
|
void
|
774
797
|
cumo_na_index_arg_to_internal_order(int argc, VALUE *argv, VALUE self)
|
@@ -866,6 +889,12 @@ cumo_na_check_contiguous(VALUE self)
|
|
866
889
|
return Qfalse;
|
867
890
|
}
|
868
891
|
|
892
|
+
VALUE
|
893
|
+
cumo_na_as_contiguous_array(VALUE a)
|
894
|
+
{
|
895
|
+
return cumo_na_check_contiguous(a) == Qtrue ? a : rb_funcall(a, rb_intern("dup"), 0);
|
896
|
+
}
|
897
|
+
|
869
898
|
//----------------------------------------------------------------------
|
870
899
|
|
871
900
|
/*
|
data/lib/cumo/cuda.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'cumo'
|
2
|
+
|
3
|
+
module Cumo
|
4
|
+
[SFloat, DFloat].each do |klass|
|
5
|
+
klass.class_eval do
|
6
|
+
alias_method :conv_backward_data, :conv_transpose
|
7
|
+
alias_method :conv_backward_filter, :conv_grad_w
|
8
|
+
|
9
|
+
def max_pool(*args, **kwargs)
|
10
|
+
self.pooling_forward(Cumo::CUDA::CUDNN::CUDNN_POOLING_MAX, *args, **kwargs)
|
11
|
+
end
|
12
|
+
|
13
|
+
def max_pool_backward(*args, **kwargs)
|
14
|
+
self.pooling_backward(Cumo::CUDA::CUDNN::CUDNN_POOLING_MAX, *args, **kwargs)
|
15
|
+
end
|
16
|
+
|
17
|
+
def avg_pool(*args, **kwargs)
|
18
|
+
pad_value = kwargs.delete(:pad_value)
|
19
|
+
if pad_value == 0
|
20
|
+
mode = Cumo::CUDA::CUDNN::CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING
|
21
|
+
elsif pad_value.nil?
|
22
|
+
mode = Cumo::CUDA::CUDNN::CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING
|
23
|
+
else
|
24
|
+
raise "pad_value: #{pad_value} is not supported"
|
25
|
+
end
|
26
|
+
self.pooling_forward(mode, *args, **kwargs)
|
27
|
+
end
|
28
|
+
|
29
|
+
def avg_pool_backward(*args, **kwargs)
|
30
|
+
pad_value = kwargs.delete(:pad_value)
|
31
|
+
if pad_value == 0
|
32
|
+
mode = Cumo::CUDA::CUDNN::CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING
|
33
|
+
elsif pad_value.nil?
|
34
|
+
mode = Cumo::CUDA::CUDNN::CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING
|
35
|
+
else
|
36
|
+
raise "pad_value: #{pad_value} is not supported"
|
37
|
+
end
|
38
|
+
self.pooling_backward(mode, *args, **kwargs)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module Cumo
|
45
|
+
module CUDA
|
46
|
+
module CUDNN
|
47
|
+
class << self
|
48
|
+
def conv(a, *args, **kwargs)
|
49
|
+
a.conv(*args, **kwargs)
|
50
|
+
end
|
51
|
+
|
52
|
+
def conv_transpose(a, *args, **kwargs)
|
53
|
+
a.conv_transpose(*args, **kwargs)
|
54
|
+
end
|
55
|
+
alias_method :conv_backward_data, :conv_transpose
|
56
|
+
|
57
|
+
def conv_grad_w(a, *args, **kwargs)
|
58
|
+
a.conv_grad_w(*args, **kwargs)
|
59
|
+
end
|
60
|
+
alias_method :conv_backward_filter, :conv_grad_w
|
61
|
+
|
62
|
+
def batch_norm(a, *args, **kwargs)
|
63
|
+
a.batch_norm(*args, **kwargs)
|
64
|
+
end
|
65
|
+
|
66
|
+
def batch_norm_backward(a, *args, **kwargs)
|
67
|
+
a.batch_norm_backward(*args, **kwargs)
|
68
|
+
end
|
69
|
+
|
70
|
+
def max_pool(a, *args, **kwargs)
|
71
|
+
a.max_pool(*args, **kwargs)
|
72
|
+
end
|
73
|
+
|
74
|
+
def max_pool_backward(a, *args, **kwargs)
|
75
|
+
a.max_pool_backward(*args, **kwargs)
|
76
|
+
end
|
77
|
+
|
78
|
+
def avg_pool(a, *args, **kwargs)
|
79
|
+
a.avg_pool(*args, **kwargs)
|
80
|
+
end
|
81
|
+
|
82
|
+
def avg_pool_backward(a, *args, **kwargs)
|
83
|
+
a.avg_pool_backward(*args, **kwargs)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cumo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -90,6 +90,8 @@ files:
|
|
90
90
|
- cumo.gemspec
|
91
91
|
- docs/src-tree.md
|
92
92
|
- ext/cumo/cuda/cublas.c
|
93
|
+
- ext/cumo/cuda/cudnn.c
|
94
|
+
- ext/cumo/cuda/cudnn_impl.cpp
|
93
95
|
- ext/cumo/cuda/driver.c
|
94
96
|
- ext/cumo/cuda/memory_pool.cpp
|
95
97
|
- ext/cumo/cuda/memory_pool_impl.cpp
|
@@ -103,12 +105,14 @@ files:
|
|
103
105
|
- ext/cumo/include/cumo.h
|
104
106
|
- ext/cumo/include/cumo/compat.h
|
105
107
|
- ext/cumo/include/cumo/cuda/cublas.h
|
108
|
+
- ext/cumo/include/cumo/cuda/cudnn.h
|
106
109
|
- ext/cumo/include/cumo/cuda/cumo_thrust.hpp
|
107
110
|
- ext/cumo/include/cumo/cuda/cumo_thrust_complex.hpp
|
108
111
|
- ext/cumo/include/cumo/cuda/driver.h
|
109
112
|
- ext/cumo/include/cumo/cuda/memory_pool.h
|
110
113
|
- ext/cumo/include/cumo/cuda/nvrtc.h
|
111
114
|
- ext/cumo/include/cumo/cuda/runtime.h
|
115
|
+
- ext/cumo/include/cumo/hash_combine.hpp
|
112
116
|
- ext/cumo/include/cumo/indexer.h
|
113
117
|
- ext/cumo/include/cumo/intern.h
|
114
118
|
- ext/cumo/include/cumo/intern_kernel.h
|
@@ -202,6 +206,8 @@ files:
|
|
202
206
|
- ext/cumo/narray/gen/tmpl/aref.c
|
203
207
|
- ext/cumo/narray/gen/tmpl/aref_cpu.c
|
204
208
|
- ext/cumo/narray/gen/tmpl/aset.c
|
209
|
+
- ext/cumo/narray/gen/tmpl/batch_norm.c
|
210
|
+
- ext/cumo/narray/gen/tmpl/batch_norm_backward.c
|
205
211
|
- ext/cumo/narray/gen/tmpl/binary.c
|
206
212
|
- ext/cumo/narray/gen/tmpl/binary2.c
|
207
213
|
- ext/cumo/narray/gen/tmpl/binary2_kernel.cu
|
@@ -219,6 +225,9 @@ files:
|
|
219
225
|
- ext/cumo/narray/gen/tmpl/cond_binary.c
|
220
226
|
- ext/cumo/narray/gen/tmpl/cond_binary_kernel.cu
|
221
227
|
- ext/cumo/narray/gen/tmpl/cond_unary.c
|
228
|
+
- ext/cumo/narray/gen/tmpl/conv.c
|
229
|
+
- ext/cumo/narray/gen/tmpl/conv_grad_w.c
|
230
|
+
- ext/cumo/narray/gen/tmpl/conv_transpose.c
|
222
231
|
- ext/cumo/narray/gen/tmpl/cum.c
|
223
232
|
- ext/cumo/narray/gen/tmpl/each.c
|
224
233
|
- ext/cumo/narray/gen/tmpl/each_with_index.c
|
@@ -251,6 +260,8 @@ files:
|
|
251
260
|
- ext/cumo/narray/gen/tmpl/new_dim0.c
|
252
261
|
- ext/cumo/narray/gen/tmpl/new_dim0_kernel.cu
|
253
262
|
- ext/cumo/narray/gen/tmpl/poly.c
|
263
|
+
- ext/cumo/narray/gen/tmpl/pooling_backward.c
|
264
|
+
- ext/cumo/narray/gen/tmpl/pooling_forward.c
|
254
265
|
- ext/cumo/narray/gen/tmpl/pow.c
|
255
266
|
- ext/cumo/narray/gen/tmpl/pow_kernel.cu
|
256
267
|
- ext/cumo/narray/gen/tmpl/powint.c
|
@@ -319,6 +330,7 @@ files:
|
|
319
330
|
- lib/cumo/cuda.rb
|
320
331
|
- lib/cumo/cuda/compile_error.rb
|
321
332
|
- lib/cumo/cuda/compiler.rb
|
333
|
+
- lib/cumo/cuda/cudnn.rb
|
322
334
|
- lib/cumo/cuda/device.rb
|
323
335
|
- lib/cumo/cuda/link_state.rb
|
324
336
|
- lib/cumo/cuda/module.rb
|
@@ -343,11 +355,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
343
355
|
version: '0'
|
344
356
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
345
357
|
requirements:
|
346
|
-
- - "
|
358
|
+
- - ">"
|
347
359
|
- !ruby/object:Gem::Version
|
348
|
-
version:
|
360
|
+
version: 1.3.1
|
349
361
|
requirements: []
|
350
|
-
|
362
|
+
rubyforge_project:
|
363
|
+
rubygems_version: 2.7.6
|
351
364
|
signing_key:
|
352
365
|
specification_version: 4
|
353
366
|
summary: Cumo is CUDA aware numerical library whose interface is highly compatible
|