ndav-ort_value 0.0.3 → 0.0.5

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: a465ee9ba7be61fdbe2e559baa80b1c49580ac53fbbbab8f86023bac3bb52993
4
- data.tar.gz: 2a8caf3c52aa4b30c618639a9a8c44db8f4f56712a4b3905f729ae5f64d0b320
3
+ metadata.gz: 19c1c1d643d1d3ffe35a5ab18394af9d511205c1f5f7c40bfce4b4dfcdbb2ebb
4
+ data.tar.gz: 3f0eaab60d431b7cf4bcc398c0a0e7f1370c3ce6eda2f1ab3929ce2559af5404
5
5
  SHA512:
6
- metadata.gz: '09eb66abb2f3ce3bc9095c04e9ca72942792c58eede40b6c8320f1e15d6ccd64db20d1d311974d8f49df06aef07517bc5c578a362b73c86ada840dc796ea9384'
7
- data.tar.gz: 01141c19d63e3d5fa0a29e26843fbc206e00f11993fa7c3fc37f04554b5810e1332a508c1217b580b9533c03c02fbe9162685c02b74c7d4296165846a319b633
6
+ metadata.gz: c36fad491d6a37b3649fc39c4a56f5688257490651bc1146b9c9b29106ea61b2dd997453a0347c720f963825d00a895449bec01d5162427100fe22e4c72bd22f
7
+ data.tar.gz: ddaac0b57a50aad083640d5dfb1efa04f582f154f2debe5d669bb8c1009671d05fcdfc3f7d1f25738067529738adfd647d36bdb82c60f2c4bf6774b5081ea9b5
data/README.md CHANGED
@@ -1,11 +1,32 @@
1
1
  OnnxRuntime::OrtValue::NDAV
2
2
  ===========================
3
3
 
4
- MemoryView and pointer support for [ONNX Runtime Ruby][].
4
+ [NDAV][] bridge for [ONNX Runtime Ruby][].
5
+
6
+ SYNOPSIS
7
+ --------
8
+
9
+ ```ruby
10
+ require "ndav/ort_value"
11
+
12
+ ort_value = OnnxRuntime::OrtValue.from_array([1.0, 2.0, 3.0], element_type: :float) # => OnnxRuntime::OrtValue
13
+ ndav = ort_value.to_ndav # => NDAV
14
+ ort_value = ndav.to_ort_value # => OnnxRuntime::OrtValue
15
+
16
+ memory_view = Fiddle::MemoryView.new(ort_value) # => Fiddle::MemoryView, now it may export a MemoryView
17
+
18
+ ndav = NDAV.from_ort_value(ort_value) # => NDAV
19
+ ort_value = OnnxRuntime::OrtValue.from_ndav(ndav) # => OnnxRuntime::OrtValue
20
+
21
+ include NDAV::Converter
22
+ ndav = NDAV(ort_value) # => NDAV
23
+ ort_value = OrtValue(ndav) # => OnnxRuntime::OrtValue
24
+ ```
5
25
 
6
26
  LICENSE
7
27
  ------
8
28
 
9
29
  MIT license. See LICENSE.txt file.
10
30
 
31
+ [NDAV]: https://kitaitimakoto.gitlab.io/ndav/
11
32
  [ONNX Runtime Ruby]: https://github.com/ankane/onnxruntime-ruby
@@ -27,6 +27,31 @@ class NDAV
27
27
  :float
28
28
  when "d"
29
29
  :double
30
+ else
31
+ case IO::Buffer::HOST_ENDIAN
32
+ when IO::Buffer::LITTLE_ENDIAN
33
+ case format
34
+ when "v"
35
+ :uint16
36
+ when "V"
37
+ :uint32
38
+ when "e"
39
+ :float
40
+ when "E"
41
+ :double
42
+ end
43
+ when IO::Buffer::BIG_ENDIAN
44
+ case format
45
+ when "n"
46
+ :uint16
47
+ when "N"
48
+ :uint32
49
+ when "g"
50
+ :float
51
+ when "G"
52
+ :double
53
+ end
54
+ end
30
55
  end
31
56
  [format, type]
32
57
  }
@@ -83,18 +108,25 @@ class NDAV
83
108
  end
84
109
  end
85
110
 
86
- module ToNDAV
87
- def to_ndav
111
+ module MemoryViewable
112
+ def ndav_descriptor(**)
88
113
  item_size = TYPE_SIZES[element_type]
89
- Utils.unsupported_type("NDAV", element_type) unless item_size
114
+ unless item_size
115
+ warn "unsupported type: #{element_type}"
116
+ return false
117
+ end
118
+
90
119
  byte_size = shape.reduce(item_size, :*)
91
120
 
92
- ::NDAV.new(
93
- ::Fiddle::Pointer.new(data_ptr.address, byte_size),
94
- shape: shape.dup,
121
+ {
122
+ data: ::Fiddle::Pointer.new(data_ptr.address, byte_size),
123
+ shape:,
124
+ strides: ::NDAV.default_strides(shape:, item_size:),
95
125
  format: TYPE_TO_FORMAT[element_type],
96
- lifetime: self
97
- )
126
+ byte_size:,
127
+ readonly?: true,
128
+ sub_offsets: nil
129
+ }
98
130
  end
99
131
  end
100
132
 
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ndav-ort_value"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.5"
4
4
  s.authors = ["Kitaiti Makoto"]
5
5
  s.summary = "OnnxRuntime extension for MemoryView exporters and pointers"
6
6
  s.licenses = ["MIT"]
7
7
  s.homepage = "https://gitlab.com/KitaitiMakoto/ndav-ort_value"
8
8
 
9
9
  s.add_runtime_dependency "onnxruntime"
10
- s.add_runtime_dependency "ndav", ">= 0.0.3"
10
+ s.add_runtime_dependency "ndav", ">= 0.0.6"
11
11
 
12
12
  s.files = Dir.chdir(__dir__) {`git ls-files -z`.split("\x0")}
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndav-ort_value
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.0.3
32
+ version: 0.0.6
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.3
39
+ version: 0.0.6
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 4.0.6
167
+ rubygems_version: 4.0.16
168
168
  specification_version: 4
169
169
  summary: OnnxRuntime extension for MemoryView exporters and pointers
170
170
  test_files: []