Class: ArrowFormat::Org::Apache::Arrow::Flatbuf::Tensor
- Inherits:
-
FlatBuffers::Table
- Object
- FlatBuffers::Table
- ArrowFormat::Org::Apache::Arrow::Flatbuf::Tensor
- Defined in:
- lib/arrow-format/org/apache/arrow/flatbuf/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), strides: ::FlatBuffers::Field.new(:strides, 3, 10, [:long], 0), data: ::FlatBuffers::Field.new(:data, 4, 12, "::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.
-
#shape ⇒ Object
The dimensions of the tensor, optionally named.
-
#strides ⇒ Object
Non-negative byte offsets to advance one value cell along each dimension If omitted, default to row-major order (C-like).
-
#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
29 30 31 32 33 34 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb', line 29 def data field_offset = @view.unpack_virtual_offset(12) return nil if field_offset.zero? @view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, field_offset) end |
#shape ⇒ Object
The dimensions of the tensor, optionally named
37 38 39 40 41 42 43 44 45 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb', line 37 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 |
#strides ⇒ Object
Non-negative byte offsets to advance one value cell along each dimension If omitted, default to row-major order (C-like).
49 50 51 52 53 54 55 56 57 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb', line 49 def strides field_offset = @view.unpack_virtual_offset(10) return nil if field_offset.zero? element_size = 8 @view.unpack_vector(field_offset, element_size) do |element_offset| @view.unpack_long(element_offset) end 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
61 62 63 64 65 66 67 68 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb', line 61 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
70 71 72 73 74 75 76 77 78 |
# File 'lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb', line 70 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 |