1#![allow(dead_code)]
19#![allow(unused_imports)]
20
21use crate::r#gen::Schema::*;
22use crate::r#gen::Tensor::*;
23use flatbuffers::EndianScalar;
24use std::{cmp::Ordering, mem};
25#[deprecated(
30 since = "2.0.0",
31 note = "Use associated constants instead. This will no longer be generated in 2021."
32)]
33pub const ENUM_MIN_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 0;
34#[deprecated(
35 since = "2.0.0",
36 note = "Use associated constants instead. This will no longer be generated in 2021."
37)]
38pub const ENUM_MAX_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 1;
39#[deprecated(
40 since = "2.0.0",
41 note = "Use associated constants instead. This will no longer be generated in 2021."
42)]
43#[allow(non_camel_case_types)]
44pub const ENUM_VALUES_SPARSE_MATRIX_COMPRESSED_AXIS: [SparseMatrixCompressedAxis; 2] = [
45 SparseMatrixCompressedAxis::Row,
46 SparseMatrixCompressedAxis::Column,
47];
48
49#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
50#[repr(transparent)]
51pub struct SparseMatrixCompressedAxis(pub i16);
52#[allow(non_upper_case_globals)]
53impl SparseMatrixCompressedAxis {
54 pub const Row: Self = Self(0);
55 pub const Column: Self = Self(1);
56
57 pub const ENUM_MIN: i16 = 0;
58 pub const ENUM_MAX: i16 = 1;
59 pub const ENUM_VALUES: &'static [Self] = &[Self::Row, Self::Column];
60 pub fn variant_name(self) -> Option<&'static str> {
62 match self {
63 Self::Row => Some("Row"),
64 Self::Column => Some("Column"),
65 _ => None,
66 }
67 }
68}
69impl core::fmt::Debug for SparseMatrixCompressedAxis {
70 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
71 if let Some(name) = self.variant_name() {
72 f.write_str(name)
73 } else {
74 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
75 }
76 }
77}
78impl<'a> flatbuffers::Follow<'a> for SparseMatrixCompressedAxis {
79 type Inner = Self;
80 #[inline]
81 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
82 let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
83 Self(b)
84 }
85}
86
87impl flatbuffers::Push for SparseMatrixCompressedAxis {
88 type Output = SparseMatrixCompressedAxis;
89 #[inline]
90 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
91 unsafe {
92 flatbuffers::emplace_scalar::<i16>(dst, self.0);
93 }
94 }
95}
96
97impl flatbuffers::EndianScalar for SparseMatrixCompressedAxis {
98 type Scalar = i16;
99 #[inline]
100 fn to_little_endian(self) -> i16 {
101 self.0.to_le()
102 }
103 #[inline]
104 #[allow(clippy::wrong_self_convention)]
105 fn from_little_endian(v: i16) -> Self {
106 let b = i16::from_le(v);
107 Self(b)
108 }
109}
110
111impl<'a> flatbuffers::Verifiable for SparseMatrixCompressedAxis {
112 #[inline]
113 fn run_verifier(
114 v: &mut flatbuffers::Verifier,
115 pos: usize,
116 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
117 use flatbuffers::Verifiable;
118 i16::run_verifier(v, pos)
119 }
120}
121
122impl flatbuffers::SimpleToVerifyInSlice for SparseMatrixCompressedAxis {}
123#[deprecated(
124 since = "2.0.0",
125 note = "Use associated constants instead. This will no longer be generated in 2021."
126)]
127pub const ENUM_MIN_SPARSE_TENSOR_INDEX: u8 = 0;
128#[deprecated(
129 since = "2.0.0",
130 note = "Use associated constants instead. This will no longer be generated in 2021."
131)]
132pub const ENUM_MAX_SPARSE_TENSOR_INDEX: u8 = 3;
133#[deprecated(
134 since = "2.0.0",
135 note = "Use associated constants instead. This will no longer be generated in 2021."
136)]
137#[allow(non_camel_case_types)]
138pub const ENUM_VALUES_SPARSE_TENSOR_INDEX: [SparseTensorIndex; 4] = [
139 SparseTensorIndex::NONE,
140 SparseTensorIndex::SparseTensorIndexCOO,
141 SparseTensorIndex::SparseMatrixIndexCSX,
142 SparseTensorIndex::SparseTensorIndexCSF,
143];
144
145#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
146#[repr(transparent)]
147pub struct SparseTensorIndex(pub u8);
148#[allow(non_upper_case_globals)]
149impl SparseTensorIndex {
150 pub const NONE: Self = Self(0);
151 pub const SparseTensorIndexCOO: Self = Self(1);
152 pub const SparseMatrixIndexCSX: Self = Self(2);
153 pub const SparseTensorIndexCSF: Self = Self(3);
154
155 pub const ENUM_MIN: u8 = 0;
156 pub const ENUM_MAX: u8 = 3;
157 pub const ENUM_VALUES: &'static [Self] = &[
158 Self::NONE,
159 Self::SparseTensorIndexCOO,
160 Self::SparseMatrixIndexCSX,
161 Self::SparseTensorIndexCSF,
162 ];
163 pub fn variant_name(self) -> Option<&'static str> {
165 match self {
166 Self::NONE => Some("NONE"),
167 Self::SparseTensorIndexCOO => Some("SparseTensorIndexCOO"),
168 Self::SparseMatrixIndexCSX => Some("SparseMatrixIndexCSX"),
169 Self::SparseTensorIndexCSF => Some("SparseTensorIndexCSF"),
170 _ => None,
171 }
172 }
173}
174impl core::fmt::Debug for SparseTensorIndex {
175 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
176 if let Some(name) = self.variant_name() {
177 f.write_str(name)
178 } else {
179 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
180 }
181 }
182}
183impl<'a> flatbuffers::Follow<'a> for SparseTensorIndex {
184 type Inner = Self;
185 #[inline]
186 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
187 let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
188 Self(b)
189 }
190}
191
192impl flatbuffers::Push for SparseTensorIndex {
193 type Output = SparseTensorIndex;
194 #[inline]
195 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
196 unsafe {
197 flatbuffers::emplace_scalar::<u8>(dst, self.0);
198 }
199 }
200}
201
202impl flatbuffers::EndianScalar for SparseTensorIndex {
203 type Scalar = u8;
204 #[inline]
205 fn to_little_endian(self) -> u8 {
206 self.0.to_le()
207 }
208 #[inline]
209 #[allow(clippy::wrong_self_convention)]
210 fn from_little_endian(v: u8) -> Self {
211 let b = u8::from_le(v);
212 Self(b)
213 }
214}
215
216impl<'a> flatbuffers::Verifiable for SparseTensorIndex {
217 #[inline]
218 fn run_verifier(
219 v: &mut flatbuffers::Verifier,
220 pos: usize,
221 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
222 use flatbuffers::Verifiable;
223 u8::run_verifier(v, pos)
224 }
225}
226
227impl flatbuffers::SimpleToVerifyInSlice for SparseTensorIndex {}
228pub struct SparseTensorIndexUnionTableOffset {}
229
230pub enum SparseTensorIndexCOOOffset {}
231#[derive(Copy, Clone, PartialEq)]
232
233pub struct SparseTensorIndexCOO<'a> {
266 pub _tab: flatbuffers::Table<'a>,
267}
268
269impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCOO<'a> {
270 type Inner = SparseTensorIndexCOO<'a>;
271 #[inline]
272 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
273 Self {
274 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
275 }
276 }
277}
278
279impl<'a> SparseTensorIndexCOO<'a> {
280 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 4;
281 pub const VT_INDICESSTRIDES: flatbuffers::VOffsetT = 6;
282 pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 8;
283 pub const VT_ISCANONICAL: flatbuffers::VOffsetT = 10;
284
285 #[inline]
286 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
287 SparseTensorIndexCOO { _tab: table }
288 }
289 #[allow(unused_mut)]
290 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
291 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
292 args: &'args SparseTensorIndexCOOArgs<'args>,
293 ) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'bldr>> {
294 let mut builder = SparseTensorIndexCOOBuilder::new(_fbb);
295 if let Some(x) = args.indicesBuffer {
296 builder.add_indicesBuffer(x);
297 }
298 if let Some(x) = args.indicesStrides {
299 builder.add_indicesStrides(x);
300 }
301 if let Some(x) = args.indicesType {
302 builder.add_indicesType(x);
303 }
304 builder.add_isCanonical(args.isCanonical);
305 builder.finish()
306 }
307
308 #[inline]
310 pub fn indicesType(&self) -> Int<'a> {
311 unsafe {
315 self._tab
316 .get::<flatbuffers::ForwardsUOffset<Int>>(
317 SparseTensorIndexCOO::VT_INDICESTYPE,
318 None,
319 )
320 .unwrap()
321 }
322 }
323 #[inline]
326 pub fn indicesStrides(&self) -> Option<flatbuffers::Vector<'a, i64>> {
327 unsafe {
331 self._tab
332 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i64>>>(
333 SparseTensorIndexCOO::VT_INDICESSTRIDES,
334 None,
335 )
336 }
337 }
338 #[inline]
340 pub fn indicesBuffer(&self) -> &'a Buffer {
341 unsafe {
345 self._tab
346 .get::<Buffer>(SparseTensorIndexCOO::VT_INDICESBUFFER, None)
347 .unwrap()
348 }
349 }
350 #[inline]
356 pub fn isCanonical(&self) -> bool {
357 unsafe {
361 self._tab
362 .get::<bool>(SparseTensorIndexCOO::VT_ISCANONICAL, Some(false))
363 .unwrap()
364 }
365 }
366}
367
368impl flatbuffers::Verifiable for SparseTensorIndexCOO<'_> {
369 #[inline]
370 fn run_verifier(
371 v: &mut flatbuffers::Verifier,
372 pos: usize,
373 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
374 use flatbuffers::Verifiable;
375 v.visit_table(pos)?
376 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
377 "indicesType",
378 Self::VT_INDICESTYPE,
379 true,
380 )?
381 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
382 "indicesStrides",
383 Self::VT_INDICESSTRIDES,
384 false,
385 )?
386 .visit_field::<Buffer>("indicesBuffer", Self::VT_INDICESBUFFER, true)?
387 .visit_field::<bool>("isCanonical", Self::VT_ISCANONICAL, false)?
388 .finish();
389 Ok(())
390 }
391}
392pub struct SparseTensorIndexCOOArgs<'a> {
393 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
394 pub indicesStrides: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
395 pub indicesBuffer: Option<&'a Buffer>,
396 pub isCanonical: bool,
397}
398impl<'a> Default for SparseTensorIndexCOOArgs<'a> {
399 #[inline]
400 fn default() -> Self {
401 SparseTensorIndexCOOArgs {
402 indicesType: None, indicesStrides: None,
404 indicesBuffer: None, isCanonical: false,
406 }
407 }
408}
409
410pub struct SparseTensorIndexCOOBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
411 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
412 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
413}
414impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorIndexCOOBuilder<'a, 'b, A> {
415 #[inline]
416 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
417 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
418 SparseTensorIndexCOO::VT_INDICESTYPE,
419 indicesType,
420 );
421 }
422 #[inline]
423 pub fn add_indicesStrides(
424 &mut self,
425 indicesStrides: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i64>>,
426 ) {
427 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
428 SparseTensorIndexCOO::VT_INDICESSTRIDES,
429 indicesStrides,
430 );
431 }
432 #[inline]
433 pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
434 self.fbb_
435 .push_slot_always::<&Buffer>(SparseTensorIndexCOO::VT_INDICESBUFFER, indicesBuffer);
436 }
437 #[inline]
438 pub fn add_isCanonical(&mut self, isCanonical: bool) {
439 self.fbb_
440 .push_slot::<bool>(SparseTensorIndexCOO::VT_ISCANONICAL, isCanonical, false);
441 }
442 #[inline]
443 pub fn new(
444 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
445 ) -> SparseTensorIndexCOOBuilder<'a, 'b, A> {
446 let start = _fbb.start_table();
447 SparseTensorIndexCOOBuilder {
448 fbb_: _fbb,
449 start_: start,
450 }
451 }
452 #[inline]
453 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'a>> {
454 let o = self.fbb_.end_table(self.start_);
455 self.fbb_
456 .required(o, SparseTensorIndexCOO::VT_INDICESTYPE, "indicesType");
457 self.fbb_
458 .required(o, SparseTensorIndexCOO::VT_INDICESBUFFER, "indicesBuffer");
459 flatbuffers::WIPOffset::new(o.value())
460 }
461}
462
463impl core::fmt::Debug for SparseTensorIndexCOO<'_> {
464 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
465 let mut ds = f.debug_struct("SparseTensorIndexCOO");
466 ds.field("indicesType", &self.indicesType());
467 ds.field("indicesStrides", &self.indicesStrides());
468 ds.field("indicesBuffer", &self.indicesBuffer());
469 ds.field("isCanonical", &self.isCanonical());
470 ds.finish()
471 }
472}
473pub enum SparseMatrixIndexCSXOffset {}
474#[derive(Copy, Clone, PartialEq)]
475
476pub struct SparseMatrixIndexCSX<'a> {
478 pub _tab: flatbuffers::Table<'a>,
479}
480
481impl<'a> flatbuffers::Follow<'a> for SparseMatrixIndexCSX<'a> {
482 type Inner = SparseMatrixIndexCSX<'a>;
483 #[inline]
484 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
485 Self {
486 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
487 }
488 }
489}
490
491impl<'a> SparseMatrixIndexCSX<'a> {
492 pub const VT_COMPRESSEDAXIS: flatbuffers::VOffsetT = 4;
493 pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 6;
494 pub const VT_INDPTRBUFFER: flatbuffers::VOffsetT = 8;
495 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 10;
496 pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 12;
497
498 #[inline]
499 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
500 SparseMatrixIndexCSX { _tab: table }
501 }
502 #[allow(unused_mut)]
503 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
504 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
505 args: &'args SparseMatrixIndexCSXArgs<'args>,
506 ) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'bldr>> {
507 let mut builder = SparseMatrixIndexCSXBuilder::new(_fbb);
508 if let Some(x) = args.indicesBuffer {
509 builder.add_indicesBuffer(x);
510 }
511 if let Some(x) = args.indicesType {
512 builder.add_indicesType(x);
513 }
514 if let Some(x) = args.indptrBuffer {
515 builder.add_indptrBuffer(x);
516 }
517 if let Some(x) = args.indptrType {
518 builder.add_indptrType(x);
519 }
520 builder.add_compressedAxis(args.compressedAxis);
521 builder.finish()
522 }
523
524 #[inline]
526 pub fn compressedAxis(&self) -> SparseMatrixCompressedAxis {
527 unsafe {
531 self._tab
532 .get::<SparseMatrixCompressedAxis>(
533 SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
534 Some(SparseMatrixCompressedAxis::Row),
535 )
536 .unwrap()
537 }
538 }
539 #[inline]
541 pub fn indptrType(&self) -> Int<'a> {
542 unsafe {
546 self._tab
547 .get::<flatbuffers::ForwardsUOffset<Int>>(SparseMatrixIndexCSX::VT_INDPTRTYPE, None)
548 .unwrap()
549 }
550 }
551 #[inline]
575 pub fn indptrBuffer(&self) -> &'a Buffer {
576 unsafe {
580 self._tab
581 .get::<Buffer>(SparseMatrixIndexCSX::VT_INDPTRBUFFER, None)
582 .unwrap()
583 }
584 }
585 #[inline]
587 pub fn indicesType(&self) -> Int<'a> {
588 unsafe {
592 self._tab
593 .get::<flatbuffers::ForwardsUOffset<Int>>(
594 SparseMatrixIndexCSX::VT_INDICESTYPE,
595 None,
596 )
597 .unwrap()
598 }
599 }
600 #[inline]
610 pub fn indicesBuffer(&self) -> &'a Buffer {
611 unsafe {
615 self._tab
616 .get::<Buffer>(SparseMatrixIndexCSX::VT_INDICESBUFFER, None)
617 .unwrap()
618 }
619 }
620}
621
622impl flatbuffers::Verifiable for SparseMatrixIndexCSX<'_> {
623 #[inline]
624 fn run_verifier(
625 v: &mut flatbuffers::Verifier,
626 pos: usize,
627 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
628 use flatbuffers::Verifiable;
629 v.visit_table(pos)?
630 .visit_field::<SparseMatrixCompressedAxis>(
631 "compressedAxis",
632 Self::VT_COMPRESSEDAXIS,
633 false,
634 )?
635 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
636 "indptrType",
637 Self::VT_INDPTRTYPE,
638 true,
639 )?
640 .visit_field::<Buffer>("indptrBuffer", Self::VT_INDPTRBUFFER, true)?
641 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
642 "indicesType",
643 Self::VT_INDICESTYPE,
644 true,
645 )?
646 .visit_field::<Buffer>("indicesBuffer", Self::VT_INDICESBUFFER, true)?
647 .finish();
648 Ok(())
649 }
650}
651pub struct SparseMatrixIndexCSXArgs<'a> {
652 pub compressedAxis: SparseMatrixCompressedAxis,
653 pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
654 pub indptrBuffer: Option<&'a Buffer>,
655 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
656 pub indicesBuffer: Option<&'a Buffer>,
657}
658impl<'a> Default for SparseMatrixIndexCSXArgs<'a> {
659 #[inline]
660 fn default() -> Self {
661 SparseMatrixIndexCSXArgs {
662 compressedAxis: SparseMatrixCompressedAxis::Row,
663 indptrType: None, indptrBuffer: None, indicesType: None, indicesBuffer: None, }
668 }
669}
670
671pub struct SparseMatrixIndexCSXBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
672 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
673 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
674}
675impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseMatrixIndexCSXBuilder<'a, 'b, A> {
676 #[inline]
677 pub fn add_compressedAxis(&mut self, compressedAxis: SparseMatrixCompressedAxis) {
678 self.fbb_.push_slot::<SparseMatrixCompressedAxis>(
679 SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
680 compressedAxis,
681 SparseMatrixCompressedAxis::Row,
682 );
683 }
684 #[inline]
685 pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
686 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
687 SparseMatrixIndexCSX::VT_INDPTRTYPE,
688 indptrType,
689 );
690 }
691 #[inline]
692 pub fn add_indptrBuffer(&mut self, indptrBuffer: &Buffer) {
693 self.fbb_
694 .push_slot_always::<&Buffer>(SparseMatrixIndexCSX::VT_INDPTRBUFFER, indptrBuffer);
695 }
696 #[inline]
697 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
698 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
699 SparseMatrixIndexCSX::VT_INDICESTYPE,
700 indicesType,
701 );
702 }
703 #[inline]
704 pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
705 self.fbb_
706 .push_slot_always::<&Buffer>(SparseMatrixIndexCSX::VT_INDICESBUFFER, indicesBuffer);
707 }
708 #[inline]
709 pub fn new(
710 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
711 ) -> SparseMatrixIndexCSXBuilder<'a, 'b, A> {
712 let start = _fbb.start_table();
713 SparseMatrixIndexCSXBuilder {
714 fbb_: _fbb,
715 start_: start,
716 }
717 }
718 #[inline]
719 pub fn finish(self) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'a>> {
720 let o = self.fbb_.end_table(self.start_);
721 self.fbb_
722 .required(o, SparseMatrixIndexCSX::VT_INDPTRTYPE, "indptrType");
723 self.fbb_
724 .required(o, SparseMatrixIndexCSX::VT_INDPTRBUFFER, "indptrBuffer");
725 self.fbb_
726 .required(o, SparseMatrixIndexCSX::VT_INDICESTYPE, "indicesType");
727 self.fbb_
728 .required(o, SparseMatrixIndexCSX::VT_INDICESBUFFER, "indicesBuffer");
729 flatbuffers::WIPOffset::new(o.value())
730 }
731}
732
733impl core::fmt::Debug for SparseMatrixIndexCSX<'_> {
734 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
735 let mut ds = f.debug_struct("SparseMatrixIndexCSX");
736 ds.field("compressedAxis", &self.compressedAxis());
737 ds.field("indptrType", &self.indptrType());
738 ds.field("indptrBuffer", &self.indptrBuffer());
739 ds.field("indicesType", &self.indicesType());
740 ds.field("indicesBuffer", &self.indicesBuffer());
741 ds.finish()
742 }
743}
744pub enum SparseTensorIndexCSFOffset {}
745#[derive(Copy, Clone, PartialEq)]
746
747pub struct SparseTensorIndexCSF<'a> {
749 pub _tab: flatbuffers::Table<'a>,
750}
751
752impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCSF<'a> {
753 type Inner = SparseTensorIndexCSF<'a>;
754 #[inline]
755 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
756 Self {
757 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
758 }
759 }
760}
761
762impl<'a> SparseTensorIndexCSF<'a> {
763 pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 4;
764 pub const VT_INDPTRBUFFERS: flatbuffers::VOffsetT = 6;
765 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 8;
766 pub const VT_INDICESBUFFERS: flatbuffers::VOffsetT = 10;
767 pub const VT_AXISORDER: flatbuffers::VOffsetT = 12;
768
769 #[inline]
770 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
771 SparseTensorIndexCSF { _tab: table }
772 }
773 #[allow(unused_mut)]
774 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
775 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
776 args: &'args SparseTensorIndexCSFArgs<'args>,
777 ) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'bldr>> {
778 let mut builder = SparseTensorIndexCSFBuilder::new(_fbb);
779 if let Some(x) = args.axisOrder {
780 builder.add_axisOrder(x);
781 }
782 if let Some(x) = args.indicesBuffers {
783 builder.add_indicesBuffers(x);
784 }
785 if let Some(x) = args.indicesType {
786 builder.add_indicesType(x);
787 }
788 if let Some(x) = args.indptrBuffers {
789 builder.add_indptrBuffers(x);
790 }
791 if let Some(x) = args.indptrType {
792 builder.add_indptrType(x);
793 }
794 builder.finish()
795 }
796
797 #[inline]
829 pub fn indptrType(&self) -> Int<'a> {
830 unsafe {
834 self._tab
835 .get::<flatbuffers::ForwardsUOffset<Int>>(SparseTensorIndexCSF::VT_INDPTRTYPE, None)
836 .unwrap()
837 }
838 }
839 #[inline]
854 pub fn indptrBuffers(&self) -> flatbuffers::Vector<'a, Buffer> {
855 unsafe {
859 self._tab
860 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
861 SparseTensorIndexCSF::VT_INDPTRBUFFERS,
862 None,
863 )
864 .unwrap()
865 }
866 }
867 #[inline]
869 pub fn indicesType(&self) -> Int<'a> {
870 unsafe {
874 self._tab
875 .get::<flatbuffers::ForwardsUOffset<Int>>(
876 SparseTensorIndexCSF::VT_INDICESTYPE,
877 None,
878 )
879 .unwrap()
880 }
881 }
882 #[inline]
894 pub fn indicesBuffers(&self) -> flatbuffers::Vector<'a, Buffer> {
895 unsafe {
899 self._tab
900 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
901 SparseTensorIndexCSF::VT_INDICESBUFFERS,
902 None,
903 )
904 .unwrap()
905 }
906 }
907 #[inline]
914 pub fn axisOrder(&self) -> flatbuffers::Vector<'a, i32> {
915 unsafe {
919 self._tab
920 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(
921 SparseTensorIndexCSF::VT_AXISORDER,
922 None,
923 )
924 .unwrap()
925 }
926 }
927}
928
929impl flatbuffers::Verifiable for SparseTensorIndexCSF<'_> {
930 #[inline]
931 fn run_verifier(
932 v: &mut flatbuffers::Verifier,
933 pos: usize,
934 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
935 use flatbuffers::Verifiable;
936 v.visit_table(pos)?
937 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
938 "indptrType",
939 Self::VT_INDPTRTYPE,
940 true,
941 )?
942 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
943 "indptrBuffers",
944 Self::VT_INDPTRBUFFERS,
945 true,
946 )?
947 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
948 "indicesType",
949 Self::VT_INDICESTYPE,
950 true,
951 )?
952 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
953 "indicesBuffers",
954 Self::VT_INDICESBUFFERS,
955 true,
956 )?
957 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(
958 "axisOrder",
959 Self::VT_AXISORDER,
960 true,
961 )?
962 .finish();
963 Ok(())
964 }
965}
966pub struct SparseTensorIndexCSFArgs<'a> {
967 pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
968 pub indptrBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
969 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
970 pub indicesBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
971 pub axisOrder: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
972}
973impl<'a> Default for SparseTensorIndexCSFArgs<'a> {
974 #[inline]
975 fn default() -> Self {
976 SparseTensorIndexCSFArgs {
977 indptrType: None, indptrBuffers: None, indicesType: None, indicesBuffers: None, axisOrder: None, }
983 }
984}
985
986pub struct SparseTensorIndexCSFBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
987 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
988 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
989}
990impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorIndexCSFBuilder<'a, 'b, A> {
991 #[inline]
992 pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
993 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
994 SparseTensorIndexCSF::VT_INDPTRTYPE,
995 indptrType,
996 );
997 }
998 #[inline]
999 pub fn add_indptrBuffers(
1000 &mut self,
1001 indptrBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
1002 ) {
1003 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1004 SparseTensorIndexCSF::VT_INDPTRBUFFERS,
1005 indptrBuffers,
1006 );
1007 }
1008 #[inline]
1009 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
1010 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
1011 SparseTensorIndexCSF::VT_INDICESTYPE,
1012 indicesType,
1013 );
1014 }
1015 #[inline]
1016 pub fn add_indicesBuffers(
1017 &mut self,
1018 indicesBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
1019 ) {
1020 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1021 SparseTensorIndexCSF::VT_INDICESBUFFERS,
1022 indicesBuffers,
1023 );
1024 }
1025 #[inline]
1026 pub fn add_axisOrder(
1027 &mut self,
1028 axisOrder: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i32>>,
1029 ) {
1030 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1031 SparseTensorIndexCSF::VT_AXISORDER,
1032 axisOrder,
1033 );
1034 }
1035 #[inline]
1036 pub fn new(
1037 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1038 ) -> SparseTensorIndexCSFBuilder<'a, 'b, A> {
1039 let start = _fbb.start_table();
1040 SparseTensorIndexCSFBuilder {
1041 fbb_: _fbb,
1042 start_: start,
1043 }
1044 }
1045 #[inline]
1046 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'a>> {
1047 let o = self.fbb_.end_table(self.start_);
1048 self.fbb_
1049 .required(o, SparseTensorIndexCSF::VT_INDPTRTYPE, "indptrType");
1050 self.fbb_
1051 .required(o, SparseTensorIndexCSF::VT_INDPTRBUFFERS, "indptrBuffers");
1052 self.fbb_
1053 .required(o, SparseTensorIndexCSF::VT_INDICESTYPE, "indicesType");
1054 self.fbb_
1055 .required(o, SparseTensorIndexCSF::VT_INDICESBUFFERS, "indicesBuffers");
1056 self.fbb_
1057 .required(o, SparseTensorIndexCSF::VT_AXISORDER, "axisOrder");
1058 flatbuffers::WIPOffset::new(o.value())
1059 }
1060}
1061
1062impl core::fmt::Debug for SparseTensorIndexCSF<'_> {
1063 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1064 let mut ds = f.debug_struct("SparseTensorIndexCSF");
1065 ds.field("indptrType", &self.indptrType());
1066 ds.field("indptrBuffers", &self.indptrBuffers());
1067 ds.field("indicesType", &self.indicesType());
1068 ds.field("indicesBuffers", &self.indicesBuffers());
1069 ds.field("axisOrder", &self.axisOrder());
1070 ds.finish()
1071 }
1072}
1073pub enum SparseTensorOffset {}
1074#[derive(Copy, Clone, PartialEq)]
1075
1076pub struct SparseTensor<'a> {
1077 pub _tab: flatbuffers::Table<'a>,
1078}
1079
1080impl<'a> flatbuffers::Follow<'a> for SparseTensor<'a> {
1081 type Inner = SparseTensor<'a>;
1082 #[inline]
1083 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
1084 Self {
1085 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
1086 }
1087 }
1088}
1089
1090impl<'a> SparseTensor<'a> {
1091 pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4;
1092 pub const VT_TYPE_: flatbuffers::VOffsetT = 6;
1093 pub const VT_SHAPE: flatbuffers::VOffsetT = 8;
1094 pub const VT_NON_ZERO_LENGTH: flatbuffers::VOffsetT = 10;
1095 pub const VT_SPARSEINDEX_TYPE: flatbuffers::VOffsetT = 12;
1096 pub const VT_SPARSEINDEX: flatbuffers::VOffsetT = 14;
1097 pub const VT_DATA: flatbuffers::VOffsetT = 16;
1098
1099 #[inline]
1100 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
1101 SparseTensor { _tab: table }
1102 }
1103 #[allow(unused_mut)]
1104 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
1105 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
1106 args: &'args SparseTensorArgs<'args>,
1107 ) -> flatbuffers::WIPOffset<SparseTensor<'bldr>> {
1108 let mut builder = SparseTensorBuilder::new(_fbb);
1109 builder.add_non_zero_length(args.non_zero_length);
1110 if let Some(x) = args.data {
1111 builder.add_data(x);
1112 }
1113 if let Some(x) = args.sparseIndex {
1114 builder.add_sparseIndex(x);
1115 }
1116 if let Some(x) = args.shape {
1117 builder.add_shape(x);
1118 }
1119 if let Some(x) = args.type_ {
1120 builder.add_type_(x);
1121 }
1122 builder.add_sparseIndex_type(args.sparseIndex_type);
1123 builder.add_type_type(args.type_type);
1124 builder.finish()
1125 }
1126
1127 #[inline]
1128 pub fn type_type(&self) -> Type {
1129 unsafe {
1133 self._tab
1134 .get::<Type>(SparseTensor::VT_TYPE_TYPE, Some(Type::NONE))
1135 .unwrap()
1136 }
1137 }
1138 #[inline]
1142 pub fn type_(&self) -> flatbuffers::Table<'a> {
1143 unsafe {
1147 self._tab
1148 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1149 SparseTensor::VT_TYPE_,
1150 None,
1151 )
1152 .unwrap()
1153 }
1154 }
1155 #[inline]
1157 pub fn shape(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
1158 unsafe {
1162 self._tab
1163 .get::<flatbuffers::ForwardsUOffset<
1164 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim>>,
1165 >>(SparseTensor::VT_SHAPE, None)
1166 .unwrap()
1167 }
1168 }
1169 #[inline]
1171 pub fn non_zero_length(&self) -> i64 {
1172 unsafe {
1176 self._tab
1177 .get::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, Some(0))
1178 .unwrap()
1179 }
1180 }
1181 #[inline]
1182 pub fn sparseIndex_type(&self) -> SparseTensorIndex {
1183 unsafe {
1187 self._tab
1188 .get::<SparseTensorIndex>(
1189 SparseTensor::VT_SPARSEINDEX_TYPE,
1190 Some(SparseTensorIndex::NONE),
1191 )
1192 .unwrap()
1193 }
1194 }
1195 #[inline]
1197 pub fn sparseIndex(&self) -> flatbuffers::Table<'a> {
1198 unsafe {
1202 self._tab
1203 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1204 SparseTensor::VT_SPARSEINDEX,
1205 None,
1206 )
1207 .unwrap()
1208 }
1209 }
1210 #[inline]
1212 pub fn data(&self) -> &'a Buffer {
1213 unsafe {
1217 self._tab
1218 .get::<Buffer>(SparseTensor::VT_DATA, None)
1219 .unwrap()
1220 }
1221 }
1222 #[inline]
1223 #[allow(non_snake_case)]
1224 pub fn type_as_null(&self) -> Option<Null<'a>> {
1225 if self.type_type() == Type::Null {
1226 let u = self.type_();
1227 Some(unsafe { Null::init_from_table(u) })
1231 } else {
1232 None
1233 }
1234 }
1235
1236 #[inline]
1237 #[allow(non_snake_case)]
1238 pub fn type_as_int(&self) -> Option<Int<'a>> {
1239 if self.type_type() == Type::Int {
1240 let u = self.type_();
1241 Some(unsafe { Int::init_from_table(u) })
1245 } else {
1246 None
1247 }
1248 }
1249
1250 #[inline]
1251 #[allow(non_snake_case)]
1252 pub fn type_as_floating_point(&self) -> Option<FloatingPoint<'a>> {
1253 if self.type_type() == Type::FloatingPoint {
1254 let u = self.type_();
1255 Some(unsafe { FloatingPoint::init_from_table(u) })
1259 } else {
1260 None
1261 }
1262 }
1263
1264 #[inline]
1265 #[allow(non_snake_case)]
1266 pub fn type_as_binary(&self) -> Option<Binary<'a>> {
1267 if self.type_type() == Type::Binary {
1268 let u = self.type_();
1269 Some(unsafe { Binary::init_from_table(u) })
1273 } else {
1274 None
1275 }
1276 }
1277
1278 #[inline]
1279 #[allow(non_snake_case)]
1280 pub fn type_as_utf_8(&self) -> Option<Utf8<'a>> {
1281 if self.type_type() == Type::Utf8 {
1282 let u = self.type_();
1283 Some(unsafe { Utf8::init_from_table(u) })
1287 } else {
1288 None
1289 }
1290 }
1291
1292 #[inline]
1293 #[allow(non_snake_case)]
1294 pub fn type_as_bool(&self) -> Option<Bool<'a>> {
1295 if self.type_type() == Type::Bool {
1296 let u = self.type_();
1297 Some(unsafe { Bool::init_from_table(u) })
1301 } else {
1302 None
1303 }
1304 }
1305
1306 #[inline]
1307 #[allow(non_snake_case)]
1308 pub fn type_as_decimal(&self) -> Option<Decimal<'a>> {
1309 if self.type_type() == Type::Decimal {
1310 let u = self.type_();
1311 Some(unsafe { Decimal::init_from_table(u) })
1315 } else {
1316 None
1317 }
1318 }
1319
1320 #[inline]
1321 #[allow(non_snake_case)]
1322 pub fn type_as_date(&self) -> Option<Date<'a>> {
1323 if self.type_type() == Type::Date {
1324 let u = self.type_();
1325 Some(unsafe { Date::init_from_table(u) })
1329 } else {
1330 None
1331 }
1332 }
1333
1334 #[inline]
1335 #[allow(non_snake_case)]
1336 pub fn type_as_time(&self) -> Option<Time<'a>> {
1337 if self.type_type() == Type::Time {
1338 let u = self.type_();
1339 Some(unsafe { Time::init_from_table(u) })
1343 } else {
1344 None
1345 }
1346 }
1347
1348 #[inline]
1349 #[allow(non_snake_case)]
1350 pub fn type_as_timestamp(&self) -> Option<Timestamp<'a>> {
1351 if self.type_type() == Type::Timestamp {
1352 let u = self.type_();
1353 Some(unsafe { Timestamp::init_from_table(u) })
1357 } else {
1358 None
1359 }
1360 }
1361
1362 #[inline]
1363 #[allow(non_snake_case)]
1364 pub fn type_as_interval(&self) -> Option<Interval<'a>> {
1365 if self.type_type() == Type::Interval {
1366 let u = self.type_();
1367 Some(unsafe { Interval::init_from_table(u) })
1371 } else {
1372 None
1373 }
1374 }
1375
1376 #[inline]
1377 #[allow(non_snake_case)]
1378 pub fn type_as_list(&self) -> Option<List<'a>> {
1379 if self.type_type() == Type::List {
1380 let u = self.type_();
1381 Some(unsafe { List::init_from_table(u) })
1385 } else {
1386 None
1387 }
1388 }
1389
1390 #[inline]
1391 #[allow(non_snake_case)]
1392 pub fn type_as_struct_(&self) -> Option<Struct_<'a>> {
1393 if self.type_type() == Type::Struct_ {
1394 let u = self.type_();
1395 Some(unsafe { Struct_::init_from_table(u) })
1399 } else {
1400 None
1401 }
1402 }
1403
1404 #[inline]
1405 #[allow(non_snake_case)]
1406 pub fn type_as_union(&self) -> Option<Union<'a>> {
1407 if self.type_type() == Type::Union {
1408 let u = self.type_();
1409 Some(unsafe { Union::init_from_table(u) })
1413 } else {
1414 None
1415 }
1416 }
1417
1418 #[inline]
1419 #[allow(non_snake_case)]
1420 pub fn type_as_fixed_size_binary(&self) -> Option<FixedSizeBinary<'a>> {
1421 if self.type_type() == Type::FixedSizeBinary {
1422 let u = self.type_();
1423 Some(unsafe { FixedSizeBinary::init_from_table(u) })
1427 } else {
1428 None
1429 }
1430 }
1431
1432 #[inline]
1433 #[allow(non_snake_case)]
1434 pub fn type_as_fixed_size_list(&self) -> Option<FixedSizeList<'a>> {
1435 if self.type_type() == Type::FixedSizeList {
1436 let u = self.type_();
1437 Some(unsafe { FixedSizeList::init_from_table(u) })
1441 } else {
1442 None
1443 }
1444 }
1445
1446 #[inline]
1447 #[allow(non_snake_case)]
1448 pub fn type_as_map(&self) -> Option<Map<'a>> {
1449 if self.type_type() == Type::Map {
1450 let u = self.type_();
1451 Some(unsafe { Map::init_from_table(u) })
1455 } else {
1456 None
1457 }
1458 }
1459
1460 #[inline]
1461 #[allow(non_snake_case)]
1462 pub fn type_as_duration(&self) -> Option<Duration<'a>> {
1463 if self.type_type() == Type::Duration {
1464 let u = self.type_();
1465 Some(unsafe { Duration::init_from_table(u) })
1469 } else {
1470 None
1471 }
1472 }
1473
1474 #[inline]
1475 #[allow(non_snake_case)]
1476 pub fn type_as_large_binary(&self) -> Option<LargeBinary<'a>> {
1477 if self.type_type() == Type::LargeBinary {
1478 let u = self.type_();
1479 Some(unsafe { LargeBinary::init_from_table(u) })
1483 } else {
1484 None
1485 }
1486 }
1487
1488 #[inline]
1489 #[allow(non_snake_case)]
1490 pub fn type_as_large_utf_8(&self) -> Option<LargeUtf8<'a>> {
1491 if self.type_type() == Type::LargeUtf8 {
1492 let u = self.type_();
1493 Some(unsafe { LargeUtf8::init_from_table(u) })
1497 } else {
1498 None
1499 }
1500 }
1501
1502 #[inline]
1503 #[allow(non_snake_case)]
1504 pub fn type_as_large_list(&self) -> Option<LargeList<'a>> {
1505 if self.type_type() == Type::LargeList {
1506 let u = self.type_();
1507 Some(unsafe { LargeList::init_from_table(u) })
1511 } else {
1512 None
1513 }
1514 }
1515
1516 #[inline]
1517 #[allow(non_snake_case)]
1518 pub fn type_as_run_end_encoded(&self) -> Option<RunEndEncoded<'a>> {
1519 if self.type_type() == Type::RunEndEncoded {
1520 let u = self.type_();
1521 Some(unsafe { RunEndEncoded::init_from_table(u) })
1525 } else {
1526 None
1527 }
1528 }
1529
1530 #[inline]
1531 #[allow(non_snake_case)]
1532 pub fn type_as_binary_view(&self) -> Option<BinaryView<'a>> {
1533 if self.type_type() == Type::BinaryView {
1534 let u = self.type_();
1535 Some(unsafe { BinaryView::init_from_table(u) })
1539 } else {
1540 None
1541 }
1542 }
1543
1544 #[inline]
1545 #[allow(non_snake_case)]
1546 pub fn type_as_utf_8_view(&self) -> Option<Utf8View<'a>> {
1547 if self.type_type() == Type::Utf8View {
1548 let u = self.type_();
1549 Some(unsafe { Utf8View::init_from_table(u) })
1553 } else {
1554 None
1555 }
1556 }
1557
1558 #[inline]
1559 #[allow(non_snake_case)]
1560 pub fn type_as_list_view(&self) -> Option<ListView<'a>> {
1561 if self.type_type() == Type::ListView {
1562 let u = self.type_();
1563 Some(unsafe { ListView::init_from_table(u) })
1567 } else {
1568 None
1569 }
1570 }
1571
1572 #[inline]
1573 #[allow(non_snake_case)]
1574 pub fn type_as_large_list_view(&self) -> Option<LargeListView<'a>> {
1575 if self.type_type() == Type::LargeListView {
1576 let u = self.type_();
1577 Some(unsafe { LargeListView::init_from_table(u) })
1581 } else {
1582 None
1583 }
1584 }
1585
1586 #[inline]
1587 #[allow(non_snake_case)]
1588 pub fn sparseIndex_as_sparse_tensor_index_coo(&self) -> Option<SparseTensorIndexCOO<'a>> {
1589 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCOO {
1590 let u = self.sparseIndex();
1591 Some(unsafe { SparseTensorIndexCOO::init_from_table(u) })
1595 } else {
1596 None
1597 }
1598 }
1599
1600 #[inline]
1601 #[allow(non_snake_case)]
1602 pub fn sparseIndex_as_sparse_matrix_index_csx(&self) -> Option<SparseMatrixIndexCSX<'a>> {
1603 if self.sparseIndex_type() == SparseTensorIndex::SparseMatrixIndexCSX {
1604 let u = self.sparseIndex();
1605 Some(unsafe { SparseMatrixIndexCSX::init_from_table(u) })
1609 } else {
1610 None
1611 }
1612 }
1613
1614 #[inline]
1615 #[allow(non_snake_case)]
1616 pub fn sparseIndex_as_sparse_tensor_index_csf(&self) -> Option<SparseTensorIndexCSF<'a>> {
1617 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCSF {
1618 let u = self.sparseIndex();
1619 Some(unsafe { SparseTensorIndexCSF::init_from_table(u) })
1623 } else {
1624 None
1625 }
1626 }
1627}
1628
1629impl flatbuffers::Verifiable for SparseTensor<'_> {
1630 #[inline]
1631 fn run_verifier(
1632 v: &mut flatbuffers::Verifier,
1633 pos: usize,
1634 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
1635 use flatbuffers::Verifiable;
1636 v.visit_table(pos)?
1637 .visit_union::<Type, _>(
1638 "type_type",
1639 Self::VT_TYPE_TYPE,
1640 "type_",
1641 Self::VT_TYPE_,
1642 true,
1643 |key, v, pos| match key {
1644 Type::Null => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>(
1645 "Type::Null",
1646 pos,
1647 ),
1648 Type::Int => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>(
1649 "Type::Int",
1650 pos,
1651 ),
1652 Type::FloatingPoint => v
1653 .verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>(
1654 "Type::FloatingPoint",
1655 pos,
1656 ),
1657 Type::Binary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>(
1658 "Type::Binary",
1659 pos,
1660 ),
1661 Type::Utf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>(
1662 "Type::Utf8",
1663 pos,
1664 ),
1665 Type::Bool => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>(
1666 "Type::Bool",
1667 pos,
1668 ),
1669 Type::Decimal => v
1670 .verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>(
1671 "Type::Decimal",
1672 pos,
1673 ),
1674 Type::Date => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>(
1675 "Type::Date",
1676 pos,
1677 ),
1678 Type::Time => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>(
1679 "Type::Time",
1680 pos,
1681 ),
1682 Type::Timestamp => v
1683 .verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>(
1684 "Type::Timestamp",
1685 pos,
1686 ),
1687 Type::Interval => v
1688 .verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>(
1689 "Type::Interval",
1690 pos,
1691 ),
1692 Type::List => v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>(
1693 "Type::List",
1694 pos,
1695 ),
1696 Type::Struct_ => v
1697 .verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>(
1698 "Type::Struct_",
1699 pos,
1700 ),
1701 Type::Union => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>(
1702 "Type::Union",
1703 pos,
1704 ),
1705 Type::FixedSizeBinary => v
1706 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>(
1707 "Type::FixedSizeBinary",
1708 pos,
1709 ),
1710 Type::FixedSizeList => v
1711 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>(
1712 "Type::FixedSizeList",
1713 pos,
1714 ),
1715 Type::Map => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>(
1716 "Type::Map",
1717 pos,
1718 ),
1719 Type::Duration => v
1720 .verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>(
1721 "Type::Duration",
1722 pos,
1723 ),
1724 Type::LargeBinary => v
1725 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>(
1726 "Type::LargeBinary",
1727 pos,
1728 ),
1729 Type::LargeUtf8 => v
1730 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>(
1731 "Type::LargeUtf8",
1732 pos,
1733 ),
1734 Type::LargeList => v
1735 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>(
1736 "Type::LargeList",
1737 pos,
1738 ),
1739 Type::RunEndEncoded => v
1740 .verify_union_variant::<flatbuffers::ForwardsUOffset<RunEndEncoded>>(
1741 "Type::RunEndEncoded",
1742 pos,
1743 ),
1744 Type::BinaryView => v
1745 .verify_union_variant::<flatbuffers::ForwardsUOffset<BinaryView>>(
1746 "Type::BinaryView",
1747 pos,
1748 ),
1749 Type::Utf8View => v
1750 .verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8View>>(
1751 "Type::Utf8View",
1752 pos,
1753 ),
1754 Type::ListView => v
1755 .verify_union_variant::<flatbuffers::ForwardsUOffset<ListView>>(
1756 "Type::ListView",
1757 pos,
1758 ),
1759 Type::LargeListView => v
1760 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeListView>>(
1761 "Type::LargeListView",
1762 pos,
1763 ),
1764 _ => Ok(()),
1765 },
1766 )?
1767 .visit_field::<flatbuffers::ForwardsUOffset<
1768 flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<TensorDim>>,
1769 >>("shape", Self::VT_SHAPE, true)?
1770 .visit_field::<i64>("non_zero_length", Self::VT_NON_ZERO_LENGTH, false)?
1771 .visit_union::<SparseTensorIndex, _>(
1772 "sparseIndex_type",
1773 Self::VT_SPARSEINDEX_TYPE,
1774 "sparseIndex",
1775 Self::VT_SPARSEINDEX,
1776 true,
1777 |key, v, pos| match key {
1778 SparseTensorIndex::SparseTensorIndexCOO => v
1779 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCOO>>(
1780 "SparseTensorIndex::SparseTensorIndexCOO",
1781 pos,
1782 ),
1783 SparseTensorIndex::SparseMatrixIndexCSX => v
1784 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseMatrixIndexCSX>>(
1785 "SparseTensorIndex::SparseMatrixIndexCSX",
1786 pos,
1787 ),
1788 SparseTensorIndex::SparseTensorIndexCSF => v
1789 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCSF>>(
1790 "SparseTensorIndex::SparseTensorIndexCSF",
1791 pos,
1792 ),
1793 _ => Ok(()),
1794 },
1795 )?
1796 .visit_field::<Buffer>("data", Self::VT_DATA, true)?
1797 .finish();
1798 Ok(())
1799 }
1800}
1801pub struct SparseTensorArgs<'a> {
1802 pub type_type: Type,
1803 pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1804 pub shape: Option<
1805 flatbuffers::WIPOffset<
1806 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
1807 >,
1808 >,
1809 pub non_zero_length: i64,
1810 pub sparseIndex_type: SparseTensorIndex,
1811 pub sparseIndex: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1812 pub data: Option<&'a Buffer>,
1813}
1814impl<'a> Default for SparseTensorArgs<'a> {
1815 #[inline]
1816 fn default() -> Self {
1817 SparseTensorArgs {
1818 type_type: Type::NONE,
1819 type_: None, shape: None, non_zero_length: 0,
1822 sparseIndex_type: SparseTensorIndex::NONE,
1823 sparseIndex: None, data: None, }
1826 }
1827}
1828
1829pub struct SparseTensorBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
1830 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1831 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
1832}
1833impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorBuilder<'a, 'b, A> {
1834 #[inline]
1835 pub fn add_type_type(&mut self, type_type: Type) {
1836 self.fbb_
1837 .push_slot::<Type>(SparseTensor::VT_TYPE_TYPE, type_type, Type::NONE);
1838 }
1839 #[inline]
1840 pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
1841 self.fbb_
1842 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_TYPE_, type_);
1843 }
1844 #[inline]
1845 pub fn add_shape(
1846 &mut self,
1847 shape: flatbuffers::WIPOffset<
1848 flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<TensorDim<'b>>>,
1849 >,
1850 ) {
1851 self.fbb_
1852 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_SHAPE, shape);
1853 }
1854 #[inline]
1855 pub fn add_non_zero_length(&mut self, non_zero_length: i64) {
1856 self.fbb_
1857 .push_slot::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, non_zero_length, 0);
1858 }
1859 #[inline]
1860 pub fn add_sparseIndex_type(&mut self, sparseIndex_type: SparseTensorIndex) {
1861 self.fbb_.push_slot::<SparseTensorIndex>(
1862 SparseTensor::VT_SPARSEINDEX_TYPE,
1863 sparseIndex_type,
1864 SparseTensorIndex::NONE,
1865 );
1866 }
1867 #[inline]
1868 pub fn add_sparseIndex(
1869 &mut self,
1870 sparseIndex: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
1871 ) {
1872 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1873 SparseTensor::VT_SPARSEINDEX,
1874 sparseIndex,
1875 );
1876 }
1877 #[inline]
1878 pub fn add_data(&mut self, data: &Buffer) {
1879 self.fbb_
1880 .push_slot_always::<&Buffer>(SparseTensor::VT_DATA, data);
1881 }
1882 #[inline]
1883 pub fn new(
1884 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1885 ) -> SparseTensorBuilder<'a, 'b, A> {
1886 let start = _fbb.start_table();
1887 SparseTensorBuilder {
1888 fbb_: _fbb,
1889 start_: start,
1890 }
1891 }
1892 #[inline]
1893 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensor<'a>> {
1894 let o = self.fbb_.end_table(self.start_);
1895 self.fbb_.required(o, SparseTensor::VT_TYPE_, "type_");
1896 self.fbb_.required(o, SparseTensor::VT_SHAPE, "shape");
1897 self.fbb_
1898 .required(o, SparseTensor::VT_SPARSEINDEX, "sparseIndex");
1899 self.fbb_.required(o, SparseTensor::VT_DATA, "data");
1900 flatbuffers::WIPOffset::new(o.value())
1901 }
1902}
1903
1904impl core::fmt::Debug for SparseTensor<'_> {
1905 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1906 let mut ds = f.debug_struct("SparseTensor");
1907 ds.field("type_type", &self.type_type());
1908 match self.type_type() {
1909 Type::Null => {
1910 if let Some(x) = self.type_as_null() {
1911 ds.field("type_", &x)
1912 } else {
1913 ds.field(
1914 "type_",
1915 &"InvalidFlatbuffer: Union discriminant does not match value.",
1916 )
1917 }
1918 }
1919 Type::Int => {
1920 if let Some(x) = self.type_as_int() {
1921 ds.field("type_", &x)
1922 } else {
1923 ds.field(
1924 "type_",
1925 &"InvalidFlatbuffer: Union discriminant does not match value.",
1926 )
1927 }
1928 }
1929 Type::FloatingPoint => {
1930 if let Some(x) = self.type_as_floating_point() {
1931 ds.field("type_", &x)
1932 } else {
1933 ds.field(
1934 "type_",
1935 &"InvalidFlatbuffer: Union discriminant does not match value.",
1936 )
1937 }
1938 }
1939 Type::Binary => {
1940 if let Some(x) = self.type_as_binary() {
1941 ds.field("type_", &x)
1942 } else {
1943 ds.field(
1944 "type_",
1945 &"InvalidFlatbuffer: Union discriminant does not match value.",
1946 )
1947 }
1948 }
1949 Type::Utf8 => {
1950 if let Some(x) = self.type_as_utf_8() {
1951 ds.field("type_", &x)
1952 } else {
1953 ds.field(
1954 "type_",
1955 &"InvalidFlatbuffer: Union discriminant does not match value.",
1956 )
1957 }
1958 }
1959 Type::Bool => {
1960 if let Some(x) = self.type_as_bool() {
1961 ds.field("type_", &x)
1962 } else {
1963 ds.field(
1964 "type_",
1965 &"InvalidFlatbuffer: Union discriminant does not match value.",
1966 )
1967 }
1968 }
1969 Type::Decimal => {
1970 if let Some(x) = self.type_as_decimal() {
1971 ds.field("type_", &x)
1972 } else {
1973 ds.field(
1974 "type_",
1975 &"InvalidFlatbuffer: Union discriminant does not match value.",
1976 )
1977 }
1978 }
1979 Type::Date => {
1980 if let Some(x) = self.type_as_date() {
1981 ds.field("type_", &x)
1982 } else {
1983 ds.field(
1984 "type_",
1985 &"InvalidFlatbuffer: Union discriminant does not match value.",
1986 )
1987 }
1988 }
1989 Type::Time => {
1990 if let Some(x) = self.type_as_time() {
1991 ds.field("type_", &x)
1992 } else {
1993 ds.field(
1994 "type_",
1995 &"InvalidFlatbuffer: Union discriminant does not match value.",
1996 )
1997 }
1998 }
1999 Type::Timestamp => {
2000 if let Some(x) = self.type_as_timestamp() {
2001 ds.field("type_", &x)
2002 } else {
2003 ds.field(
2004 "type_",
2005 &"InvalidFlatbuffer: Union discriminant does not match value.",
2006 )
2007 }
2008 }
2009 Type::Interval => {
2010 if let Some(x) = self.type_as_interval() {
2011 ds.field("type_", &x)
2012 } else {
2013 ds.field(
2014 "type_",
2015 &"InvalidFlatbuffer: Union discriminant does not match value.",
2016 )
2017 }
2018 }
2019 Type::List => {
2020 if let Some(x) = self.type_as_list() {
2021 ds.field("type_", &x)
2022 } else {
2023 ds.field(
2024 "type_",
2025 &"InvalidFlatbuffer: Union discriminant does not match value.",
2026 )
2027 }
2028 }
2029 Type::Struct_ => {
2030 if let Some(x) = self.type_as_struct_() {
2031 ds.field("type_", &x)
2032 } else {
2033 ds.field(
2034 "type_",
2035 &"InvalidFlatbuffer: Union discriminant does not match value.",
2036 )
2037 }
2038 }
2039 Type::Union => {
2040 if let Some(x) = self.type_as_union() {
2041 ds.field("type_", &x)
2042 } else {
2043 ds.field(
2044 "type_",
2045 &"InvalidFlatbuffer: Union discriminant does not match value.",
2046 )
2047 }
2048 }
2049 Type::FixedSizeBinary => {
2050 if let Some(x) = self.type_as_fixed_size_binary() {
2051 ds.field("type_", &x)
2052 } else {
2053 ds.field(
2054 "type_",
2055 &"InvalidFlatbuffer: Union discriminant does not match value.",
2056 )
2057 }
2058 }
2059 Type::FixedSizeList => {
2060 if let Some(x) = self.type_as_fixed_size_list() {
2061 ds.field("type_", &x)
2062 } else {
2063 ds.field(
2064 "type_",
2065 &"InvalidFlatbuffer: Union discriminant does not match value.",
2066 )
2067 }
2068 }
2069 Type::Map => {
2070 if let Some(x) = self.type_as_map() {
2071 ds.field("type_", &x)
2072 } else {
2073 ds.field(
2074 "type_",
2075 &"InvalidFlatbuffer: Union discriminant does not match value.",
2076 )
2077 }
2078 }
2079 Type::Duration => {
2080 if let Some(x) = self.type_as_duration() {
2081 ds.field("type_", &x)
2082 } else {
2083 ds.field(
2084 "type_",
2085 &"InvalidFlatbuffer: Union discriminant does not match value.",
2086 )
2087 }
2088 }
2089 Type::LargeBinary => {
2090 if let Some(x) = self.type_as_large_binary() {
2091 ds.field("type_", &x)
2092 } else {
2093 ds.field(
2094 "type_",
2095 &"InvalidFlatbuffer: Union discriminant does not match value.",
2096 )
2097 }
2098 }
2099 Type::LargeUtf8 => {
2100 if let Some(x) = self.type_as_large_utf_8() {
2101 ds.field("type_", &x)
2102 } else {
2103 ds.field(
2104 "type_",
2105 &"InvalidFlatbuffer: Union discriminant does not match value.",
2106 )
2107 }
2108 }
2109 Type::LargeList => {
2110 if let Some(x) = self.type_as_large_list() {
2111 ds.field("type_", &x)
2112 } else {
2113 ds.field(
2114 "type_",
2115 &"InvalidFlatbuffer: Union discriminant does not match value.",
2116 )
2117 }
2118 }
2119 Type::RunEndEncoded => {
2120 if let Some(x) = self.type_as_run_end_encoded() {
2121 ds.field("type_", &x)
2122 } else {
2123 ds.field(
2124 "type_",
2125 &"InvalidFlatbuffer: Union discriminant does not match value.",
2126 )
2127 }
2128 }
2129 Type::BinaryView => {
2130 if let Some(x) = self.type_as_binary_view() {
2131 ds.field("type_", &x)
2132 } else {
2133 ds.field(
2134 "type_",
2135 &"InvalidFlatbuffer: Union discriminant does not match value.",
2136 )
2137 }
2138 }
2139 Type::Utf8View => {
2140 if let Some(x) = self.type_as_utf_8_view() {
2141 ds.field("type_", &x)
2142 } else {
2143 ds.field(
2144 "type_",
2145 &"InvalidFlatbuffer: Union discriminant does not match value.",
2146 )
2147 }
2148 }
2149 Type::ListView => {
2150 if let Some(x) = self.type_as_list_view() {
2151 ds.field("type_", &x)
2152 } else {
2153 ds.field(
2154 "type_",
2155 &"InvalidFlatbuffer: Union discriminant does not match value.",
2156 )
2157 }
2158 }
2159 Type::LargeListView => {
2160 if let Some(x) = self.type_as_large_list_view() {
2161 ds.field("type_", &x)
2162 } else {
2163 ds.field(
2164 "type_",
2165 &"InvalidFlatbuffer: Union discriminant does not match value.",
2166 )
2167 }
2168 }
2169 _ => {
2170 let x: Option<()> = None;
2171 ds.field("type_", &x)
2172 }
2173 };
2174 ds.field("shape", &self.shape());
2175 ds.field("non_zero_length", &self.non_zero_length());
2176 ds.field("sparseIndex_type", &self.sparseIndex_type());
2177 match self.sparseIndex_type() {
2178 SparseTensorIndex::SparseTensorIndexCOO => {
2179 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_coo() {
2180 ds.field("sparseIndex", &x)
2181 } else {
2182 ds.field(
2183 "sparseIndex",
2184 &"InvalidFlatbuffer: Union discriminant does not match value.",
2185 )
2186 }
2187 }
2188 SparseTensorIndex::SparseMatrixIndexCSX => {
2189 if let Some(x) = self.sparseIndex_as_sparse_matrix_index_csx() {
2190 ds.field("sparseIndex", &x)
2191 } else {
2192 ds.field(
2193 "sparseIndex",
2194 &"InvalidFlatbuffer: Union discriminant does not match value.",
2195 )
2196 }
2197 }
2198 SparseTensorIndex::SparseTensorIndexCSF => {
2199 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_csf() {
2200 ds.field("sparseIndex", &x)
2201 } else {
2202 ds.field(
2203 "sparseIndex",
2204 &"InvalidFlatbuffer: Union discriminant does not match value.",
2205 )
2206 }
2207 }
2208 _ => {
2209 let x: Option<()> = None;
2210 ds.field("sparseIndex", &x)
2211 }
2212 };
2213 ds.field("data", &self.data());
2214 ds.finish()
2215 }
2216}
2217#[inline]
2218pub fn root_as_sparse_tensor(buf: &[u8]) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2225 flatbuffers::root::<SparseTensor>(buf)
2226}
2227#[inline]
2228pub fn size_prefixed_root_as_sparse_tensor(
2235 buf: &[u8],
2236) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2237 flatbuffers::size_prefixed_root::<SparseTensor>(buf)
2238}
2239#[inline]
2240pub fn root_as_sparse_tensor_with_opts<'b, 'o>(
2247 opts: &'o flatbuffers::VerifierOptions,
2248 buf: &'b [u8],
2249) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
2250 flatbuffers::root_with_opts::<SparseTensor<'b>>(opts, buf)
2251}
2252#[inline]
2253pub fn size_prefixed_root_as_sparse_tensor_with_opts<'b, 'o>(
2260 opts: &'o flatbuffers::VerifierOptions,
2261 buf: &'b [u8],
2262) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
2263 flatbuffers::size_prefixed_root_with_opts::<SparseTensor<'b>>(opts, buf)
2264}
2265#[inline]
2266pub unsafe fn root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2270 unsafe { flatbuffers::root_unchecked::<SparseTensor>(buf) }
2271}
2272#[inline]
2273pub unsafe fn size_prefixed_root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2277 unsafe { flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf) }
2278}
2279#[inline]
2280pub fn finish_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
2281 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
2282 root: flatbuffers::WIPOffset<SparseTensor<'a>>,
2283) {
2284 fbb.finish(root, None);
2285}
2286
2287#[inline]
2288pub fn finish_size_prefixed_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
2289 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
2290 root: flatbuffers::WIPOffset<SparseTensor<'a>>,
2291) {
2292 fbb.finish_size_prefixed(root, None);
2293}