Class: ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensor
- Inherits:
-
FlatBuffers::Table
- Object
- FlatBuffers::Table
- ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensor
- Defined in:
- lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb
Constant Summary collapse
- FIELDS =
{ type_type: ::FlatBuffers::Field.new(:type_type, 0, 4, :utype, 0), type: ::FlatBuffers::Field.new(:type, 1, 6, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::Type", 0), shape: ::FlatBuffers::Field.new(:shape, 2, 8, ["::ArrowFormat::Org::Apache::Arrow::Flatbuf::TensorDim"], 0), non_zero_length: ::FlatBuffers::Field.new(:non_zero_length, 3, 10, :long, 0), sparse_index_type: ::FlatBuffers::Field.new(:sparse_index_type, 4, 12, :utype, 0), sparse_index: ::FlatBuffers::Field.new(:sparse_index, 5, 14, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensorIndex", 0), data: ::FlatBuffers::Field.new(:data, 6, 16, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer", 0), }
- Data =
define_data_class
Instance Method Summary collapse
-
#data ⇒ Object
The location and size of the tensor’s data.
-
#non_zero_length ⇒ Object
The number of non-zero values in a sparse tensor.
-
#shape ⇒ Object
The dimensions of the tensor, optionally named.
-
#sparse_index ⇒ Object
Sparse tensor index.
- #sparse_index_type ⇒ Object
-
#type ⇒ Object
The type of data contained in a value cell.
- #type_type ⇒ Object
Instance Method Details
#data ⇒ Object
The location and size of the tensor’s data
32 33 34 35 36 37 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 32 def data field_offset = @view.unpack_virtual_offset(16) return nil if field_offset.zero? @view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, field_offset) end |
#non_zero_length ⇒ Object
The number of non-zero values in a sparse tensor.
40 41 42 43 44 45 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 40 def non_zero_length field_offset = @view.unpack_virtual_offset(10) return 0 if field_offset.zero? @view.unpack_long(field_offset) end |
#shape ⇒ Object
The dimensions of the tensor, optionally named.
48 49 50 51 52 53 54 55 56 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 48 def shape field_offset = @view.unpack_virtual_offset(8) return nil if field_offset.zero? element_size = 4 @view.unpack_vector(field_offset, element_size) do |element_offset| @view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::TensorDim, element_offset) end end |
#sparse_index ⇒ Object
Sparse tensor index
59 60 61 62 63 64 65 66 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 59 def sparse_index type = sparse_index_type return nil if type.nil? field_offset = @view.unpack_virtual_offset(14) return nil if field_offset.zero? @view.unpack_union(type.table_class, field_offset) end |
#sparse_index_type ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 68 def sparse_index_type field_offset = @view.unpack_virtual_offset(12) if field_offset.zero? enum_value = 0 else enum_value = @view.unpack_utype(field_offset) end ::ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensorIndex.try_convert(enum_value) || enum_value end |
#type ⇒ Object
The type of data contained in a value cell. Currently only fixed-width value types are supported, no strings or nested types.
81 82 83 84 85 86 87 88 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 81 def type type = type_type return nil if type.nil? field_offset = @view.unpack_virtual_offset(6) return nil if field_offset.zero? @view.unpack_union(type.table_class, field_offset) end |
#type_type ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb', line 90 def type_type field_offset = @view.unpack_virtual_offset(4) if field_offset.zero? enum_value = 0 else enum_value = @view.unpack_utype(field_offset) end ::ArrowFormat::Org::Apache::Arrow::Flatbuf::Type.try_convert(enum_value) || enum_value end |