onnxruntime 0.7.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +117 -0
- data/LICENSE.txt +22 -0
- data/README.md +134 -0
- data/lib/onnxruntime/datasets.rb +10 -0
- data/lib/onnxruntime/ffi.rb +171 -0
- data/lib/onnxruntime/inference_session.rb +531 -0
- data/lib/onnxruntime/model.rb +30 -0
- data/lib/onnxruntime/utils.rb +16 -0
- data/lib/onnxruntime/version.rb +3 -0
- data/lib/onnxruntime.rb +42 -0
- data/vendor/LICENSE +21 -0
- data/vendor/ThirdPartyNotices.txt +4779 -0
- data/vendor/libonnxruntime.arm64.dylib +0 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98aa76296341e9cd08b89f21d8c440e8fb4d2f269238e064060b6c16f7885c71
|
4
|
+
data.tar.gz: d28b0a71f55bed6a8087159069a1805cd54c484f015c77337c96c60ecf78beed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53003ffe9559aa9bec701f78f38776aabd27bfb73664c6335009f5041137d4daffe6e1f8061f005df3a36cc276c1d09aee58d175de200e9b616d2f86f6ee5d12
|
7
|
+
data.tar.gz: 90b0fa6faf3b88f7a7ad10825437e2a084ce0b41d9145c3dc3cd8ee515e9bf90a421a662bf1e7a6e4a48da569d9ce40a253f3ee646a4ae82c5cca0292fe6833d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
## 0.7.0 (2022-03-27)
|
2
|
+
|
3
|
+
- Added platform-specific gems
|
4
|
+
- Added ARM shared library for Linux
|
5
|
+
- Dropped support for Ruby < 2.7
|
6
|
+
|
7
|
+
## 0.6.6 (2022-03-27)
|
8
|
+
|
9
|
+
- Updated ONNX Runtime to 1.11.0
|
10
|
+
|
11
|
+
## 0.6.5 (2021-12-07)
|
12
|
+
|
13
|
+
- Updated ONNX Runtime to 1.10.0
|
14
|
+
|
15
|
+
## 0.6.4 (2021-09-22)
|
16
|
+
|
17
|
+
- Updated ONNX Runtime to 1.9.0
|
18
|
+
|
19
|
+
## 0.6.3 (2021-07-08)
|
20
|
+
|
21
|
+
- Updated ONNX Runtime to 1.8.1
|
22
|
+
|
23
|
+
## 0.6.2 (2021-06-03)
|
24
|
+
|
25
|
+
- Updated ONNX Runtime to 1.8.0
|
26
|
+
|
27
|
+
## 0.6.1 (2021-05-17)
|
28
|
+
|
29
|
+
- Fixed memory errors
|
30
|
+
|
31
|
+
## 0.6.0 (2021-03-14)
|
32
|
+
|
33
|
+
- Updated ONNX Runtime to 1.7.0
|
34
|
+
- OpenMP is no longer required
|
35
|
+
|
36
|
+
## 0.5.2 (2020-12-27)
|
37
|
+
|
38
|
+
- Updated ONNX Runtime to 1.6.0
|
39
|
+
- Fixed error with `execution_mode` option
|
40
|
+
- Fixed error with `bool` input
|
41
|
+
|
42
|
+
## 0.5.1 (2020-11-01)
|
43
|
+
|
44
|
+
- Updated ONNX Runtime to 1.5.2
|
45
|
+
- Added support for string output
|
46
|
+
- Added `output_type` option
|
47
|
+
- Improved performance for Numo array inputs
|
48
|
+
|
49
|
+
## 0.5.0 (2020-10-01)
|
50
|
+
|
51
|
+
- Updated ONNX Runtime to 1.5.1
|
52
|
+
- OpenMP is now required on Mac
|
53
|
+
- Fixed `mul_1.onnx` example
|
54
|
+
|
55
|
+
## 0.4.0 (2020-07-20)
|
56
|
+
|
57
|
+
- Updated ONNX Runtime to 1.4.0
|
58
|
+
- Added `providers` method
|
59
|
+
- Fixed errors on Windows
|
60
|
+
|
61
|
+
## 0.3.3 (2020-06-17)
|
62
|
+
|
63
|
+
- Fixed segmentation fault on exit on Linux
|
64
|
+
|
65
|
+
## 0.3.2 (2020-06-16)
|
66
|
+
|
67
|
+
- Fixed error with FFI 1.13.0+
|
68
|
+
- Added friendly graph optimization levels
|
69
|
+
|
70
|
+
## 0.3.1 (2020-05-18)
|
71
|
+
|
72
|
+
- Updated ONNX Runtime to 1.3.0
|
73
|
+
- Added `custom_metadata_map` to model metadata
|
74
|
+
|
75
|
+
## 0.3.0 (2020-03-11)
|
76
|
+
|
77
|
+
- Updated ONNX Runtime to 1.2.0
|
78
|
+
- Added model metadata
|
79
|
+
- Added `end_profiling` method
|
80
|
+
- Added support for loading from IO objects
|
81
|
+
- Improved `input` and `output` for `seq` and `map` types
|
82
|
+
|
83
|
+
## 0.2.3 (2020-01-23)
|
84
|
+
|
85
|
+
- Updated ONNX Runtime to 1.1.1
|
86
|
+
|
87
|
+
## 0.2.2 (2019-12-24)
|
88
|
+
|
89
|
+
- Added support for session options
|
90
|
+
- Added support for run options
|
91
|
+
- Added `Datasets` module
|
92
|
+
|
93
|
+
## 0.2.1 (2019-12-19)
|
94
|
+
|
95
|
+
- Updated ONNX Runtime to 1.1.0
|
96
|
+
|
97
|
+
## 0.2.0 (2019-10-30)
|
98
|
+
|
99
|
+
- Added support for ONNX Runtime 1.0
|
100
|
+
- Dropped support for ONNX Runtime < 1.0
|
101
|
+
|
102
|
+
## 0.1.2 (2019-10-27)
|
103
|
+
|
104
|
+
- Added support for Numo::NArray
|
105
|
+
- Made thread-safe
|
106
|
+
- Fixed error with JRuby
|
107
|
+
|
108
|
+
## 0.1.1 (2019-09-03)
|
109
|
+
|
110
|
+
- Packaged ONNX Runtime with gem
|
111
|
+
- Added support for many more types
|
112
|
+
- Fixed output order with `output_names` option
|
113
|
+
- Fixed `File doesn't exist` on Windows
|
114
|
+
|
115
|
+
## 0.1.0 (2019-08-26)
|
116
|
+
|
117
|
+
- First release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) Microsoft Corporation
|
4
|
+
Copyright (c) 2019-2022 Andrew Kane
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# ONNX Runtime Ruby
|
2
|
+
|
3
|
+
:fire: [ONNX Runtime](https://github.com/Microsoft/onnxruntime) - the high performance scoring engine for ML models - for Ruby
|
4
|
+
|
5
|
+
Check out [an example](https://ankane.org/tensorflow-ruby)
|
6
|
+
|
7
|
+
[![Build Status](https://github.com/ankane/onnxruntime-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/onnxruntime-ruby/actions)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application’s Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "onnxruntime"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Getting Started
|
18
|
+
|
19
|
+
Load a model and make predictions
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
model = OnnxRuntime::Model.new("model.onnx")
|
23
|
+
model.predict({x: [1, 2, 3]})
|
24
|
+
```
|
25
|
+
|
26
|
+
> Download pre-trained models from the [ONNX Model Zoo](https://github.com/onnx/models)
|
27
|
+
|
28
|
+
Get inputs
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
model.inputs
|
32
|
+
```
|
33
|
+
|
34
|
+
Get outputs
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
model.outputs
|
38
|
+
```
|
39
|
+
|
40
|
+
Get metadata
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
model.metadata
|
44
|
+
```
|
45
|
+
|
46
|
+
Load a model from a string
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
byte_str = StringIO.new("...")
|
50
|
+
model = OnnxRuntime::Model.new(byte_str)
|
51
|
+
```
|
52
|
+
|
53
|
+
Get specific outputs
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
model.predict({x: [1, 2, 3]}, output_names: ["label"])
|
57
|
+
```
|
58
|
+
|
59
|
+
## Session Options
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
OnnxRuntime::Model.new(path_or_bytes, {
|
63
|
+
enable_cpu_mem_arena: true,
|
64
|
+
enable_mem_pattern: true,
|
65
|
+
enable_profiling: false,
|
66
|
+
execution_mode: :sequential, # :sequential or :parallel
|
67
|
+
graph_optimization_level: nil, # :none, :basic, :extended, or :all
|
68
|
+
inter_op_num_threads: nil,
|
69
|
+
intra_op_num_threads: nil,
|
70
|
+
log_severity_level: 2,
|
71
|
+
log_verbosity_level: 0,
|
72
|
+
logid: nil,
|
73
|
+
optimized_model_filepath: nil
|
74
|
+
})
|
75
|
+
```
|
76
|
+
|
77
|
+
## Run Options
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
model.predict(input_feed, {
|
81
|
+
output_names: nil,
|
82
|
+
log_severity_level: 2,
|
83
|
+
log_verbosity_level: 0,
|
84
|
+
logid: nil,
|
85
|
+
terminate: false,
|
86
|
+
output_type: :ruby # :ruby or :numo
|
87
|
+
})
|
88
|
+
```
|
89
|
+
|
90
|
+
## Inference Session API
|
91
|
+
|
92
|
+
You can also use the Inference Session API, which follows the [Python API](https://microsoft.github.io/onnxruntime/python/api_summary.html).
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
session = OnnxRuntime::InferenceSession.new("model.onnx")
|
96
|
+
session.run(nil, {x: [1, 2, 3]})
|
97
|
+
```
|
98
|
+
|
99
|
+
The Python example models are included as well.
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
OnnxRuntime::Datasets.example("sigmoid.onnx")
|
103
|
+
```
|
104
|
+
|
105
|
+
## GPU Support
|
106
|
+
|
107
|
+
To enable GPU support on Linux and Windows, download the appropriate [GPU release](https://github.com/microsoft/onnxruntime/releases) and set:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
OnnxRuntime.ffi_lib = "path/to/lib/libonnxruntime.so" # onnxruntime.dll for Windows
|
111
|
+
```
|
112
|
+
|
113
|
+
## History
|
114
|
+
|
115
|
+
View the [changelog](https://github.com/ankane/onnxruntime-ruby/blob/master/CHANGELOG.md)
|
116
|
+
|
117
|
+
## Contributing
|
118
|
+
|
119
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
120
|
+
|
121
|
+
- [Report bugs](https://github.com/ankane/onnxruntime-ruby/issues)
|
122
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/onnxruntime-ruby/pulls)
|
123
|
+
- Write, clarify, or fix documentation
|
124
|
+
- Suggest or add new features
|
125
|
+
|
126
|
+
To get started with development and testing:
|
127
|
+
|
128
|
+
```sh
|
129
|
+
git clone https://github.com/ankane/onnxruntime-ruby.git
|
130
|
+
cd onnxruntime-ruby
|
131
|
+
bundle install
|
132
|
+
bundle exec rake vendor:all
|
133
|
+
bundle exec rake test
|
134
|
+
```
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module OnnxRuntime
|
2
|
+
module Datasets
|
3
|
+
def self.example(name)
|
4
|
+
unless %w(logreg_iris.onnx mul_1.onnx sigmoid.onnx).include?(name)
|
5
|
+
raise ArgumentError, "Unable to find example '#{name}'"
|
6
|
+
end
|
7
|
+
File.expand_path("../../datasets/#{name}", __dir__)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module OnnxRuntime
|
2
|
+
module FFI
|
3
|
+
extend ::FFI::Library
|
4
|
+
|
5
|
+
begin
|
6
|
+
ffi_lib OnnxRuntime.ffi_lib
|
7
|
+
rescue LoadError => e
|
8
|
+
if e.message.include?("Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib") && e.message.include?("Reason: image not found")
|
9
|
+
raise LoadError, "OpenMP not found. Run `brew install libomp`"
|
10
|
+
else
|
11
|
+
raise e
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# https://github.com/microsoft/onnxruntime/blob/master/include/onnxruntime/core/session/onnxruntime_c_api.h
|
16
|
+
# keep same order
|
17
|
+
|
18
|
+
# enums
|
19
|
+
TensorElementDataType = enum(:undefined, :float, :uint8, :int8, :uint16, :int16, :int32, :int64, :string, :bool, :float16, :double, :uint32, :uint64, :complex64, :complex128, :bfloat16)
|
20
|
+
OnnxType = enum(:unknown, :tensor, :sequence, :map, :opaque, :sparsetensor)
|
21
|
+
|
22
|
+
class Api < ::FFI::Struct
|
23
|
+
layout \
|
24
|
+
:CreateStatus, callback(%i[int string], :pointer),
|
25
|
+
:GetErrorCode, callback(%i[pointer], :pointer),
|
26
|
+
:GetErrorMessage, callback(%i[pointer], :pointer),
|
27
|
+
:CreateEnv, callback(%i[int string pointer], :pointer),
|
28
|
+
:CreateEnvWithCustomLogger, callback(%i[], :pointer),
|
29
|
+
:EnableTelemetryEvents, callback(%i[pointer], :pointer),
|
30
|
+
:DisableTelemetryEvents, callback(%i[pointer], :pointer),
|
31
|
+
:CreateSession, callback(%i[pointer pointer pointer pointer], :pointer),
|
32
|
+
:CreateSessionFromArray, callback(%i[pointer pointer size_t pointer pointer], :pointer),
|
33
|
+
:Run, callback(%i[pointer pointer pointer pointer size_t pointer size_t pointer], :pointer),
|
34
|
+
:CreateSessionOptions, callback(%i[pointer], :pointer),
|
35
|
+
:SetOptimizedModelFilePath, callback(%i[pointer pointer], :pointer),
|
36
|
+
:CloneSessionOptions, callback(%i[], :pointer),
|
37
|
+
:SetSessionExecutionMode, callback(%i[pointer int], :pointer),
|
38
|
+
:EnableProfiling, callback(%i[pointer pointer], :pointer),
|
39
|
+
:DisableProfiling, callback(%i[pointer], :pointer),
|
40
|
+
:EnableMemPattern, callback(%i[pointer], :pointer),
|
41
|
+
:DisableMemPattern, callback(%i[pointer], :pointer),
|
42
|
+
:EnableCpuMemArena, callback(%i[pointer], :pointer),
|
43
|
+
:DisableCpuMemArena, callback(%i[pointer], :pointer),
|
44
|
+
:SetSessionLogId, callback(%i[pointer string], :pointer),
|
45
|
+
:SetSessionLogVerbosityLevel, callback(%i[pointer int], :pointer),
|
46
|
+
:SetSessionLogSeverityLevel, callback(%i[pointer int], :pointer),
|
47
|
+
:SetSessionGraphOptimizationLevel, callback(%i[pointer int], :pointer),
|
48
|
+
:SetIntraOpNumThreads, callback(%i[pointer int], :pointer),
|
49
|
+
:SetInterOpNumThreads, callback(%i[pointer int], :pointer),
|
50
|
+
:CreateCustomOpDomain, callback(%i[], :pointer),
|
51
|
+
:CustomOpDomain_Add, callback(%i[], :pointer),
|
52
|
+
:AddCustomOpDomain, callback(%i[], :pointer),
|
53
|
+
:RegisterCustomOpsLibrary, callback(%i[], :pointer),
|
54
|
+
:SessionGetInputCount, callback(%i[pointer pointer], :pointer),
|
55
|
+
:SessionGetOutputCount, callback(%i[pointer pointer], :pointer),
|
56
|
+
:SessionGetOverridableInitializerCount, callback(%i[], :pointer),
|
57
|
+
:SessionGetInputTypeInfo, callback(%i[pointer size_t pointer], :pointer),
|
58
|
+
:SessionGetOutputTypeInfo, callback(%i[pointer size_t pointer], :pointer),
|
59
|
+
:SessionGetOverridableInitializerTypeInfo, callback(%i[], :pointer),
|
60
|
+
:SessionGetInputName, callback(%i[pointer size_t pointer pointer], :pointer),
|
61
|
+
:SessionGetOutputName, callback(%i[pointer size_t pointer pointer], :pointer),
|
62
|
+
:SessionGetOverridableInitializerName, callback(%i[], :pointer),
|
63
|
+
:CreateRunOptions, callback(%i[pointer], :pointer),
|
64
|
+
:RunOptionsSetRunLogVerbosityLevel, callback(%i[pointer int], :pointer),
|
65
|
+
:RunOptionsSetRunLogSeverityLevel, callback(%i[pointer int], :pointer),
|
66
|
+
:RunOptionsSetRunTag, callback(%i[pointer string], :pointer),
|
67
|
+
:RunOptionsGetRunLogVerbosityLevel, callback(%i[], :pointer),
|
68
|
+
:RunOptionsGetRunLogSeverityLevel, callback(%i[], :pointer),
|
69
|
+
:RunOptionsGetRunTag, callback(%i[], :pointer),
|
70
|
+
:RunOptionsSetTerminate, callback(%i[pointer], :pointer),
|
71
|
+
:RunOptionsUnsetTerminate, callback(%i[pointer], :pointer),
|
72
|
+
:CreateTensorAsOrtValue, callback(%i[pointer pointer size_t int pointer], :pointer),
|
73
|
+
:CreateTensorWithDataAsOrtValue, callback(%i[pointer pointer size_t pointer size_t int pointer], :pointer),
|
74
|
+
:IsTensor, callback(%i[], :pointer),
|
75
|
+
:GetTensorMutableData, callback(%i[pointer pointer], :pointer),
|
76
|
+
:FillStringTensor, callback(%i[pointer pointer size_t], :pointer),
|
77
|
+
:GetStringTensorDataLength, callback(%i[pointer pointer], :pointer),
|
78
|
+
:GetStringTensorContent, callback(%i[pointer pointer size_t pointer size_t], :pointer),
|
79
|
+
:CastTypeInfoToTensorInfo, callback(%i[pointer pointer], :pointer),
|
80
|
+
:GetOnnxTypeFromTypeInfo, callback(%i[pointer pointer], :pointer),
|
81
|
+
:CreateTensorTypeAndShapeInfo, callback(%i[], :pointer),
|
82
|
+
:SetTensorElementType, callback(%i[], :pointer),
|
83
|
+
:SetDimensions, callback(%i[], :pointer),
|
84
|
+
:GetTensorElementType, callback(%i[pointer pointer], :pointer),
|
85
|
+
:GetDimensionsCount, callback(%i[pointer pointer], :pointer),
|
86
|
+
:GetDimensions, callback(%i[pointer pointer size_t], :pointer),
|
87
|
+
:GetSymbolicDimensions, callback(%i[], :pointer),
|
88
|
+
:GetTensorShapeElementCount, callback(%i[pointer pointer], :pointer),
|
89
|
+
:GetTensorTypeAndShape, callback(%i[pointer pointer], :pointer),
|
90
|
+
:GetTypeInfo, callback(%i[pointer pointer], :pointer),
|
91
|
+
:GetValueType, callback(%i[pointer pointer], :pointer),
|
92
|
+
:CreateMemoryInfo, callback(%i[], :pointer),
|
93
|
+
:CreateCpuMemoryInfo, callback(%i[int int pointer], :pointer),
|
94
|
+
:CompareMemoryInfo, callback(%i[], :pointer),
|
95
|
+
:MemoryInfoGetName, callback(%i[], :pointer),
|
96
|
+
:MemoryInfoGetId, callback(%i[], :pointer),
|
97
|
+
:MemoryInfoGetMemType, callback(%i[], :pointer),
|
98
|
+
:MemoryInfoGetType, callback(%i[], :pointer),
|
99
|
+
:AllocatorAlloc, callback(%i[], :pointer),
|
100
|
+
:AllocatorFree, callback(%i[], :pointer),
|
101
|
+
:AllocatorGetInfo, callback(%i[], :pointer),
|
102
|
+
:GetAllocatorWithDefaultOptions, callback(%i[pointer], :pointer),
|
103
|
+
:AddFreeDimensionOverride, callback(%i[], :pointer),
|
104
|
+
:GetValue, callback(%i[pointer int pointer pointer], :pointer),
|
105
|
+
:GetValueCount, callback(%i[pointer pointer], :pointer),
|
106
|
+
:CreateValue, callback(%i[], :pointer),
|
107
|
+
:CreateOpaqueValue, callback(%i[], :pointer),
|
108
|
+
:GetOpaqueValue, callback(%i[], :pointer),
|
109
|
+
:KernelInfoGetAttribute_float, callback(%i[], :pointer),
|
110
|
+
:KernelInfoGetAttribute_int64, callback(%i[], :pointer),
|
111
|
+
:KernelInfoGetAttribute_string, callback(%i[], :pointer),
|
112
|
+
:KernelContext_GetInputCount, callback(%i[], :pointer),
|
113
|
+
:KernelContext_GetOutputCount, callback(%i[], :pointer),
|
114
|
+
:KernelContext_GetInput, callback(%i[], :pointer),
|
115
|
+
:KernelContext_GetOutput, callback(%i[], :pointer),
|
116
|
+
:ReleaseEnv, callback(%i[pointer], :void),
|
117
|
+
:ReleaseStatus, callback(%i[pointer], :void),
|
118
|
+
:ReleaseMemoryInfo, callback(%i[pointer], :void),
|
119
|
+
:ReleaseSession, callback(%i[pointer], :void),
|
120
|
+
:ReleaseValue, callback(%i[pointer], :void),
|
121
|
+
:ReleaseRunOptions, callback(%i[pointer], :void),
|
122
|
+
:ReleaseTypeInfo, callback(%i[pointer], :void),
|
123
|
+
:ReleaseTensorTypeAndShapeInfo, callback(%i[pointer], :void),
|
124
|
+
:ReleaseSessionOptions, callback(%i[pointer], :void),
|
125
|
+
:ReleaseCustomOpDomain, callback(%i[pointer], :void),
|
126
|
+
:GetDenotationFromTypeInfo, callback(%i[], :pointer),
|
127
|
+
:CastTypeInfoToMapTypeInfo, callback(%i[pointer pointer], :pointer),
|
128
|
+
:CastTypeInfoToSequenceTypeInfo, callback(%i[pointer pointer], :pointer),
|
129
|
+
:GetMapKeyType, callback(%i[pointer pointer], :pointer),
|
130
|
+
:GetMapValueType, callback(%i[pointer pointer], :pointer),
|
131
|
+
:GetSequenceElementType, callback(%i[pointer pointer], :pointer),
|
132
|
+
:ReleaseMapTypeInfo, callback(%i[pointer], :void),
|
133
|
+
:ReleaseSequenceTypeInfo, callback(%i[pointer], :void),
|
134
|
+
:SessionEndProfiling, callback(%i[pointer pointer pointer], :pointer),
|
135
|
+
:SessionGetModelMetadata, callback(%i[pointer pointer], :pointer),
|
136
|
+
:ModelMetadataGetProducerName, callback(%i[pointer pointer pointer], :pointer),
|
137
|
+
:ModelMetadataGetGraphName, callback(%i[pointer pointer pointer], :pointer),
|
138
|
+
:ModelMetadataGetDomain, callback(%i[pointer pointer pointer], :pointer),
|
139
|
+
:ModelMetadataGetDescription, callback(%i[pointer pointer pointer], :pointer),
|
140
|
+
:ModelMetadataLookupCustomMetadataMap, callback(%i[pointer pointer pointer pointer], :pointer),
|
141
|
+
:ModelMetadataGetVersion, callback(%i[pointer pointer], :pointer),
|
142
|
+
:ReleaseModelMetadata, callback(%i[pointer], :void),
|
143
|
+
:CreateEnvWithGlobalThreadPools, callback(%i[], :pointer),
|
144
|
+
:DisablePerSessionThreads, callback(%i[], :pointer),
|
145
|
+
:CreateThreadingOptions, callback(%i[], :pointer),
|
146
|
+
:ReleaseThreadingOptions, callback(%i[], :pointer),
|
147
|
+
:ModelMetadataGetCustomMetadataMapKeys, callback(%i[pointer pointer pointer pointer], :pointer),
|
148
|
+
:AddFreeDimensionOverrideByName, callback(%i[], :pointer),
|
149
|
+
:GetAvailableProviders, callback(%i[pointer pointer], :pointer),
|
150
|
+
:ReleaseAvailableProviders, callback(%i[pointer int], :pointer)
|
151
|
+
end
|
152
|
+
|
153
|
+
class ApiBase < ::FFI::Struct
|
154
|
+
# use uint32 instead of uint32_t
|
155
|
+
# to prevent "unable to resolve type" error on Ubuntu
|
156
|
+
layout \
|
157
|
+
:GetApi, callback(%i[uint32], Api.by_ref),
|
158
|
+
:GetVersionString, callback(%i[], :pointer)
|
159
|
+
end
|
160
|
+
|
161
|
+
attach_function :OrtGetApiBase, %i[], ApiBase.by_ref
|
162
|
+
|
163
|
+
if Gem.win_platform?
|
164
|
+
class Libc
|
165
|
+
extend ::FFI::Library
|
166
|
+
ffi_lib ::FFI::Library::LIBC
|
167
|
+
attach_function :mbstowcs, %i[pointer string size_t], :size_t
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|