ndav-ort_value 0.0.5 → 0.0.6

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: 19c1c1d643d1d3ffe35a5ab18394af9d511205c1f5f7c40bfce4b4dfcdbb2ebb
4
- data.tar.gz: 3f0eaab60d431b7cf4bcc398c0a0e7f1370c3ce6eda2f1ab3929ce2559af5404
3
+ metadata.gz: e2e8b2b21e5976af7fdadc3c24d76506374bda52b74b4b40ada242154e403fea
4
+ data.tar.gz: 64452122087555efc507c3babfdf30754c1ca71161ed1245064148376119a0eb
5
5
  SHA512:
6
- metadata.gz: c36fad491d6a37b3649fc39c4a56f5688257490651bc1146b9c9b29106ea61b2dd997453a0347c720f963825d00a895449bec01d5162427100fe22e4c72bd22f
7
- data.tar.gz: ddaac0b57a50aad083640d5dfb1efa04f582f154f2debe5d669bb8c1009671d05fcdfc3f7d1f25738067529738adfd647d36bdb82c60f2c4bf6774b5081ea9b5
6
+ metadata.gz: f7b30d342e4abe2fc12416eb21da3305cf74c35e7538c66e3e0098656e0269c0c6eba14f38253fe62394618adae63245089c24459ededdf7d4980ab626911353
7
+ data.tar.gz: 105131f343eec427bc6c5f97b777e7af72da3f2e7c1f482d05f49204028be504f4e530957ba5b3de3b3d00de1ec5e8353d7e6c4701e01afadc044986e16cd092
@@ -15,49 +15,56 @@ class NDAV
15
15
  float: "f",
16
16
  double: "d"
17
17
  }
18
-
19
- FORMAT_TO_TYPE = ::NDAV::ITEM_SIZES.to_h {|format, size|
20
- suffix = size * 8
21
- type = case format
22
- when "s!", "c", "s", "l", "q", "i", "i!", "l!", "q!"
23
- :"int#{suffix}"
24
- when "S!", "C", "S", "L", "Q", "I", "I!", "L!", "Q!"
25
- :"uint#{suffix}"
26
- when "f"
27
- :float
28
- when "d"
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
55
- end
56
- [format, type]
57
- }
58
-
18
+ FORMAT_TO_TYPE = Hash.new {|types, format| types[format] = type_from_format(format)}
59
19
  TYPE_SIZES = TYPE_TO_FORMAT.transform_values {|format| ::NDAV::ITEM_SIZES[format]}
60
20
 
21
+ class << self
22
+ def type_from_format(format)
23
+ item_desc = ::NDAV::ITEM_DESCS[format]
24
+ return unless item_desc.length == 1
25
+
26
+ component = item_desc[0]
27
+ return unless component.repeat == 1
28
+
29
+ suffix = component.size * 8
30
+ case component.format
31
+ when "c", "s", "l", "q", "i", "j"
32
+ :"int#{suffix}"
33
+ when "C", "S", "L", "Q", "I", "J"
34
+ :"uint#{suffix}"
35
+ when "f"
36
+ :float
37
+ when "d"
38
+ :double
39
+ else
40
+ case IO::Buffer::HOST_ENDIAN
41
+ when IO::Buffer::LITTLE_ENDIAN
42
+ case format
43
+ when "v"
44
+ :uint16
45
+ when "V"
46
+ :uint32
47
+ when "e"
48
+ :float
49
+ when "E"
50
+ :double
51
+ end
52
+ when IO::Buffer::BIG_ENDIAN
53
+ case format
54
+ when "n"
55
+ :uint16
56
+ when "N"
57
+ :uint32
58
+ when "g"
59
+ :float
60
+ when "G"
61
+ :double
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
61
68
  module FromNDAV
62
69
  def from_memory_view(input)
63
70
  from_ndav(::NDAV.new(input))
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ndav-ort_value"
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6"
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.6"
10
+ s.add_runtime_dependency "ndav", ">= 0.0.7"
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.5
4
+ version: 0.0.6
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.6
32
+ version: 0.0.7
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.6
39
+ version: 0.0.7
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
42
42
  requirement: !ruby/object:Gem::Requirement