onnxruntime 0.10.1 → 0.10.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/lib/onnxruntime/inference_session.rb +32 -33
- data/lib/onnxruntime/ort_value.rb +7 -4
- data/lib/onnxruntime/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d929830bb6473f4e066f2beae78ca73d5db2d09ac0d3407c4a580bb076d76b36
|
|
4
|
+
data.tar.gz: 9bfdc0dd3eade96a7aef4526021425596247c8a6f9892dceb12d7347d7b8c269
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3135a375840cfe5937428dc40476bb2773edb6b6781d90545a1e9470bf5c639aac44c3a4de8a83b748ed911bad5ef8a5d9b749d4d922a1e77fe70f2b49ec3274
|
|
7
|
+
data.tar.gz: a83b4a77293cd19633da8c21147bc37ca1135ae9403aa76a28b5574168447adccde021f38aec17ea951a846bd4369459eabe77584460361f0a8ad1031bd1cf64
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) Microsoft Corporation
|
|
4
|
-
Copyright (c) 2019-
|
|
4
|
+
Copyright (c) 2019-2026 Andrew Kane
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -3,6 +3,9 @@ module OnnxRuntime
|
|
|
3
3
|
attr_reader :inputs, :outputs
|
|
4
4
|
|
|
5
5
|
def initialize(path_or_bytes, enable_cpu_mem_arena: true, enable_mem_pattern: true, enable_profiling: false, execution_mode: nil, free_dimension_overrides_by_denotation: nil, free_dimension_overrides_by_name: nil, graph_optimization_level: nil, inter_op_num_threads: nil, intra_op_num_threads: nil, log_severity_level: nil, log_verbosity_level: nil, logid: nil, optimized_model_filepath: nil, profile_file_prefix: nil, session_config_entries: nil, providers: [])
|
|
6
|
+
# create environment first to prevent uncaught exception with CoreMLExecutionProvider
|
|
7
|
+
env
|
|
8
|
+
|
|
6
9
|
# session options
|
|
7
10
|
session_options = ::FFI::MemoryPointer.new(:pointer)
|
|
8
11
|
check_status api[:CreateSessionOptions].call(session_options)
|
|
@@ -137,65 +140,61 @@ module OnnxRuntime
|
|
|
137
140
|
keys = ::FFI::MemoryPointer.new(:pointer)
|
|
138
141
|
num_keys = ::FFI::MemoryPointer.new(:int64_t)
|
|
139
142
|
check_status api[:ModelMetadataGetCustomMetadataMapKeys].call(metadata, @allocator, keys, num_keys)
|
|
140
|
-
keys = keys.read_pointer
|
|
143
|
+
keys = ::FFI::AutoPointer.new(keys.read_pointer, method(:allocator_free))
|
|
144
|
+
key_ptrs =
|
|
145
|
+
keys.read_array_of_pointer(num_keys.read(:int64_t)).map do |ptr|
|
|
146
|
+
::FFI::AutoPointer.new(ptr, method(:allocator_free))
|
|
147
|
+
end
|
|
141
148
|
|
|
142
149
|
custom_metadata_map = {}
|
|
143
|
-
|
|
144
|
-
key_ptr = keys.get_pointer(i * ::FFI::Pointer.size)
|
|
150
|
+
key_ptrs.each do |key_ptr|
|
|
145
151
|
key = key_ptr.read_string
|
|
146
152
|
value = ::FFI::MemoryPointer.new(:pointer)
|
|
147
153
|
check_status api[:ModelMetadataLookupCustomMetadataMap].call(metadata, @allocator, key, value)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
allocator_free key_ptr
|
|
151
|
-
allocator_free value.read_pointer
|
|
154
|
+
value = ::FFI::AutoPointer.new(value.read_pointer, method(:allocator_free))
|
|
155
|
+
custom_metadata_map[key] = value.read_string
|
|
152
156
|
end
|
|
153
157
|
|
|
154
158
|
description = ::FFI::MemoryPointer.new(:pointer)
|
|
155
159
|
check_status api[:ModelMetadataGetDescription].call(metadata, @allocator, description)
|
|
160
|
+
description = ::FFI::AutoPointer.new(description.read_pointer, method(:allocator_free))
|
|
156
161
|
|
|
157
162
|
domain = ::FFI::MemoryPointer.new(:pointer)
|
|
158
163
|
check_status api[:ModelMetadataGetDomain].call(metadata, @allocator, domain)
|
|
164
|
+
domain = ::FFI::AutoPointer.new(domain.read_pointer, method(:allocator_free))
|
|
159
165
|
|
|
160
166
|
graph_name = ::FFI::MemoryPointer.new(:pointer)
|
|
161
167
|
check_status api[:ModelMetadataGetGraphName].call(metadata, @allocator, graph_name)
|
|
168
|
+
graph_name = ::FFI::AutoPointer.new(graph_name.read_pointer, method(:allocator_free))
|
|
162
169
|
|
|
163
170
|
graph_description = ::FFI::MemoryPointer.new(:pointer)
|
|
164
171
|
check_status api[:ModelMetadataGetGraphDescription].call(metadata, @allocator, graph_description)
|
|
172
|
+
graph_description = ::FFI::AutoPointer.new(graph_description.read_pointer, method(:allocator_free))
|
|
165
173
|
|
|
166
174
|
producer_name = ::FFI::MemoryPointer.new(:pointer)
|
|
167
175
|
check_status api[:ModelMetadataGetProducerName].call(metadata, @allocator, producer_name)
|
|
176
|
+
producer_name = ::FFI::AutoPointer.new(producer_name.read_pointer, method(:allocator_free))
|
|
168
177
|
|
|
169
178
|
version = ::FFI::MemoryPointer.new(:int64_t)
|
|
170
179
|
check_status api[:ModelMetadataGetVersion].call(metadata, version)
|
|
171
180
|
|
|
172
181
|
{
|
|
173
182
|
custom_metadata_map: custom_metadata_map,
|
|
174
|
-
description: description.
|
|
175
|
-
domain: domain.
|
|
176
|
-
graph_name: graph_name.
|
|
177
|
-
graph_description: graph_description.
|
|
178
|
-
producer_name: producer_name.
|
|
183
|
+
description: description.read_string,
|
|
184
|
+
domain: domain.read_string,
|
|
185
|
+
graph_name: graph_name.read_string,
|
|
186
|
+
graph_description: graph_description.read_string,
|
|
187
|
+
producer_name: producer_name.read_string,
|
|
179
188
|
version: version.read(:int64_t)
|
|
180
189
|
}
|
|
181
|
-
ensure
|
|
182
|
-
allocator_free keys
|
|
183
|
-
allocator_free description.read_pointer
|
|
184
|
-
allocator_free domain.read_pointer
|
|
185
|
-
allocator_free graph_name.read_pointer
|
|
186
|
-
allocator_free graph_description.read_pointer
|
|
187
|
-
allocator_free producer_name.read_pointer
|
|
188
190
|
end
|
|
189
191
|
|
|
190
192
|
# return value has double underscore like Python
|
|
191
193
|
def end_profiling
|
|
192
194
|
out = ::FFI::MemoryPointer.new(:pointer)
|
|
193
195
|
check_status api[:SessionEndProfiling].call(@session, @allocator, out)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
ensure
|
|
197
|
-
allocator_free out.read_pointer
|
|
198
|
-
end
|
|
196
|
+
out = ::FFI::AutoPointer.new(out.read_pointer, method(:allocator_free))
|
|
197
|
+
out.read_string
|
|
199
198
|
end
|
|
200
199
|
|
|
201
200
|
# no way to set providers with C API yet
|
|
@@ -205,9 +204,11 @@ module OnnxRuntime
|
|
|
205
204
|
length_ptr = ::FFI::MemoryPointer.new(:int)
|
|
206
205
|
check_status api[:GetAvailableProviders].call(out_ptr, length_ptr)
|
|
207
206
|
length = length_ptr.read_int
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
begin
|
|
208
|
+
out_ptr.read_pointer.read_array_of_pointer(length).map(&:read_string)
|
|
209
|
+
ensure
|
|
210
|
+
api[:ReleaseAvailableProviders].call(out_ptr.read_pointer, length)
|
|
211
|
+
end
|
|
211
212
|
end
|
|
212
213
|
|
|
213
214
|
private
|
|
@@ -238,14 +239,13 @@ module OnnxRuntime
|
|
|
238
239
|
num_input_nodes.read(:size_t).times.map do |i|
|
|
239
240
|
name_ptr = ::FFI::MemoryPointer.new(:pointer)
|
|
240
241
|
check_status api[:SessionGetInputName].call(@session, i, @allocator, name_ptr)
|
|
241
|
-
|
|
242
|
-
allocator_free name_ptr.read_pointer
|
|
242
|
+
name_ptr = ::FFI::AutoPointer.new(name_ptr.read_pointer, method(:allocator_free))
|
|
243
243
|
|
|
244
244
|
typeinfo = ::FFI::MemoryPointer.new(:pointer)
|
|
245
245
|
check_status api[:SessionGetInputTypeInfo].call(@session, i, typeinfo)
|
|
246
246
|
typeinfo = ::FFI::AutoPointer.new(typeinfo.read_pointer, api[:ReleaseTypeInfo])
|
|
247
247
|
|
|
248
|
-
{name:
|
|
248
|
+
{name: name_ptr.read_string}.merge(Utils.node_info(typeinfo))
|
|
249
249
|
end
|
|
250
250
|
end
|
|
251
251
|
|
|
@@ -256,14 +256,13 @@ module OnnxRuntime
|
|
|
256
256
|
num_output_nodes.read(:size_t).times.map do |i|
|
|
257
257
|
name_ptr = ::FFI::MemoryPointer.new(:pointer)
|
|
258
258
|
check_status api[:SessionGetOutputName].call(@session, i, @allocator, name_ptr)
|
|
259
|
-
|
|
260
|
-
allocator_free name_ptr.read_pointer
|
|
259
|
+
name_ptr = ::FFI::AutoPointer.new(name_ptr.read_pointer, method(:allocator_free))
|
|
261
260
|
|
|
262
261
|
typeinfo = ::FFI::MemoryPointer.new(:pointer)
|
|
263
262
|
check_status api[:SessionGetOutputTypeInfo].call(@session, i, typeinfo)
|
|
264
263
|
typeinfo = ::FFI::AutoPointer.new(typeinfo.read_pointer, api[:ReleaseTypeInfo])
|
|
265
264
|
|
|
266
|
-
{name:
|
|
265
|
+
{name: name_ptr.read_string}.merge(Utils.node_info(typeinfo))
|
|
267
266
|
end
|
|
268
267
|
end
|
|
269
268
|
|
|
@@ -200,17 +200,20 @@ module OnnxRuntime
|
|
|
200
200
|
out.read(:size_t).times.map do |i|
|
|
201
201
|
seq = ::FFI::MemoryPointer.new(:pointer)
|
|
202
202
|
Utils.check_status FFI.api[:GetValue].call(out_ptr, i, Utils.allocator, seq)
|
|
203
|
-
|
|
203
|
+
seq = ::FFI::AutoPointer.new(seq.read_pointer, FFI.api[:ReleaseValue])
|
|
204
|
+
create_from_onnx_value(seq, output_type)
|
|
204
205
|
end
|
|
205
206
|
when :map
|
|
206
207
|
map_keys = ::FFI::MemoryPointer.new(:pointer)
|
|
207
208
|
Utils.check_status FFI.api[:GetValue].call(out_ptr, 0, Utils.allocator, map_keys)
|
|
209
|
+
map_keys = ::FFI::AutoPointer.new(map_keys.read_pointer, FFI.api[:ReleaseValue])
|
|
208
210
|
|
|
209
211
|
map_values = ::FFI::MemoryPointer.new(:pointer)
|
|
210
212
|
Utils.check_status FFI.api[:GetValue].call(out_ptr, 1, Utils.allocator, map_values)
|
|
213
|
+
map_values = ::FFI::AutoPointer.new(map_values.read_pointer, FFI.api[:ReleaseValue])
|
|
211
214
|
|
|
212
215
|
type_shape = ::FFI::MemoryPointer.new(:pointer)
|
|
213
|
-
Utils.check_status FFI.api[:GetTensorTypeAndShape].call(map_keys
|
|
216
|
+
Utils.check_status FFI.api[:GetTensorTypeAndShape].call(map_keys, type_shape)
|
|
214
217
|
type_shape = ::FFI::AutoPointer.new(type_shape.read_pointer, FFI.api[:ReleaseTensorTypeAndShapeInfo])
|
|
215
218
|
|
|
216
219
|
elem_type = ::FFI::MemoryPointer.new(:int)
|
|
@@ -221,8 +224,8 @@ module OnnxRuntime
|
|
|
221
224
|
case elem_type
|
|
222
225
|
when :int64
|
|
223
226
|
ret = {}
|
|
224
|
-
keys = create_from_onnx_value(map_keys
|
|
225
|
-
values = create_from_onnx_value(map_values
|
|
227
|
+
keys = create_from_onnx_value(map_keys, output_type)
|
|
228
|
+
values = create_from_onnx_value(map_values, output_type)
|
|
226
229
|
keys.zip(values).each do |k, v|
|
|
227
230
|
ret[k] = v
|
|
228
231
|
end
|
data/lib/onnxruntime/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: onnxruntime
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: '0'
|
|
66
66
|
requirements: []
|
|
67
|
-
rubygems_version:
|
|
67
|
+
rubygems_version: 4.0.3
|
|
68
68
|
specification_version: 4
|
|
69
69
|
summary: High performance scoring engine for ML models
|
|
70
70
|
test_files: []
|