menoh 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffe56775dcbde74f64fdeed4fa59bf6fcc539803
4
- data.tar.gz: cc676fe5e5d2f2a2e591125fc6dcdfc9c4054962
3
+ metadata.gz: b5e483ff5c77e451a7e6384898da3460c098a098
4
+ data.tar.gz: 5277658d6ba5c471a6aee27c3c78afd0c6967018
5
5
  SHA512:
6
- metadata.gz: 6b1fb84c56bf469d76f97c86e0a0b0b0a832f146ff3ca52224d4983c429720c6dcb3c0191ca87fc1fb925234ea2d04bda2960a280265e52b7d790e270d73df4d
7
- data.tar.gz: 62f09585697c3d536d55fef32f0477b289cb0593786e97ae7820759b87fc749d72446d8434abf23550c626e5737fc5e999c4375a4fa46807c31d85ddeeea3b14
6
+ metadata.gz: 5c230e3d4524c1568c9e50be0fc6043a6ddc7f8d92b55db353e16a86dc69734d3d6e589ca023e62575620c60ccddfa25cfd8b06c90d4ba61ac55f9d4d1267072
7
+ data.tar.gz: a3849a57262ac65c9df11cd0faaa598bcb3926588546f2b27bd1a8546bfe5a1d09c24135b5f4fec70974f1f71d15bd51e5cfe1bafc3997d38fbd8bc7943b95b6
data/README.md CHANGED
@@ -77,4 +77,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
77
77
 
78
78
  ## Code of Conduct
79
79
 
80
- Everyone interacting in the OnnxInstant project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pfnet-research/menoh-ruby/blob/master/CODE_OF_CONDUCT.md).
80
+ Everyone interacting in the Menoh Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pfnet-research/menoh-ruby/blob/master/CODE_OF_CONDUCT.md).
@@ -45,8 +45,8 @@ model_opt = {
45
45
  dims: [
46
46
  image_list.length,
47
47
  input_shape[:channel_num],
48
+ input_shape[:height],
48
49
  input_shape[:width],
49
- input_shape[:height]
50
50
  ]
51
51
  }
52
52
  ],
@@ -36,8 +36,8 @@ model_opt = {
36
36
  dims: [
37
37
  image_list.length,
38
38
  input_shape[:channel_num],
39
+ input_shape[:height],
39
40
  input_shape[:width],
40
- input_shape[:height]
41
41
  ]
42
42
  }
43
43
  ],
@@ -33,8 +33,8 @@ model_opt = {
33
33
  dims: [
34
34
  image_list.length,
35
35
  input_shape[:channel_num],
36
+ input_shape[:height],
36
37
  input_shape[:width],
37
- input_shape[:height]
38
38
  ]
39
39
  }
40
40
  ],
@@ -1,7 +1,7 @@
1
1
  require 'open-uri'
2
2
  require 'rmagick'
3
3
  require 'menoh'
4
- # TODO revise api
4
+
5
5
  # download dependencies
6
6
  def download_file(url, output)
7
7
  return if File.exist? output
@@ -45,8 +45,8 @@ model_opt = {
45
45
  dims: [
46
46
  image_list.length,
47
47
  input_shape[:channel_num],
48
+ input_shape[:height],
48
49
  input_shape[:width],
49
- input_shape[:height]
50
50
  ]
51
51
  }
52
52
  ],
@@ -164,57 +164,57 @@ static VALUE wrap_model_init(VALUE self, VALUE vonnx, VALUE option) {
164
164
  rb_raise(rb_eStandardError, "invalid dimension length");
165
165
  return Qnil;
166
166
  }
167
+ }
167
168
 
168
- // build variable provile table
169
- ERROR_CHECK(menoh_build_variable_profile_table(
170
- getModel(self)->vpt_builder, getModel(self)->model_data,
171
- &(getModel(self)->variable_profile_table)),
172
- rb_eStandardError);
169
+ // build variable provile table
170
+ ERROR_CHECK(menoh_build_variable_profile_table(
171
+ getModel(self)->vpt_builder, getModel(self)->model_data,
172
+ &(getModel(self)->variable_profile_table)),
173
+ rb_eStandardError);
173
174
 
174
- // optimize
175
- ERROR_CHECK(
176
- menoh_model_data_optimize(getModel(self)->model_data,
177
- getModel(self)->variable_profile_table),
178
- rb_eStandardError);
175
+ // optimize
176
+ ERROR_CHECK(
177
+ menoh_model_data_optimize(getModel(self)->model_data,
178
+ getModel(self)->variable_profile_table),
179
+ rb_eStandardError);
179
180
 
180
- // get model buildler
181
- ERROR_CHECK(menoh_make_model_builder(getModel(self)->variable_profile_table,
182
- &(getModel(self)->model_builder)),
183
- rb_eStandardError);
181
+ // get model buildler
182
+ ERROR_CHECK(menoh_make_model_builder(getModel(self)->variable_profile_table,
183
+ &(getModel(self)->model_builder)),
184
+ rb_eStandardError);
184
185
 
185
- // attach input buffer to model builder
186
- getModel(self)->input_buffs =
187
- (float **)ruby_xmalloc(sizeof(float **) * input_layer_num);
188
- for (int32_t i = 0; i < input_layer_num; i++) {
189
- VALUE vinput_layer = rb_ary_entry(vinput_layers, i);
190
- VALUE vname =
191
- rb_hash_aref(vinput_layer, rb_to_symbol(rb_str_new2("name")));
192
- VALUE vdims =
193
- rb_hash_aref(vinput_layer, rb_to_symbol(rb_str_new2("dims")));
194
- int32_t dims_length =
195
- NUM2INT(rb_funcall(vdims, rb_intern("length"), 0, NULL));
196
-
197
- // prepare input buffer
198
- int32_t buffer_length = 1;
199
- for (int32_t j = 0; j < dims_length; j++)
200
- buffer_length *= NUM2INT(rb_ary_entry(vdims, j));
201
-
202
- float *input_buff = (float *)ruby_xmalloc(sizeof(float) * buffer_length);
203
- getModel(self)->input_buffs[i] = input_buff;
204
- ERROR_CHECK(
205
- menoh_model_builder_attach_external_buffer(
206
- getModel(self)->model_builder, StringValueCStr(vname), input_buff),
207
- rb_eStandardError);
208
- }
186
+ // attach input buffer to model builder
187
+ getModel(self)->input_buffs =
188
+ (float **)ruby_xmalloc(sizeof(float **) * input_layer_num);
189
+ for (int32_t i = 0; i < input_layer_num; i++) {
190
+ VALUE vinput_layer = rb_ary_entry(vinput_layers, i);
191
+ VALUE vname =
192
+ rb_hash_aref(vinput_layer, rb_to_symbol(rb_str_new2("name")));
193
+ VALUE vdims =
194
+ rb_hash_aref(vinput_layer, rb_to_symbol(rb_str_new2("dims")));
195
+ int32_t dims_length =
196
+ NUM2INT(rb_funcall(vdims, rb_intern("length"), 0, NULL));
209
197
 
210
- // build model
211
- ERROR_CHECK(menoh_build_model(
212
- getModel(self)->model_builder, getModel(self)->model_data,
213
- StringValueCStr(vbackend), "", &(getModel(self)->model)),
214
- rb_eStandardError);
198
+ // prepare input buffer
199
+ int32_t buffer_length = 1;
200
+ for (int32_t j = 0; j < dims_length; j++)
201
+ buffer_length *= NUM2INT(rb_ary_entry(vdims, j));
215
202
 
216
- return Qnil;
203
+ float *input_buff = (float *)ruby_xmalloc(sizeof(float) * buffer_length);
204
+ getModel(self)->input_buffs[i] = input_buff;
205
+ ERROR_CHECK(
206
+ menoh_model_builder_attach_external_buffer(
207
+ getModel(self)->model_builder, StringValueCStr(vname), input_buff),
208
+ rb_eStandardError);
217
209
  }
210
+
211
+ // build model
212
+ ERROR_CHECK(menoh_build_model(
213
+ getModel(self)->model_builder, getModel(self)->model_data,
214
+ StringValueCStr(vbackend), "", &(getModel(self)->model)),
215
+ rb_eStandardError);
216
+
217
+ return Qnil;
218
218
  }
219
219
 
220
220
  static VALUE wrap_model_run(VALUE self, VALUE dataset) {
@@ -1,7 +1,7 @@
1
- #ifndef RUNX_H
2
- #define RUNX_H 1
1
+ #ifndef MENOH_H
2
+ #define MENOH_H 1
3
3
 
4
4
  #include <menoh/menoh.h>
5
5
  #include <ruby.h>
6
6
 
7
- #endif /* RUNX_H */
7
+ #endif /* MENOH_H */
@@ -4,35 +4,20 @@ require 'menoh/menoh_native'
4
4
  module Menoh
5
5
  class Menoh
6
6
  def initialize(file)
7
- if !File.exist?(file)
8
- raise "No such file : #{file}"
9
- end
7
+ raise "No such file : #{file}" unless File.exist?(file)
10
8
 
11
9
  native_init file
12
10
  yield self if block_given?
13
11
  end
14
12
 
15
13
  def make_model(option)
16
- if option[:backend].nil?
17
- raise "Required ':backend' : #{option[:backend]}"
18
- end
14
+ raise "Required ':backend' : #{option[:backend]}" if option[:backend].nil?
19
15
  model = MenohModel.new self, option
20
16
  yield model if block_given?
21
17
  model
22
18
  end
23
19
  end
24
- end
25
-
26
- def transpose(buffer, shape)
27
- sliced_buffer = buffer.each_slice(buffer.length / shape[0]).to_a
28
- if shape.length > 2
29
- next_shape = shape.slice(1, a.length)
30
- sliced_buffer = sliced_buffer.map { |buf| transpose buf, next_shape }
31
- end
32
- sliced_buffer
33
- end
34
20
 
35
- module Menoh
36
21
  class MenohModel
37
22
  def initialize(menoh, option)
38
23
  if option[:input_layers].nil? || option[:input_layers].empty?
@@ -77,11 +62,22 @@ module Menoh
77
62
  results.map do |raw|
78
63
  buffer = raw[:data]
79
64
  shape = raw[:shape]
80
- raw[:data] = transpose buffer, shape
65
+ raw[:data] = Util.reshape buffer, shape
81
66
  end
82
67
 
83
68
  yield results if block_given?
84
69
  results
85
70
  end
86
71
  end
72
+
73
+ module Util
74
+ def self.reshape(buffer, shape)
75
+ sliced_buffer = buffer.each_slice(buffer.length / shape[0]).to_a
76
+ if shape.length > 2
77
+ next_shape = shape.slice(1, shape.length)
78
+ sliced_buffer = sliced_buffer.map { |buf| reshape buf, next_shape }
79
+ end
80
+ sliced_buffer
81
+ end
82
+ end
87
83
  end
@@ -1,3 +1,3 @@
1
1
  module Menoh
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'menoh'
7
7
  spec.version = Menoh::VERSION
8
8
  spec.authors = ['Kunihiko MIYOSHI']
9
- spec.email = ['miyoshik@preferred.jp']
9
+ spec.email = ['menoh-oss@preferred.jp']
10
10
 
11
11
  spec.summary = "Ruby binding of ONNX runtime engine 'Menoh'"
12
12
  spec.description = "Ruby binding of ONNX runtime engine 'Menoh'"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: menoh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kunihiko MIYOSHI
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2018-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '0'
83
83
  description: Ruby binding of ONNX runtime engine 'Menoh'
84
84
  email:
85
- - miyoshik@preferred.jp
85
+ - menoh-oss@preferred.jp
86
86
  executables: []
87
87
  extensions:
88
88
  - ext/menoh_native/extconf.rb