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> {
1082 pub _tab: flatbuffers::Table<'a>,
1083}
1084
1085impl<'a> flatbuffers::Follow<'a> for SparseTensor<'a> {
1086 type Inner = SparseTensor<'a>;
1087 #[inline]
1088 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
1089 Self {
1090 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
1091 }
1092 }
1093}
1094
1095impl<'a> SparseTensor<'a> {
1096 pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4;
1097 pub const VT_TYPE_: flatbuffers::VOffsetT = 6;
1098 pub const VT_SHAPE: flatbuffers::VOffsetT = 8;
1099 pub const VT_NON_ZERO_LENGTH: flatbuffers::VOffsetT = 10;
1100 pub const VT_SPARSEINDEX_TYPE: flatbuffers::VOffsetT = 12;
1101 pub const VT_SPARSEINDEX: flatbuffers::VOffsetT = 14;
1102 pub const VT_DATA: flatbuffers::VOffsetT = 16;
1103
1104 #[inline]
1105 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
1106 SparseTensor { _tab: table }
1107 }
1108 #[allow(unused_mut)]
1109 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
1110 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
1111 args: &'args SparseTensorArgs<'args>,
1112 ) -> flatbuffers::WIPOffset<SparseTensor<'bldr>> {
1113 let mut builder = SparseTensorBuilder::new(_fbb);
1114 builder.add_non_zero_length(args.non_zero_length);
1115 if let Some(x) = args.data {
1116 builder.add_data(x);
1117 }
1118 if let Some(x) = args.sparseIndex {
1119 builder.add_sparseIndex(x);
1120 }
1121 if let Some(x) = args.shape {
1122 builder.add_shape(x);
1123 }
1124 if let Some(x) = args.type_ {
1125 builder.add_type_(x);
1126 }
1127 builder.add_sparseIndex_type(args.sparseIndex_type);
1128 builder.add_type_type(args.type_type);
1129 builder.finish()
1130 }
1131
1132 #[inline]
1133 pub fn type_type(&self) -> Type {
1134 unsafe {
1138 self._tab
1139 .get::<Type>(SparseTensor::VT_TYPE_TYPE, Some(Type::NONE))
1140 .unwrap()
1141 }
1142 }
1143 #[inline]
1147 pub fn type_(&self) -> flatbuffers::Table<'a> {
1148 unsafe {
1152 self._tab
1153 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1154 SparseTensor::VT_TYPE_,
1155 None,
1156 )
1157 .unwrap()
1158 }
1159 }
1160 #[inline]
1162 pub fn shape(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
1163 unsafe {
1167 self._tab
1168 .get::<flatbuffers::ForwardsUOffset<
1169 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim>>,
1170 >>(SparseTensor::VT_SHAPE, None)
1171 .unwrap()
1172 }
1173 }
1174 #[inline]
1176 pub fn non_zero_length(&self) -> i64 {
1177 unsafe {
1181 self._tab
1182 .get::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, Some(0))
1183 .unwrap()
1184 }
1185 }
1186 #[inline]
1187 pub fn sparseIndex_type(&self) -> SparseTensorIndex {
1188 unsafe {
1192 self._tab
1193 .get::<SparseTensorIndex>(
1194 SparseTensor::VT_SPARSEINDEX_TYPE,
1195 Some(SparseTensorIndex::NONE),
1196 )
1197 .unwrap()
1198 }
1199 }
1200 #[inline]
1202 pub fn sparseIndex(&self) -> flatbuffers::Table<'a> {
1203 unsafe {
1207 self._tab
1208 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1209 SparseTensor::VT_SPARSEINDEX,
1210 None,
1211 )
1212 .unwrap()
1213 }
1214 }
1215 #[inline]
1217 pub fn data(&self) -> &'a Buffer {
1218 unsafe {
1222 self._tab
1223 .get::<Buffer>(SparseTensor::VT_DATA, None)
1224 .unwrap()
1225 }
1226 }
1227 #[inline]
1228 #[allow(non_snake_case)]
1229 pub fn type_as_null(&self) -> Option<Null<'a>> {
1230 if self.type_type() == Type::Null {
1231 let u = self.type_();
1232 Some(unsafe { Null::init_from_table(u) })
1236 } else {
1237 None
1238 }
1239 }
1240
1241 #[inline]
1242 #[allow(non_snake_case)]
1243 pub fn type_as_int(&self) -> Option<Int<'a>> {
1244 if self.type_type() == Type::Int {
1245 let u = self.type_();
1246 Some(unsafe { Int::init_from_table(u) })
1250 } else {
1251 None
1252 }
1253 }
1254
1255 #[inline]
1256 #[allow(non_snake_case)]
1257 pub fn type_as_floating_point(&self) -> Option<FloatingPoint<'a>> {
1258 if self.type_type() == Type::FloatingPoint {
1259 let u = self.type_();
1260 Some(unsafe { FloatingPoint::init_from_table(u) })
1264 } else {
1265 None
1266 }
1267 }
1268
1269 #[inline]
1270 #[allow(non_snake_case)]
1271 pub fn type_as_binary(&self) -> Option<Binary<'a>> {
1272 if self.type_type() == Type::Binary {
1273 let u = self.type_();
1274 Some(unsafe { Binary::init_from_table(u) })
1278 } else {
1279 None
1280 }
1281 }
1282
1283 #[inline]
1284 #[allow(non_snake_case)]
1285 pub fn type_as_utf_8(&self) -> Option<Utf8<'a>> {
1286 if self.type_type() == Type::Utf8 {
1287 let u = self.type_();
1288 Some(unsafe { Utf8::init_from_table(u) })
1292 } else {
1293 None
1294 }
1295 }
1296
1297 #[inline]
1298 #[allow(non_snake_case)]
1299 pub fn type_as_bool(&self) -> Option<Bool<'a>> {
1300 if self.type_type() == Type::Bool {
1301 let u = self.type_();
1302 Some(unsafe { Bool::init_from_table(u) })
1306 } else {
1307 None
1308 }
1309 }
1310
1311 #[inline]
1312 #[allow(non_snake_case)]
1313 pub fn type_as_decimal(&self) -> Option<Decimal<'a>> {
1314 if self.type_type() == Type::Decimal {
1315 let u = self.type_();
1316 Some(unsafe { Decimal::init_from_table(u) })
1320 } else {
1321 None
1322 }
1323 }
1324
1325 #[inline]
1326 #[allow(non_snake_case)]
1327 pub fn type_as_date(&self) -> Option<Date<'a>> {
1328 if self.type_type() == Type::Date {
1329 let u = self.type_();
1330 Some(unsafe { Date::init_from_table(u) })
1334 } else {
1335 None
1336 }
1337 }
1338
1339 #[inline]
1340 #[allow(non_snake_case)]
1341 pub fn type_as_time(&self) -> Option<Time<'a>> {
1342 if self.type_type() == Type::Time {
1343 let u = self.type_();
1344 Some(unsafe { Time::init_from_table(u) })
1348 } else {
1349 None
1350 }
1351 }
1352
1353 #[inline]
1354 #[allow(non_snake_case)]
1355 pub fn type_as_timestamp(&self) -> Option<Timestamp<'a>> {
1356 if self.type_type() == Type::Timestamp {
1357 let u = self.type_();
1358 Some(unsafe { Timestamp::init_from_table(u) })
1362 } else {
1363 None
1364 }
1365 }
1366
1367 #[inline]
1368 #[allow(non_snake_case)]
1369 pub fn type_as_interval(&self) -> Option<Interval<'a>> {
1370 if self.type_type() == Type::Interval {
1371 let u = self.type_();
1372 Some(unsafe { Interval::init_from_table(u) })
1376 } else {
1377 None
1378 }
1379 }
1380
1381 #[inline]
1382 #[allow(non_snake_case)]
1383 pub fn type_as_list(&self) -> Option<List<'a>> {
1384 if self.type_type() == Type::List {
1385 let u = self.type_();
1386 Some(unsafe { List::init_from_table(u) })
1390 } else {
1391 None
1392 }
1393 }
1394
1395 #[inline]
1396 #[allow(non_snake_case)]
1397 pub fn type_as_struct_(&self) -> Option<Struct_<'a>> {
1398 if self.type_type() == Type::Struct_ {
1399 let u = self.type_();
1400 Some(unsafe { Struct_::init_from_table(u) })
1404 } else {
1405 None
1406 }
1407 }
1408
1409 #[inline]
1410 #[allow(non_snake_case)]
1411 pub fn type_as_union(&self) -> Option<Union<'a>> {
1412 if self.type_type() == Type::Union {
1413 let u = self.type_();
1414 Some(unsafe { Union::init_from_table(u) })
1418 } else {
1419 None
1420 }
1421 }
1422
1423 #[inline]
1424 #[allow(non_snake_case)]
1425 pub fn type_as_fixed_size_binary(&self) -> Option<FixedSizeBinary<'a>> {
1426 if self.type_type() == Type::FixedSizeBinary {
1427 let u = self.type_();
1428 Some(unsafe { FixedSizeBinary::init_from_table(u) })
1432 } else {
1433 None
1434 }
1435 }
1436
1437 #[inline]
1438 #[allow(non_snake_case)]
1439 pub fn type_as_fixed_size_list(&self) -> Option<FixedSizeList<'a>> {
1440 if self.type_type() == Type::FixedSizeList {
1441 let u = self.type_();
1442 Some(unsafe { FixedSizeList::init_from_table(u) })
1446 } else {
1447 None
1448 }
1449 }
1450
1451 #[inline]
1452 #[allow(non_snake_case)]
1453 pub fn type_as_map(&self) -> Option<Map<'a>> {
1454 if self.type_type() == Type::Map {
1455 let u = self.type_();
1456 Some(unsafe { Map::init_from_table(u) })
1460 } else {
1461 None
1462 }
1463 }
1464
1465 #[inline]
1466 #[allow(non_snake_case)]
1467 pub fn type_as_duration(&self) -> Option<Duration<'a>> {
1468 if self.type_type() == Type::Duration {
1469 let u = self.type_();
1470 Some(unsafe { Duration::init_from_table(u) })
1474 } else {
1475 None
1476 }
1477 }
1478
1479 #[inline]
1480 #[allow(non_snake_case)]
1481 pub fn type_as_large_binary(&self) -> Option<LargeBinary<'a>> {
1482 if self.type_type() == Type::LargeBinary {
1483 let u = self.type_();
1484 Some(unsafe { LargeBinary::init_from_table(u) })
1488 } else {
1489 None
1490 }
1491 }
1492
1493 #[inline]
1494 #[allow(non_snake_case)]
1495 pub fn type_as_large_utf_8(&self) -> Option<LargeUtf8<'a>> {
1496 if self.type_type() == Type::LargeUtf8 {
1497 let u = self.type_();
1498 Some(unsafe { LargeUtf8::init_from_table(u) })
1502 } else {
1503 None
1504 }
1505 }
1506
1507 #[inline]
1508 #[allow(non_snake_case)]
1509 pub fn type_as_large_list(&self) -> Option<LargeList<'a>> {
1510 if self.type_type() == Type::LargeList {
1511 let u = self.type_();
1512 Some(unsafe { LargeList::init_from_table(u) })
1516 } else {
1517 None
1518 }
1519 }
1520
1521 #[inline]
1522 #[allow(non_snake_case)]
1523 pub fn type_as_run_end_encoded(&self) -> Option<RunEndEncoded<'a>> {
1524 if self.type_type() == Type::RunEndEncoded {
1525 let u = self.type_();
1526 Some(unsafe { RunEndEncoded::init_from_table(u) })
1530 } else {
1531 None
1532 }
1533 }
1534
1535 #[inline]
1536 #[allow(non_snake_case)]
1537 pub fn type_as_binary_view(&self) -> Option<BinaryView<'a>> {
1538 if self.type_type() == Type::BinaryView {
1539 let u = self.type_();
1540 Some(unsafe { BinaryView::init_from_table(u) })
1544 } else {
1545 None
1546 }
1547 }
1548
1549 #[inline]
1550 #[allow(non_snake_case)]
1551 pub fn type_as_utf_8_view(&self) -> Option<Utf8View<'a>> {
1552 if self.type_type() == Type::Utf8View {
1553 let u = self.type_();
1554 Some(unsafe { Utf8View::init_from_table(u) })
1558 } else {
1559 None
1560 }
1561 }
1562
1563 #[inline]
1564 #[allow(non_snake_case)]
1565 pub fn type_as_list_view(&self) -> Option<ListView<'a>> {
1566 if self.type_type() == Type::ListView {
1567 let u = self.type_();
1568 Some(unsafe { ListView::init_from_table(u) })
1572 } else {
1573 None
1574 }
1575 }
1576
1577 #[inline]
1578 #[allow(non_snake_case)]
1579 pub fn type_as_large_list_view(&self) -> Option<LargeListView<'a>> {
1580 if self.type_type() == Type::LargeListView {
1581 let u = self.type_();
1582 Some(unsafe { LargeListView::init_from_table(u) })
1586 } else {
1587 None
1588 }
1589 }
1590
1591 #[inline]
1592 #[allow(non_snake_case)]
1593 pub fn sparseIndex_as_sparse_tensor_index_coo(&self) -> Option<SparseTensorIndexCOO<'a>> {
1594 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCOO {
1595 let u = self.sparseIndex();
1596 Some(unsafe { SparseTensorIndexCOO::init_from_table(u) })
1600 } else {
1601 None
1602 }
1603 }
1604
1605 #[inline]
1606 #[allow(non_snake_case)]
1607 pub fn sparseIndex_as_sparse_matrix_index_csx(&self) -> Option<SparseMatrixIndexCSX<'a>> {
1608 if self.sparseIndex_type() == SparseTensorIndex::SparseMatrixIndexCSX {
1609 let u = self.sparseIndex();
1610 Some(unsafe { SparseMatrixIndexCSX::init_from_table(u) })
1614 } else {
1615 None
1616 }
1617 }
1618
1619 #[inline]
1620 #[allow(non_snake_case)]
1621 pub fn sparseIndex_as_sparse_tensor_index_csf(&self) -> Option<SparseTensorIndexCSF<'a>> {
1622 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCSF {
1623 let u = self.sparseIndex();
1624 Some(unsafe { SparseTensorIndexCSF::init_from_table(u) })
1628 } else {
1629 None
1630 }
1631 }
1632}
1633
1634impl flatbuffers::Verifiable for SparseTensor<'_> {
1635 #[inline]
1636 fn run_verifier(
1637 v: &mut flatbuffers::Verifier,
1638 pos: usize,
1639 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
1640 use flatbuffers::Verifiable;
1641 v.visit_table(pos)?
1642 .visit_union::<Type, _>(
1643 "type_type",
1644 Self::VT_TYPE_TYPE,
1645 "type_",
1646 Self::VT_TYPE_,
1647 true,
1648 |key, v, pos| match key {
1649 Type::Null => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>(
1650 "Type::Null",
1651 pos,
1652 ),
1653 Type::Int => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>(
1654 "Type::Int",
1655 pos,
1656 ),
1657 Type::FloatingPoint => v
1658 .verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>(
1659 "Type::FloatingPoint",
1660 pos,
1661 ),
1662 Type::Binary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>(
1663 "Type::Binary",
1664 pos,
1665 ),
1666 Type::Utf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>(
1667 "Type::Utf8",
1668 pos,
1669 ),
1670 Type::Bool => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>(
1671 "Type::Bool",
1672 pos,
1673 ),
1674 Type::Decimal => v
1675 .verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>(
1676 "Type::Decimal",
1677 pos,
1678 ),
1679 Type::Date => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>(
1680 "Type::Date",
1681 pos,
1682 ),
1683 Type::Time => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>(
1684 "Type::Time",
1685 pos,
1686 ),
1687 Type::Timestamp => v
1688 .verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>(
1689 "Type::Timestamp",
1690 pos,
1691 ),
1692 Type::Interval => v
1693 .verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>(
1694 "Type::Interval",
1695 pos,
1696 ),
1697 Type::List => v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>(
1698 "Type::List",
1699 pos,
1700 ),
1701 Type::Struct_ => v
1702 .verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>(
1703 "Type::Struct_",
1704 pos,
1705 ),
1706 Type::Union => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>(
1707 "Type::Union",
1708 pos,
1709 ),
1710 Type::FixedSizeBinary => v
1711 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>(
1712 "Type::FixedSizeBinary",
1713 pos,
1714 ),
1715 Type::FixedSizeList => v
1716 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>(
1717 "Type::FixedSizeList",
1718 pos,
1719 ),
1720 Type::Map => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>(
1721 "Type::Map",
1722 pos,
1723 ),
1724 Type::Duration => v
1725 .verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>(
1726 "Type::Duration",
1727 pos,
1728 ),
1729 Type::LargeBinary => v
1730 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>(
1731 "Type::LargeBinary",
1732 pos,
1733 ),
1734 Type::LargeUtf8 => v
1735 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>(
1736 "Type::LargeUtf8",
1737 pos,
1738 ),
1739 Type::LargeList => v
1740 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>(
1741 "Type::LargeList",
1742 pos,
1743 ),
1744 Type::RunEndEncoded => v
1745 .verify_union_variant::<flatbuffers::ForwardsUOffset<RunEndEncoded>>(
1746 "Type::RunEndEncoded",
1747 pos,
1748 ),
1749 Type::BinaryView => v
1750 .verify_union_variant::<flatbuffers::ForwardsUOffset<BinaryView>>(
1751 "Type::BinaryView",
1752 pos,
1753 ),
1754 Type::Utf8View => v
1755 .verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8View>>(
1756 "Type::Utf8View",
1757 pos,
1758 ),
1759 Type::ListView => v
1760 .verify_union_variant::<flatbuffers::ForwardsUOffset<ListView>>(
1761 "Type::ListView",
1762 pos,
1763 ),
1764 Type::LargeListView => v
1765 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeListView>>(
1766 "Type::LargeListView",
1767 pos,
1768 ),
1769 _ => Ok(()),
1770 },
1771 )?
1772 .visit_field::<flatbuffers::ForwardsUOffset<
1773 flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<TensorDim>>,
1774 >>("shape", Self::VT_SHAPE, true)?
1775 .visit_field::<i64>("non_zero_length", Self::VT_NON_ZERO_LENGTH, false)?
1776 .visit_union::<SparseTensorIndex, _>(
1777 "sparseIndex_type",
1778 Self::VT_SPARSEINDEX_TYPE,
1779 "sparseIndex",
1780 Self::VT_SPARSEINDEX,
1781 true,
1782 |key, v, pos| match key {
1783 SparseTensorIndex::SparseTensorIndexCOO => v
1784 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCOO>>(
1785 "SparseTensorIndex::SparseTensorIndexCOO",
1786 pos,
1787 ),
1788 SparseTensorIndex::SparseMatrixIndexCSX => v
1789 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseMatrixIndexCSX>>(
1790 "SparseTensorIndex::SparseMatrixIndexCSX",
1791 pos,
1792 ),
1793 SparseTensorIndex::SparseTensorIndexCSF => v
1794 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCSF>>(
1795 "SparseTensorIndex::SparseTensorIndexCSF",
1796 pos,
1797 ),
1798 _ => Ok(()),
1799 },
1800 )?
1801 .visit_field::<Buffer>("data", Self::VT_DATA, true)?
1802 .finish();
1803 Ok(())
1804 }
1805}
1806pub struct SparseTensorArgs<'a> {
1807 pub type_type: Type,
1808 pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1809 pub shape: Option<
1810 flatbuffers::WIPOffset<
1811 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
1812 >,
1813 >,
1814 pub non_zero_length: i64,
1815 pub sparseIndex_type: SparseTensorIndex,
1816 pub sparseIndex: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1817 pub data: Option<&'a Buffer>,
1818}
1819impl<'a> Default for SparseTensorArgs<'a> {
1820 #[inline]
1821 fn default() -> Self {
1822 SparseTensorArgs {
1823 type_type: Type::NONE,
1824 type_: None, shape: None, non_zero_length: 0,
1827 sparseIndex_type: SparseTensorIndex::NONE,
1828 sparseIndex: None, data: None, }
1831 }
1832}
1833
1834pub struct SparseTensorBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
1835 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1836 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
1837}
1838impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorBuilder<'a, 'b, A> {
1839 #[inline]
1840 pub fn add_type_type(&mut self, type_type: Type) {
1841 self.fbb_
1842 .push_slot::<Type>(SparseTensor::VT_TYPE_TYPE, type_type, Type::NONE);
1843 }
1844 #[inline]
1845 pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
1846 self.fbb_
1847 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_TYPE_, type_);
1848 }
1849 #[inline]
1850 pub fn add_shape(
1851 &mut self,
1852 shape: flatbuffers::WIPOffset<
1853 flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<TensorDim<'b>>>,
1854 >,
1855 ) {
1856 self.fbb_
1857 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_SHAPE, shape);
1858 }
1859 #[inline]
1860 pub fn add_non_zero_length(&mut self, non_zero_length: i64) {
1861 self.fbb_
1862 .push_slot::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, non_zero_length, 0);
1863 }
1864 #[inline]
1865 pub fn add_sparseIndex_type(&mut self, sparseIndex_type: SparseTensorIndex) {
1866 self.fbb_.push_slot::<SparseTensorIndex>(
1867 SparseTensor::VT_SPARSEINDEX_TYPE,
1868 sparseIndex_type,
1869 SparseTensorIndex::NONE,
1870 );
1871 }
1872 #[inline]
1873 pub fn add_sparseIndex(
1874 &mut self,
1875 sparseIndex: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
1876 ) {
1877 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1878 SparseTensor::VT_SPARSEINDEX,
1879 sparseIndex,
1880 );
1881 }
1882 #[inline]
1883 pub fn add_data(&mut self, data: &Buffer) {
1884 self.fbb_
1885 .push_slot_always::<&Buffer>(SparseTensor::VT_DATA, data);
1886 }
1887 #[inline]
1888 pub fn new(
1889 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1890 ) -> SparseTensorBuilder<'a, 'b, A> {
1891 let start = _fbb.start_table();
1892 SparseTensorBuilder {
1893 fbb_: _fbb,
1894 start_: start,
1895 }
1896 }
1897 #[inline]
1898 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensor<'a>> {
1899 let o = self.fbb_.end_table(self.start_);
1900 self.fbb_.required(o, SparseTensor::VT_TYPE_, "type_");
1901 self.fbb_.required(o, SparseTensor::VT_SHAPE, "shape");
1902 self.fbb_
1903 .required(o, SparseTensor::VT_SPARSEINDEX, "sparseIndex");
1904 self.fbb_.required(o, SparseTensor::VT_DATA, "data");
1905 flatbuffers::WIPOffset::new(o.value())
1906 }
1907}
1908
1909impl core::fmt::Debug for SparseTensor<'_> {
1910 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1911 let mut ds = f.debug_struct("SparseTensor");
1912 ds.field("type_type", &self.type_type());
1913 match self.type_type() {
1914 Type::Null => {
1915 if let Some(x) = self.type_as_null() {
1916 ds.field("type_", &x)
1917 } else {
1918 ds.field(
1919 "type_",
1920 &"InvalidFlatbuffer: Union discriminant does not match value.",
1921 )
1922 }
1923 }
1924 Type::Int => {
1925 if let Some(x) = self.type_as_int() {
1926 ds.field("type_", &x)
1927 } else {
1928 ds.field(
1929 "type_",
1930 &"InvalidFlatbuffer: Union discriminant does not match value.",
1931 )
1932 }
1933 }
1934 Type::FloatingPoint => {
1935 if let Some(x) = self.type_as_floating_point() {
1936 ds.field("type_", &x)
1937 } else {
1938 ds.field(
1939 "type_",
1940 &"InvalidFlatbuffer: Union discriminant does not match value.",
1941 )
1942 }
1943 }
1944 Type::Binary => {
1945 if let Some(x) = self.type_as_binary() {
1946 ds.field("type_", &x)
1947 } else {
1948 ds.field(
1949 "type_",
1950 &"InvalidFlatbuffer: Union discriminant does not match value.",
1951 )
1952 }
1953 }
1954 Type::Utf8 => {
1955 if let Some(x) = self.type_as_utf_8() {
1956 ds.field("type_", &x)
1957 } else {
1958 ds.field(
1959 "type_",
1960 &"InvalidFlatbuffer: Union discriminant does not match value.",
1961 )
1962 }
1963 }
1964 Type::Bool => {
1965 if let Some(x) = self.type_as_bool() {
1966 ds.field("type_", &x)
1967 } else {
1968 ds.field(
1969 "type_",
1970 &"InvalidFlatbuffer: Union discriminant does not match value.",
1971 )
1972 }
1973 }
1974 Type::Decimal => {
1975 if let Some(x) = self.type_as_decimal() {
1976 ds.field("type_", &x)
1977 } else {
1978 ds.field(
1979 "type_",
1980 &"InvalidFlatbuffer: Union discriminant does not match value.",
1981 )
1982 }
1983 }
1984 Type::Date => {
1985 if let Some(x) = self.type_as_date() {
1986 ds.field("type_", &x)
1987 } else {
1988 ds.field(
1989 "type_",
1990 &"InvalidFlatbuffer: Union discriminant does not match value.",
1991 )
1992 }
1993 }
1994 Type::Time => {
1995 if let Some(x) = self.type_as_time() {
1996 ds.field("type_", &x)
1997 } else {
1998 ds.field(
1999 "type_",
2000 &"InvalidFlatbuffer: Union discriminant does not match value.",
2001 )
2002 }
2003 }
2004 Type::Timestamp => {
2005 if let Some(x) = self.type_as_timestamp() {
2006 ds.field("type_", &x)
2007 } else {
2008 ds.field(
2009 "type_",
2010 &"InvalidFlatbuffer: Union discriminant does not match value.",
2011 )
2012 }
2013 }
2014 Type::Interval => {
2015 if let Some(x) = self.type_as_interval() {
2016 ds.field("type_", &x)
2017 } else {
2018 ds.field(
2019 "type_",
2020 &"InvalidFlatbuffer: Union discriminant does not match value.",
2021 )
2022 }
2023 }
2024 Type::List => {
2025 if let Some(x) = self.type_as_list() {
2026 ds.field("type_", &x)
2027 } else {
2028 ds.field(
2029 "type_",
2030 &"InvalidFlatbuffer: Union discriminant does not match value.",
2031 )
2032 }
2033 }
2034 Type::Struct_ => {
2035 if let Some(x) = self.type_as_struct_() {
2036 ds.field("type_", &x)
2037 } else {
2038 ds.field(
2039 "type_",
2040 &"InvalidFlatbuffer: Union discriminant does not match value.",
2041 )
2042 }
2043 }
2044 Type::Union => {
2045 if let Some(x) = self.type_as_union() {
2046 ds.field("type_", &x)
2047 } else {
2048 ds.field(
2049 "type_",
2050 &"InvalidFlatbuffer: Union discriminant does not match value.",
2051 )
2052 }
2053 }
2054 Type::FixedSizeBinary => {
2055 if let Some(x) = self.type_as_fixed_size_binary() {
2056 ds.field("type_", &x)
2057 } else {
2058 ds.field(
2059 "type_",
2060 &"InvalidFlatbuffer: Union discriminant does not match value.",
2061 )
2062 }
2063 }
2064 Type::FixedSizeList => {
2065 if let Some(x) = self.type_as_fixed_size_list() {
2066 ds.field("type_", &x)
2067 } else {
2068 ds.field(
2069 "type_",
2070 &"InvalidFlatbuffer: Union discriminant does not match value.",
2071 )
2072 }
2073 }
2074 Type::Map => {
2075 if let Some(x) = self.type_as_map() {
2076 ds.field("type_", &x)
2077 } else {
2078 ds.field(
2079 "type_",
2080 &"InvalidFlatbuffer: Union discriminant does not match value.",
2081 )
2082 }
2083 }
2084 Type::Duration => {
2085 if let Some(x) = self.type_as_duration() {
2086 ds.field("type_", &x)
2087 } else {
2088 ds.field(
2089 "type_",
2090 &"InvalidFlatbuffer: Union discriminant does not match value.",
2091 )
2092 }
2093 }
2094 Type::LargeBinary => {
2095 if let Some(x) = self.type_as_large_binary() {
2096 ds.field("type_", &x)
2097 } else {
2098 ds.field(
2099 "type_",
2100 &"InvalidFlatbuffer: Union discriminant does not match value.",
2101 )
2102 }
2103 }
2104 Type::LargeUtf8 => {
2105 if let Some(x) = self.type_as_large_utf_8() {
2106 ds.field("type_", &x)
2107 } else {
2108 ds.field(
2109 "type_",
2110 &"InvalidFlatbuffer: Union discriminant does not match value.",
2111 )
2112 }
2113 }
2114 Type::LargeList => {
2115 if let Some(x) = self.type_as_large_list() {
2116 ds.field("type_", &x)
2117 } else {
2118 ds.field(
2119 "type_",
2120 &"InvalidFlatbuffer: Union discriminant does not match value.",
2121 )
2122 }
2123 }
2124 Type::RunEndEncoded => {
2125 if let Some(x) = self.type_as_run_end_encoded() {
2126 ds.field("type_", &x)
2127 } else {
2128 ds.field(
2129 "type_",
2130 &"InvalidFlatbuffer: Union discriminant does not match value.",
2131 )
2132 }
2133 }
2134 Type::BinaryView => {
2135 if let Some(x) = self.type_as_binary_view() {
2136 ds.field("type_", &x)
2137 } else {
2138 ds.field(
2139 "type_",
2140 &"InvalidFlatbuffer: Union discriminant does not match value.",
2141 )
2142 }
2143 }
2144 Type::Utf8View => {
2145 if let Some(x) = self.type_as_utf_8_view() {
2146 ds.field("type_", &x)
2147 } else {
2148 ds.field(
2149 "type_",
2150 &"InvalidFlatbuffer: Union discriminant does not match value.",
2151 )
2152 }
2153 }
2154 Type::ListView => {
2155 if let Some(x) = self.type_as_list_view() {
2156 ds.field("type_", &x)
2157 } else {
2158 ds.field(
2159 "type_",
2160 &"InvalidFlatbuffer: Union discriminant does not match value.",
2161 )
2162 }
2163 }
2164 Type::LargeListView => {
2165 if let Some(x) = self.type_as_large_list_view() {
2166 ds.field("type_", &x)
2167 } else {
2168 ds.field(
2169 "type_",
2170 &"InvalidFlatbuffer: Union discriminant does not match value.",
2171 )
2172 }
2173 }
2174 _ => {
2175 let x: Option<()> = None;
2176 ds.field("type_", &x)
2177 }
2178 };
2179 ds.field("shape", &self.shape());
2180 ds.field("non_zero_length", &self.non_zero_length());
2181 ds.field("sparseIndex_type", &self.sparseIndex_type());
2182 match self.sparseIndex_type() {
2183 SparseTensorIndex::SparseTensorIndexCOO => {
2184 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_coo() {
2185 ds.field("sparseIndex", &x)
2186 } else {
2187 ds.field(
2188 "sparseIndex",
2189 &"InvalidFlatbuffer: Union discriminant does not match value.",
2190 )
2191 }
2192 }
2193 SparseTensorIndex::SparseMatrixIndexCSX => {
2194 if let Some(x) = self.sparseIndex_as_sparse_matrix_index_csx() {
2195 ds.field("sparseIndex", &x)
2196 } else {
2197 ds.field(
2198 "sparseIndex",
2199 &"InvalidFlatbuffer: Union discriminant does not match value.",
2200 )
2201 }
2202 }
2203 SparseTensorIndex::SparseTensorIndexCSF => {
2204 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_csf() {
2205 ds.field("sparseIndex", &x)
2206 } else {
2207 ds.field(
2208 "sparseIndex",
2209 &"InvalidFlatbuffer: Union discriminant does not match value.",
2210 )
2211 }
2212 }
2213 _ => {
2214 let x: Option<()> = None;
2215 ds.field("sparseIndex", &x)
2216 }
2217 };
2218 ds.field("data", &self.data());
2219 ds.finish()
2220 }
2221}
2222#[inline]
2223pub fn root_as_sparse_tensor(buf: &[u8]) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2230 flatbuffers::root::<SparseTensor>(buf)
2231}
2232#[inline]
2233pub fn size_prefixed_root_as_sparse_tensor(
2240 buf: &[u8],
2241) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2242 flatbuffers::size_prefixed_root::<SparseTensor>(buf)
2243}
2244#[inline]
2245pub fn root_as_sparse_tensor_with_opts<'b, 'o>(
2252 opts: &'o flatbuffers::VerifierOptions,
2253 buf: &'b [u8],
2254) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
2255 flatbuffers::root_with_opts::<SparseTensor<'b>>(opts, buf)
2256}
2257#[inline]
2258pub fn size_prefixed_root_as_sparse_tensor_with_opts<'b, 'o>(
2265 opts: &'o flatbuffers::VerifierOptions,
2266 buf: &'b [u8],
2267) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
2268 flatbuffers::size_prefixed_root_with_opts::<SparseTensor<'b>>(opts, buf)
2269}
2270#[inline]
2271pub unsafe fn root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2275 unsafe { flatbuffers::root_unchecked::<SparseTensor>(buf) }
2276}
2277#[inline]
2278pub unsafe fn size_prefixed_root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2282 unsafe { flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf) }
2283}
2284#[inline]
2285pub fn finish_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
2286 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
2287 root: flatbuffers::WIPOffset<SparseTensor<'a>>,
2288) {
2289 fbb.finish(root, None);
2290}
2291
2292#[inline]
2293pub fn finish_size_prefixed_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
2294 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
2295 root: flatbuffers::WIPOffset<SparseTensor<'a>>,
2296) {
2297 fbb.finish_size_prefixed(root, None);
2298}