onnxruntime 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d4b9ddc710644eab07227fe005c92ad039643e989236e5f112a83df2266fc55
4
- data.tar.gz: d15c9ac4ae98130499d1411d3be2e7b822df8248550c0ad44c2e7a02d88f95d8
3
+ metadata.gz: 0b017fa8896c64bbeeda0ba6582ca9bfa626de3f13023ec9f3f91000031e88b8
4
+ data.tar.gz: 16344db9151ca3f388539e05772a7172129613f949dbff77d89bfb9c307d0de2
5
5
  SHA512:
6
- metadata.gz: 83a2e3699506460b8b280376ec8935a680e7e2cffe6bf7dd6766a85eea84bf06273e13889b6a2961c9df3c277be6ea7d8afbb67a4d4be62d50b266d7ccd8dc55
7
- data.tar.gz: 5086c2c04f76ec67224e7dbc9ccc36366b394840296536232b29d92009c7a4ef637fb4f39daec8abb7a5e3fdcca591675cfaf3e4a8e31ec939f9aa1e2ae6f112
6
+ metadata.gz: 21011ae8d875230858ff148a27ff29caf005210aae6f6e6a347ed9a02dfb85bceac6714957718d3f17872f07f0ace21c3ba7d7ba8884c1dff4b79fd08b43e40b
7
+ data.tar.gz: 000f4575890f92c2b1de308e052977f159ead243aef3984cd4190a5a873ecbe2868fe586fdbe14f2963f0518a75d8c4600d47ba2fbdd6a77c84cf3da1fc84292
@@ -1,3 +1,8 @@
1
+ ## 0.3.2 (2020-06-16)
2
+
3
+ - Fixed error with FFI 1.13.0+
4
+ - Added friendly graph optimization levels
5
+
1
6
  ## 0.3.1 (2020-05-18)
2
7
 
3
8
  - Updated ONNX Runtime to 1.3.0
data/README.md CHANGED
@@ -63,8 +63,8 @@ OnnxRuntime::Model.new(path_or_bytes, {
63
63
  enable_cpu_mem_arena: true,
64
64
  enable_mem_pattern: true,
65
65
  enable_profiling: false,
66
- execution_mode: :sequential,
67
- graph_optimization_level: nil,
66
+ execution_mode: :sequential, # :sequential or :parallel
67
+ graph_optimization_level: nil, # :none, :basic, :extended, or :all
68
68
  inter_op_num_threads: nil,
69
69
  intra_op_num_threads: nil,
70
70
  log_severity_level: 2,
@@ -19,7 +19,7 @@ module OnnxRuntime
19
19
  self.ffi_lib = [vendor_lib]
20
20
 
21
21
  def self.lib_version
22
- FFI.OrtGetApiBase[:GetVersionString].call
22
+ FFI.OrtGetApiBase[:GetVersionString].call.read_string
23
23
  end
24
24
 
25
25
  # friendlier error message
@@ -20,7 +20,7 @@ module OnnxRuntime
20
20
  layout \
21
21
  :CreateStatus, callback(%i[int string], :pointer),
22
22
  :GetErrorCode, callback(%i[pointer], :pointer),
23
- :GetErrorMessage, callback(%i[pointer], :string),
23
+ :GetErrorMessage, callback(%i[pointer], :pointer),
24
24
  :CreateEnv, callback(%i[int string pointer], :pointer),
25
25
  :CreateEnvWithCustomLogger, callback(%i[], :pointer),
26
26
  :EnableTelemetryEvents, callback(%i[pointer], :pointer),
@@ -150,7 +150,7 @@ module OnnxRuntime
150
150
  # to prevent "unable to resolve type" error on Ubuntu
151
151
  layout \
152
152
  :GetApi, callback(%i[uint32], Api.by_ref),
153
- :GetVersionString, callback(%i[], :string)
153
+ :GetVersionString, callback(%i[], :pointer)
154
154
  end
155
155
 
156
156
  attach_function :OrtGetApiBase, %i[], ApiBase.by_ref
@@ -10,18 +10,17 @@ module OnnxRuntime
10
10
  check_status api[:EnableMemPattern].call(session_options.read_pointer) if enable_mem_pattern
11
11
  check_status api[:EnableProfiling].call(session_options.read_pointer, "onnxruntime_profile_") if enable_profiling
12
12
  if execution_mode
13
- mode =
14
- case execution_mode
15
- when :sequential
16
- 0
17
- when :parallel
18
- 1
19
- else
20
- raise ArgumentError, "Invalid execution mode"
21
- end
13
+ execution_modes = {sequential: 0, parallel: 1}
14
+ mode = execution_modes[execution_mode]
15
+ raise ArgumentError, "Invalid execution mode" unless mode
22
16
  check_status api[:SetSessionExecutionMode].call(session_options.read_pointer, mode)
23
17
  end
24
- check_status api[:SetSessionGraphOptimizationLevel].call(session_options.read_pointer, graph_optimization_level) if graph_optimization_level
18
+ if graph_optimization_level
19
+ optimization_levels = {none: 0, basic: 1, extended: 2, all: 99}
20
+ # TODO raise error in 0.4.0
21
+ level = optimization_levels[graph_optimization_level] || graph_optimization_level
22
+ check_status api[:SetSessionGraphOptimizationLevel].call(session_options.read_pointer, level)
23
+ end
25
24
  check_status api[:SetInterOpNumThreads].call(session_options.read_pointer, inter_op_num_threads) if inter_op_num_threads
26
25
  check_status api[:SetIntraOpNumThreads].call(session_options.read_pointer, intra_op_num_threads) if intra_op_num_threads
27
26
  check_status api[:SetSessionLogSeverityLevel].call(session_options.read_pointer, log_severity_level) if log_severity_level
@@ -291,7 +290,7 @@ module OnnxRuntime
291
290
 
292
291
  def check_status(status)
293
292
  unless status.null?
294
- message = api[:GetErrorMessage].call(status)
293
+ message = api[:GetErrorMessage].call(status).read_string
295
294
  api[:ReleaseStatus].call(status)
296
295
  raise OnnxRuntime::Error, message
297
296
  end
@@ -1,3 +1,3 @@
1
1
  module OnnxRuntime
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onnxruntime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi