1#![allow(dead_code)]
19#![allow(unused_imports)]
20
21use crate::gen::Schema::*;
22use flatbuffers::EndianScalar;
23use std::{cmp::Ordering, mem};
24pub enum TensorDimOffset {}
29#[derive(Copy, Clone, PartialEq)]
30
31pub struct TensorDim<'a> {
35 pub _tab: flatbuffers::Table<'a>,
36}
37
38impl<'a> flatbuffers::Follow<'a> for TensorDim<'a> {
39 type Inner = TensorDim<'a>;
40 #[inline]
41 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
42 Self {
43 _tab: flatbuffers::Table::new(buf, loc),
44 }
45 }
46}
47
48impl<'a> TensorDim<'a> {
49 pub const VT_SIZE_: flatbuffers::VOffsetT = 4;
50 pub const VT_NAME: flatbuffers::VOffsetT = 6;
51
52 #[inline]
53 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
54 TensorDim { _tab: table }
55 }
56 #[allow(unused_mut)]
57 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
58 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
59 args: &'args TensorDimArgs<'args>,
60 ) -> flatbuffers::WIPOffset<TensorDim<'bldr>> {
61 let mut builder = TensorDimBuilder::new(_fbb);
62 builder.add_size_(args.size_);
63 if let Some(x) = args.name {
64 builder.add_name(x);
65 }
66 builder.finish()
67 }
68
69 #[inline]
71 pub fn size_(&self) -> i64 {
72 unsafe { self._tab.get::<i64>(TensorDim::VT_SIZE_, Some(0)).unwrap() }
76 }
77 #[inline]
79 pub fn name(&self) -> Option<&'a str> {
80 unsafe {
84 self._tab
85 .get::<flatbuffers::ForwardsUOffset<&str>>(TensorDim::VT_NAME, None)
86 }
87 }
88}
89
90impl flatbuffers::Verifiable for TensorDim<'_> {
91 #[inline]
92 fn run_verifier(
93 v: &mut flatbuffers::Verifier,
94 pos: usize,
95 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
96 use flatbuffers::Verifiable;
97 v.visit_table(pos)?
98 .visit_field::<i64>("size_", Self::VT_SIZE_, false)?
99 .visit_field::<flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
100 .finish();
101 Ok(())
102 }
103}
104pub struct TensorDimArgs<'a> {
105 pub size_: i64,
106 pub name: Option<flatbuffers::WIPOffset<&'a str>>,
107}
108impl<'a> Default for TensorDimArgs<'a> {
109 #[inline]
110 fn default() -> Self {
111 TensorDimArgs {
112 size_: 0,
113 name: None,
114 }
115 }
116}
117
118pub struct TensorDimBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
119 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
120 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
121}
122impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TensorDimBuilder<'a, 'b, A> {
123 #[inline]
124 pub fn add_size_(&mut self, size_: i64) {
125 self.fbb_.push_slot::<i64>(TensorDim::VT_SIZE_, size_, 0);
126 }
127 #[inline]
128 pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
129 self.fbb_
130 .push_slot_always::<flatbuffers::WIPOffset<_>>(TensorDim::VT_NAME, name);
131 }
132 #[inline]
133 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TensorDimBuilder<'a, 'b, A> {
134 let start = _fbb.start_table();
135 TensorDimBuilder {
136 fbb_: _fbb,
137 start_: start,
138 }
139 }
140 #[inline]
141 pub fn finish(self) -> flatbuffers::WIPOffset<TensorDim<'a>> {
142 let o = self.fbb_.end_table(self.start_);
143 flatbuffers::WIPOffset::new(o.value())
144 }
145}
146
147impl core::fmt::Debug for TensorDim<'_> {
148 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
149 let mut ds = f.debug_struct("TensorDim");
150 ds.field("size_", &self.size_());
151 ds.field("name", &self.name());
152 ds.finish()
153 }
154}
155pub enum TensorOffset {}
156#[derive(Copy, Clone, PartialEq)]
157
158pub struct Tensor<'a> {
159 pub _tab: flatbuffers::Table<'a>,
160}
161
162impl<'a> flatbuffers::Follow<'a> for Tensor<'a> {
163 type Inner = Tensor<'a>;
164 #[inline]
165 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
166 Self {
167 _tab: flatbuffers::Table::new(buf, loc),
168 }
169 }
170}
171
172impl<'a> Tensor<'a> {
173 pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4;
174 pub const VT_TYPE_: flatbuffers::VOffsetT = 6;
175 pub const VT_SHAPE: flatbuffers::VOffsetT = 8;
176 pub const VT_STRIDES: flatbuffers::VOffsetT = 10;
177 pub const VT_DATA: flatbuffers::VOffsetT = 12;
178
179 #[inline]
180 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
181 Tensor { _tab: table }
182 }
183 #[allow(unused_mut)]
184 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
185 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
186 args: &'args TensorArgs<'args>,
187 ) -> flatbuffers::WIPOffset<Tensor<'bldr>> {
188 let mut builder = TensorBuilder::new(_fbb);
189 if let Some(x) = args.data {
190 builder.add_data(x);
191 }
192 if let Some(x) = args.strides {
193 builder.add_strides(x);
194 }
195 if let Some(x) = args.shape {
196 builder.add_shape(x);
197 }
198 if let Some(x) = args.type_ {
199 builder.add_type_(x);
200 }
201 builder.add_type_type(args.type_type);
202 builder.finish()
203 }
204
205 #[inline]
206 pub fn type_type(&self) -> Type {
207 unsafe {
211 self._tab
212 .get::<Type>(Tensor::VT_TYPE_TYPE, Some(Type::NONE))
213 .unwrap()
214 }
215 }
216 #[inline]
219 pub fn type_(&self) -> flatbuffers::Table<'a> {
220 unsafe {
224 self._tab
225 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Tensor::VT_TYPE_, None)
226 .unwrap()
227 }
228 }
229 #[inline]
231 pub fn shape(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
232 unsafe {
236 self._tab
237 .get::<flatbuffers::ForwardsUOffset<
238 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim>>,
239 >>(Tensor::VT_SHAPE, None)
240 .unwrap()
241 }
242 }
243 #[inline]
246 pub fn strides(&self) -> Option<flatbuffers::Vector<'a, i64>> {
247 unsafe {
251 self._tab
252 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i64>>>(
253 Tensor::VT_STRIDES,
254 None,
255 )
256 }
257 }
258 #[inline]
260 pub fn data(&self) -> &'a Buffer {
261 unsafe { self._tab.get::<Buffer>(Tensor::VT_DATA, None).unwrap() }
265 }
266 #[inline]
267 #[allow(non_snake_case)]
268 pub fn type_as_null(&self) -> Option<Null<'a>> {
269 if self.type_type() == Type::Null {
270 let u = self.type_();
271 Some(unsafe { Null::init_from_table(u) })
275 } else {
276 None
277 }
278 }
279
280 #[inline]
281 #[allow(non_snake_case)]
282 pub fn type_as_int(&self) -> Option<Int<'a>> {
283 if self.type_type() == Type::Int {
284 let u = self.type_();
285 Some(unsafe { Int::init_from_table(u) })
289 } else {
290 None
291 }
292 }
293
294 #[inline]
295 #[allow(non_snake_case)]
296 pub fn type_as_floating_point(&self) -> Option<FloatingPoint<'a>> {
297 if self.type_type() == Type::FloatingPoint {
298 let u = self.type_();
299 Some(unsafe { FloatingPoint::init_from_table(u) })
303 } else {
304 None
305 }
306 }
307
308 #[inline]
309 #[allow(non_snake_case)]
310 pub fn type_as_binary(&self) -> Option<Binary<'a>> {
311 if self.type_type() == Type::Binary {
312 let u = self.type_();
313 Some(unsafe { Binary::init_from_table(u) })
317 } else {
318 None
319 }
320 }
321
322 #[inline]
323 #[allow(non_snake_case)]
324 pub fn type_as_utf_8(&self) -> Option<Utf8<'a>> {
325 if self.type_type() == Type::Utf8 {
326 let u = self.type_();
327 Some(unsafe { Utf8::init_from_table(u) })
331 } else {
332 None
333 }
334 }
335
336 #[inline]
337 #[allow(non_snake_case)]
338 pub fn type_as_bool(&self) -> Option<Bool<'a>> {
339 if self.type_type() == Type::Bool {
340 let u = self.type_();
341 Some(unsafe { Bool::init_from_table(u) })
345 } else {
346 None
347 }
348 }
349
350 #[inline]
351 #[allow(non_snake_case)]
352 pub fn type_as_decimal(&self) -> Option<Decimal<'a>> {
353 if self.type_type() == Type::Decimal {
354 let u = self.type_();
355 Some(unsafe { Decimal::init_from_table(u) })
359 } else {
360 None
361 }
362 }
363
364 #[inline]
365 #[allow(non_snake_case)]
366 pub fn type_as_date(&self) -> Option<Date<'a>> {
367 if self.type_type() == Type::Date {
368 let u = self.type_();
369 Some(unsafe { Date::init_from_table(u) })
373 } else {
374 None
375 }
376 }
377
378 #[inline]
379 #[allow(non_snake_case)]
380 pub fn type_as_time(&self) -> Option<Time<'a>> {
381 if self.type_type() == Type::Time {
382 let u = self.type_();
383 Some(unsafe { Time::init_from_table(u) })
387 } else {
388 None
389 }
390 }
391
392 #[inline]
393 #[allow(non_snake_case)]
394 pub fn type_as_timestamp(&self) -> Option<Timestamp<'a>> {
395 if self.type_type() == Type::Timestamp {
396 let u = self.type_();
397 Some(unsafe { Timestamp::init_from_table(u) })
401 } else {
402 None
403 }
404 }
405
406 #[inline]
407 #[allow(non_snake_case)]
408 pub fn type_as_interval(&self) -> Option<Interval<'a>> {
409 if self.type_type() == Type::Interval {
410 let u = self.type_();
411 Some(unsafe { Interval::init_from_table(u) })
415 } else {
416 None
417 }
418 }
419
420 #[inline]
421 #[allow(non_snake_case)]
422 pub fn type_as_list(&self) -> Option<List<'a>> {
423 if self.type_type() == Type::List {
424 let u = self.type_();
425 Some(unsafe { List::init_from_table(u) })
429 } else {
430 None
431 }
432 }
433
434 #[inline]
435 #[allow(non_snake_case)]
436 pub fn type_as_struct_(&self) -> Option<Struct_<'a>> {
437 if self.type_type() == Type::Struct_ {
438 let u = self.type_();
439 Some(unsafe { Struct_::init_from_table(u) })
443 } else {
444 None
445 }
446 }
447
448 #[inline]
449 #[allow(non_snake_case)]
450 pub fn type_as_union(&self) -> Option<Union<'a>> {
451 if self.type_type() == Type::Union {
452 let u = self.type_();
453 Some(unsafe { Union::init_from_table(u) })
457 } else {
458 None
459 }
460 }
461
462 #[inline]
463 #[allow(non_snake_case)]
464 pub fn type_as_fixed_size_binary(&self) -> Option<FixedSizeBinary<'a>> {
465 if self.type_type() == Type::FixedSizeBinary {
466 let u = self.type_();
467 Some(unsafe { FixedSizeBinary::init_from_table(u) })
471 } else {
472 None
473 }
474 }
475
476 #[inline]
477 #[allow(non_snake_case)]
478 pub fn type_as_fixed_size_list(&self) -> Option<FixedSizeList<'a>> {
479 if self.type_type() == Type::FixedSizeList {
480 let u = self.type_();
481 Some(unsafe { FixedSizeList::init_from_table(u) })
485 } else {
486 None
487 }
488 }
489
490 #[inline]
491 #[allow(non_snake_case)]
492 pub fn type_as_map(&self) -> Option<Map<'a>> {
493 if self.type_type() == Type::Map {
494 let u = self.type_();
495 Some(unsafe { Map::init_from_table(u) })
499 } else {
500 None
501 }
502 }
503
504 #[inline]
505 #[allow(non_snake_case)]
506 pub fn type_as_duration(&self) -> Option<Duration<'a>> {
507 if self.type_type() == Type::Duration {
508 let u = self.type_();
509 Some(unsafe { Duration::init_from_table(u) })
513 } else {
514 None
515 }
516 }
517
518 #[inline]
519 #[allow(non_snake_case)]
520 pub fn type_as_large_binary(&self) -> Option<LargeBinary<'a>> {
521 if self.type_type() == Type::LargeBinary {
522 let u = self.type_();
523 Some(unsafe { LargeBinary::init_from_table(u) })
527 } else {
528 None
529 }
530 }
531
532 #[inline]
533 #[allow(non_snake_case)]
534 pub fn type_as_large_utf_8(&self) -> Option<LargeUtf8<'a>> {
535 if self.type_type() == Type::LargeUtf8 {
536 let u = self.type_();
537 Some(unsafe { LargeUtf8::init_from_table(u) })
541 } else {
542 None
543 }
544 }
545
546 #[inline]
547 #[allow(non_snake_case)]
548 pub fn type_as_large_list(&self) -> Option<LargeList<'a>> {
549 if self.type_type() == Type::LargeList {
550 let u = self.type_();
551 Some(unsafe { LargeList::init_from_table(u) })
555 } else {
556 None
557 }
558 }
559
560 #[inline]
561 #[allow(non_snake_case)]
562 pub fn type_as_run_end_encoded(&self) -> Option<RunEndEncoded<'a>> {
563 if self.type_type() == Type::RunEndEncoded {
564 let u = self.type_();
565 Some(unsafe { RunEndEncoded::init_from_table(u) })
569 } else {
570 None
571 }
572 }
573
574 #[inline]
575 #[allow(non_snake_case)]
576 pub fn type_as_binary_view(&self) -> Option<BinaryView<'a>> {
577 if self.type_type() == Type::BinaryView {
578 let u = self.type_();
579 Some(unsafe { BinaryView::init_from_table(u) })
583 } else {
584 None
585 }
586 }
587
588 #[inline]
589 #[allow(non_snake_case)]
590 pub fn type_as_utf_8_view(&self) -> Option<Utf8View<'a>> {
591 if self.type_type() == Type::Utf8View {
592 let u = self.type_();
593 Some(unsafe { Utf8View::init_from_table(u) })
597 } else {
598 None
599 }
600 }
601
602 #[inline]
603 #[allow(non_snake_case)]
604 pub fn type_as_list_view(&self) -> Option<ListView<'a>> {
605 if self.type_type() == Type::ListView {
606 let u = self.type_();
607 Some(unsafe { ListView::init_from_table(u) })
611 } else {
612 None
613 }
614 }
615
616 #[inline]
617 #[allow(non_snake_case)]
618 pub fn type_as_large_list_view(&self) -> Option<LargeListView<'a>> {
619 if self.type_type() == Type::LargeListView {
620 let u = self.type_();
621 Some(unsafe { LargeListView::init_from_table(u) })
625 } else {
626 None
627 }
628 }
629}
630
631impl flatbuffers::Verifiable for Tensor<'_> {
632 #[inline]
633 fn run_verifier(
634 v: &mut flatbuffers::Verifier,
635 pos: usize,
636 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
637 use flatbuffers::Verifiable;
638 v.visit_table(pos)?
639 .visit_union::<Type, _>(
640 "type_type",
641 Self::VT_TYPE_TYPE,
642 "type_",
643 Self::VT_TYPE_,
644 true,
645 |key, v, pos| match key {
646 Type::Null => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>(
647 "Type::Null",
648 pos,
649 ),
650 Type::Int => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>(
651 "Type::Int",
652 pos,
653 ),
654 Type::FloatingPoint => v
655 .verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>(
656 "Type::FloatingPoint",
657 pos,
658 ),
659 Type::Binary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>(
660 "Type::Binary",
661 pos,
662 ),
663 Type::Utf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>(
664 "Type::Utf8",
665 pos,
666 ),
667 Type::Bool => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>(
668 "Type::Bool",
669 pos,
670 ),
671 Type::Decimal => v
672 .verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>(
673 "Type::Decimal",
674 pos,
675 ),
676 Type::Date => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>(
677 "Type::Date",
678 pos,
679 ),
680 Type::Time => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>(
681 "Type::Time",
682 pos,
683 ),
684 Type::Timestamp => v
685 .verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>(
686 "Type::Timestamp",
687 pos,
688 ),
689 Type::Interval => v
690 .verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>(
691 "Type::Interval",
692 pos,
693 ),
694 Type::List => v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>(
695 "Type::List",
696 pos,
697 ),
698 Type::Struct_ => v
699 .verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>(
700 "Type::Struct_",
701 pos,
702 ),
703 Type::Union => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>(
704 "Type::Union",
705 pos,
706 ),
707 Type::FixedSizeBinary => v
708 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>(
709 "Type::FixedSizeBinary",
710 pos,
711 ),
712 Type::FixedSizeList => v
713 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>(
714 "Type::FixedSizeList",
715 pos,
716 ),
717 Type::Map => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>(
718 "Type::Map",
719 pos,
720 ),
721 Type::Duration => v
722 .verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>(
723 "Type::Duration",
724 pos,
725 ),
726 Type::LargeBinary => v
727 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>(
728 "Type::LargeBinary",
729 pos,
730 ),
731 Type::LargeUtf8 => v
732 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>(
733 "Type::LargeUtf8",
734 pos,
735 ),
736 Type::LargeList => v
737 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>(
738 "Type::LargeList",
739 pos,
740 ),
741 Type::RunEndEncoded => v
742 .verify_union_variant::<flatbuffers::ForwardsUOffset<RunEndEncoded>>(
743 "Type::RunEndEncoded",
744 pos,
745 ),
746 Type::BinaryView => v
747 .verify_union_variant::<flatbuffers::ForwardsUOffset<BinaryView>>(
748 "Type::BinaryView",
749 pos,
750 ),
751 Type::Utf8View => v
752 .verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8View>>(
753 "Type::Utf8View",
754 pos,
755 ),
756 Type::ListView => v
757 .verify_union_variant::<flatbuffers::ForwardsUOffset<ListView>>(
758 "Type::ListView",
759 pos,
760 ),
761 Type::LargeListView => v
762 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeListView>>(
763 "Type::LargeListView",
764 pos,
765 ),
766 _ => Ok(()),
767 },
768 )?
769 .visit_field::<flatbuffers::ForwardsUOffset<
770 flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<TensorDim>>,
771 >>("shape", Self::VT_SHAPE, true)?
772 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
773 "strides",
774 Self::VT_STRIDES,
775 false,
776 )?
777 .visit_field::<Buffer>("data", Self::VT_DATA, true)?
778 .finish();
779 Ok(())
780 }
781}
782pub struct TensorArgs<'a> {
783 pub type_type: Type,
784 pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
785 pub shape: Option<
786 flatbuffers::WIPOffset<
787 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
788 >,
789 >,
790 pub strides: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
791 pub data: Option<&'a Buffer>,
792}
793impl<'a> Default for TensorArgs<'a> {
794 #[inline]
795 fn default() -> Self {
796 TensorArgs {
797 type_type: Type::NONE,
798 type_: None, shape: None, strides: None,
801 data: None, }
803 }
804}
805
806pub struct TensorBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
807 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
808 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
809}
810impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TensorBuilder<'a, 'b, A> {
811 #[inline]
812 pub fn add_type_type(&mut self, type_type: Type) {
813 self.fbb_
814 .push_slot::<Type>(Tensor::VT_TYPE_TYPE, type_type, Type::NONE);
815 }
816 #[inline]
817 pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
818 self.fbb_
819 .push_slot_always::<flatbuffers::WIPOffset<_>>(Tensor::VT_TYPE_, type_);
820 }
821 #[inline]
822 pub fn add_shape(
823 &mut self,
824 shape: flatbuffers::WIPOffset<
825 flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<TensorDim<'b>>>,
826 >,
827 ) {
828 self.fbb_
829 .push_slot_always::<flatbuffers::WIPOffset<_>>(Tensor::VT_SHAPE, shape);
830 }
831 #[inline]
832 pub fn add_strides(&mut self, strides: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i64>>) {
833 self.fbb_
834 .push_slot_always::<flatbuffers::WIPOffset<_>>(Tensor::VT_STRIDES, strides);
835 }
836 #[inline]
837 pub fn add_data(&mut self, data: &Buffer) {
838 self.fbb_.push_slot_always::<&Buffer>(Tensor::VT_DATA, data);
839 }
840 #[inline]
841 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TensorBuilder<'a, 'b, A> {
842 let start = _fbb.start_table();
843 TensorBuilder {
844 fbb_: _fbb,
845 start_: start,
846 }
847 }
848 #[inline]
849 pub fn finish(self) -> flatbuffers::WIPOffset<Tensor<'a>> {
850 let o = self.fbb_.end_table(self.start_);
851 self.fbb_.required(o, Tensor::VT_TYPE_, "type_");
852 self.fbb_.required(o, Tensor::VT_SHAPE, "shape");
853 self.fbb_.required(o, Tensor::VT_DATA, "data");
854 flatbuffers::WIPOffset::new(o.value())
855 }
856}
857
858impl core::fmt::Debug for Tensor<'_> {
859 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
860 let mut ds = f.debug_struct("Tensor");
861 ds.field("type_type", &self.type_type());
862 match self.type_type() {
863 Type::Null => {
864 if let Some(x) = self.type_as_null() {
865 ds.field("type_", &x)
866 } else {
867 ds.field(
868 "type_",
869 &"InvalidFlatbuffer: Union discriminant does not match value.",
870 )
871 }
872 }
873 Type::Int => {
874 if let Some(x) = self.type_as_int() {
875 ds.field("type_", &x)
876 } else {
877 ds.field(
878 "type_",
879 &"InvalidFlatbuffer: Union discriminant does not match value.",
880 )
881 }
882 }
883 Type::FloatingPoint => {
884 if let Some(x) = self.type_as_floating_point() {
885 ds.field("type_", &x)
886 } else {
887 ds.field(
888 "type_",
889 &"InvalidFlatbuffer: Union discriminant does not match value.",
890 )
891 }
892 }
893 Type::Binary => {
894 if let Some(x) = self.type_as_binary() {
895 ds.field("type_", &x)
896 } else {
897 ds.field(
898 "type_",
899 &"InvalidFlatbuffer: Union discriminant does not match value.",
900 )
901 }
902 }
903 Type::Utf8 => {
904 if let Some(x) = self.type_as_utf_8() {
905 ds.field("type_", &x)
906 } else {
907 ds.field(
908 "type_",
909 &"InvalidFlatbuffer: Union discriminant does not match value.",
910 )
911 }
912 }
913 Type::Bool => {
914 if let Some(x) = self.type_as_bool() {
915 ds.field("type_", &x)
916 } else {
917 ds.field(
918 "type_",
919 &"InvalidFlatbuffer: Union discriminant does not match value.",
920 )
921 }
922 }
923 Type::Decimal => {
924 if let Some(x) = self.type_as_decimal() {
925 ds.field("type_", &x)
926 } else {
927 ds.field(
928 "type_",
929 &"InvalidFlatbuffer: Union discriminant does not match value.",
930 )
931 }
932 }
933 Type::Date => {
934 if let Some(x) = self.type_as_date() {
935 ds.field("type_", &x)
936 } else {
937 ds.field(
938 "type_",
939 &"InvalidFlatbuffer: Union discriminant does not match value.",
940 )
941 }
942 }
943 Type::Time => {
944 if let Some(x) = self.type_as_time() {
945 ds.field("type_", &x)
946 } else {
947 ds.field(
948 "type_",
949 &"InvalidFlatbuffer: Union discriminant does not match value.",
950 )
951 }
952 }
953 Type::Timestamp => {
954 if let Some(x) = self.type_as_timestamp() {
955 ds.field("type_", &x)
956 } else {
957 ds.field(
958 "type_",
959 &"InvalidFlatbuffer: Union discriminant does not match value.",
960 )
961 }
962 }
963 Type::Interval => {
964 if let Some(x) = self.type_as_interval() {
965 ds.field("type_", &x)
966 } else {
967 ds.field(
968 "type_",
969 &"InvalidFlatbuffer: Union discriminant does not match value.",
970 )
971 }
972 }
973 Type::List => {
974 if let Some(x) = self.type_as_list() {
975 ds.field("type_", &x)
976 } else {
977 ds.field(
978 "type_",
979 &"InvalidFlatbuffer: Union discriminant does not match value.",
980 )
981 }
982 }
983 Type::Struct_ => {
984 if let Some(x) = self.type_as_struct_() {
985 ds.field("type_", &x)
986 } else {
987 ds.field(
988 "type_",
989 &"InvalidFlatbuffer: Union discriminant does not match value.",
990 )
991 }
992 }
993 Type::Union => {
994 if let Some(x) = self.type_as_union() {
995 ds.field("type_", &x)
996 } else {
997 ds.field(
998 "type_",
999 &"InvalidFlatbuffer: Union discriminant does not match value.",
1000 )
1001 }
1002 }
1003 Type::FixedSizeBinary => {
1004 if let Some(x) = self.type_as_fixed_size_binary() {
1005 ds.field("type_", &x)
1006 } else {
1007 ds.field(
1008 "type_",
1009 &"InvalidFlatbuffer: Union discriminant does not match value.",
1010 )
1011 }
1012 }
1013 Type::FixedSizeList => {
1014 if let Some(x) = self.type_as_fixed_size_list() {
1015 ds.field("type_", &x)
1016 } else {
1017 ds.field(
1018 "type_",
1019 &"InvalidFlatbuffer: Union discriminant does not match value.",
1020 )
1021 }
1022 }
1023 Type::Map => {
1024 if let Some(x) = self.type_as_map() {
1025 ds.field("type_", &x)
1026 } else {
1027 ds.field(
1028 "type_",
1029 &"InvalidFlatbuffer: Union discriminant does not match value.",
1030 )
1031 }
1032 }
1033 Type::Duration => {
1034 if let Some(x) = self.type_as_duration() {
1035 ds.field("type_", &x)
1036 } else {
1037 ds.field(
1038 "type_",
1039 &"InvalidFlatbuffer: Union discriminant does not match value.",
1040 )
1041 }
1042 }
1043 Type::LargeBinary => {
1044 if let Some(x) = self.type_as_large_binary() {
1045 ds.field("type_", &x)
1046 } else {
1047 ds.field(
1048 "type_",
1049 &"InvalidFlatbuffer: Union discriminant does not match value.",
1050 )
1051 }
1052 }
1053 Type::LargeUtf8 => {
1054 if let Some(x) = self.type_as_large_utf_8() {
1055 ds.field("type_", &x)
1056 } else {
1057 ds.field(
1058 "type_",
1059 &"InvalidFlatbuffer: Union discriminant does not match value.",
1060 )
1061 }
1062 }
1063 Type::LargeList => {
1064 if let Some(x) = self.type_as_large_list() {
1065 ds.field("type_", &x)
1066 } else {
1067 ds.field(
1068 "type_",
1069 &"InvalidFlatbuffer: Union discriminant does not match value.",
1070 )
1071 }
1072 }
1073 Type::RunEndEncoded => {
1074 if let Some(x) = self.type_as_run_end_encoded() {
1075 ds.field("type_", &x)
1076 } else {
1077 ds.field(
1078 "type_",
1079 &"InvalidFlatbuffer: Union discriminant does not match value.",
1080 )
1081 }
1082 }
1083 Type::BinaryView => {
1084 if let Some(x) = self.type_as_binary_view() {
1085 ds.field("type_", &x)
1086 } else {
1087 ds.field(
1088 "type_",
1089 &"InvalidFlatbuffer: Union discriminant does not match value.",
1090 )
1091 }
1092 }
1093 Type::Utf8View => {
1094 if let Some(x) = self.type_as_utf_8_view() {
1095 ds.field("type_", &x)
1096 } else {
1097 ds.field(
1098 "type_",
1099 &"InvalidFlatbuffer: Union discriminant does not match value.",
1100 )
1101 }
1102 }
1103 Type::ListView => {
1104 if let Some(x) = self.type_as_list_view() {
1105 ds.field("type_", &x)
1106 } else {
1107 ds.field(
1108 "type_",
1109 &"InvalidFlatbuffer: Union discriminant does not match value.",
1110 )
1111 }
1112 }
1113 Type::LargeListView => {
1114 if let Some(x) = self.type_as_large_list_view() {
1115 ds.field("type_", &x)
1116 } else {
1117 ds.field(
1118 "type_",
1119 &"InvalidFlatbuffer: Union discriminant does not match value.",
1120 )
1121 }
1122 }
1123 _ => {
1124 let x: Option<()> = None;
1125 ds.field("type_", &x)
1126 }
1127 };
1128 ds.field("shape", &self.shape());
1129 ds.field("strides", &self.strides());
1130 ds.field("data", &self.data());
1131 ds.finish()
1132 }
1133}
1134#[inline]
1135pub fn root_as_tensor(buf: &[u8]) -> Result<Tensor, flatbuffers::InvalidFlatbuffer> {
1142 flatbuffers::root::<Tensor>(buf)
1143}
1144#[inline]
1145pub fn size_prefixed_root_as_tensor(buf: &[u8]) -> Result<Tensor, flatbuffers::InvalidFlatbuffer> {
1152 flatbuffers::size_prefixed_root::<Tensor>(buf)
1153}
1154#[inline]
1155pub fn root_as_tensor_with_opts<'b, 'o>(
1162 opts: &'o flatbuffers::VerifierOptions,
1163 buf: &'b [u8],
1164) -> Result<Tensor<'b>, flatbuffers::InvalidFlatbuffer> {
1165 flatbuffers::root_with_opts::<Tensor<'b>>(opts, buf)
1166}
1167#[inline]
1168pub fn size_prefixed_root_as_tensor_with_opts<'b, 'o>(
1175 opts: &'o flatbuffers::VerifierOptions,
1176 buf: &'b [u8],
1177) -> Result<Tensor<'b>, flatbuffers::InvalidFlatbuffer> {
1178 flatbuffers::size_prefixed_root_with_opts::<Tensor<'b>>(opts, buf)
1179}
1180#[inline]
1181pub unsafe fn root_as_tensor_unchecked(buf: &[u8]) -> Tensor {
1185 flatbuffers::root_unchecked::<Tensor>(buf)
1186}
1187#[inline]
1188pub unsafe fn size_prefixed_root_as_tensor_unchecked(buf: &[u8]) -> Tensor {
1192 flatbuffers::size_prefixed_root_unchecked::<Tensor>(buf)
1193}
1194#[inline]
1195pub fn finish_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
1196 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1197 root: flatbuffers::WIPOffset<Tensor<'a>>,
1198) {
1199 fbb.finish(root, None);
1200}
1201
1202#[inline]
1203pub fn finish_size_prefixed_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
1204 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1205 root: flatbuffers::WIPOffset<Tensor<'a>>,
1206) {
1207 fbb.finish_size_prefixed(root, None);
1208}