1#![allow(dead_code)]
6#![allow(unused_imports)]
7
8use crate::r#gen::Schema::*;
9use crate::r#gen::Tensor::*;
10use flatbuffers::EndianScalar;
11use std::{cmp::Ordering, mem};
12#[deprecated(
17 since = "2.0.0",
18 note = "Use associated constants instead. This will no longer be generated in 2021."
19)]
20pub const ENUM_MIN_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 0;
21#[deprecated(
22 since = "2.0.0",
23 note = "Use associated constants instead. This will no longer be generated in 2021."
24)]
25pub const ENUM_MAX_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 1;
26#[deprecated(
27 since = "2.0.0",
28 note = "Use associated constants instead. This will no longer be generated in 2021."
29)]
30#[allow(non_camel_case_types)]
31pub const ENUM_VALUES_SPARSE_MATRIX_COMPRESSED_AXIS: [SparseMatrixCompressedAxis; 2] = [
32 SparseMatrixCompressedAxis::Row,
33 SparseMatrixCompressedAxis::Column,
34];
35
36#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
37#[repr(transparent)]
38pub struct SparseMatrixCompressedAxis(pub i16);
39#[allow(non_upper_case_globals)]
40impl SparseMatrixCompressedAxis {
41 pub const Row: Self = Self(0);
42 pub const Column: Self = Self(1);
43
44 pub const ENUM_MIN: i16 = 0;
45 pub const ENUM_MAX: i16 = 1;
46 pub const ENUM_VALUES: &'static [Self] = &[Self::Row, Self::Column];
47 pub fn variant_name(self) -> Option<&'static str> {
49 match self {
50 Self::Row => Some("Row"),
51 Self::Column => Some("Column"),
52 _ => None,
53 }
54 }
55}
56impl core::fmt::Debug for SparseMatrixCompressedAxis {
57 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
58 if let Some(name) = self.variant_name() {
59 f.write_str(name)
60 } else {
61 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
62 }
63 }
64}
65impl<'a> flatbuffers::Follow<'a> for SparseMatrixCompressedAxis {
66 type Inner = Self;
67 #[inline]
68 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
69 let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
70 Self(b)
71 }
72}
73
74impl flatbuffers::Push for SparseMatrixCompressedAxis {
75 type Output = SparseMatrixCompressedAxis;
76 #[inline]
77 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
78 unsafe {
79 flatbuffers::emplace_scalar::<i16>(dst, self.0);
80 }
81 }
82}
83
84impl flatbuffers::EndianScalar for SparseMatrixCompressedAxis {
85 type Scalar = i16;
86 #[inline]
87 fn to_little_endian(self) -> i16 {
88 self.0.to_le()
89 }
90 #[inline]
91 #[allow(clippy::wrong_self_convention)]
92 fn from_little_endian(v: i16) -> Self {
93 let b = i16::from_le(v);
94 Self(b)
95 }
96}
97
98impl<'a> flatbuffers::Verifiable for SparseMatrixCompressedAxis {
99 #[inline]
100 fn run_verifier(
101 v: &mut flatbuffers::Verifier,
102 pos: usize,
103 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
104 use flatbuffers::Verifiable;
105 i16::run_verifier(v, pos)
106 }
107}
108
109impl flatbuffers::SimpleToVerifyInSlice for SparseMatrixCompressedAxis {}
110#[deprecated(
111 since = "2.0.0",
112 note = "Use associated constants instead. This will no longer be generated in 2021."
113)]
114pub const ENUM_MIN_SPARSE_TENSOR_INDEX: u8 = 0;
115#[deprecated(
116 since = "2.0.0",
117 note = "Use associated constants instead. This will no longer be generated in 2021."
118)]
119pub const ENUM_MAX_SPARSE_TENSOR_INDEX: u8 = 3;
120#[deprecated(
121 since = "2.0.0",
122 note = "Use associated constants instead. This will no longer be generated in 2021."
123)]
124#[allow(non_camel_case_types)]
125pub const ENUM_VALUES_SPARSE_TENSOR_INDEX: [SparseTensorIndex; 4] = [
126 SparseTensorIndex::NONE,
127 SparseTensorIndex::SparseTensorIndexCOO,
128 SparseTensorIndex::SparseMatrixIndexCSX,
129 SparseTensorIndex::SparseTensorIndexCSF,
130];
131
132#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
133#[repr(transparent)]
134pub struct SparseTensorIndex(pub u8);
135#[allow(non_upper_case_globals)]
136impl SparseTensorIndex {
137 pub const NONE: Self = Self(0);
138 pub const SparseTensorIndexCOO: Self = Self(1);
139 pub const SparseMatrixIndexCSX: Self = Self(2);
140 pub const SparseTensorIndexCSF: Self = Self(3);
141
142 pub const ENUM_MIN: u8 = 0;
143 pub const ENUM_MAX: u8 = 3;
144 pub const ENUM_VALUES: &'static [Self] = &[
145 Self::NONE,
146 Self::SparseTensorIndexCOO,
147 Self::SparseMatrixIndexCSX,
148 Self::SparseTensorIndexCSF,
149 ];
150 pub fn variant_name(self) -> Option<&'static str> {
152 match self {
153 Self::NONE => Some("NONE"),
154 Self::SparseTensorIndexCOO => Some("SparseTensorIndexCOO"),
155 Self::SparseMatrixIndexCSX => Some("SparseMatrixIndexCSX"),
156 Self::SparseTensorIndexCSF => Some("SparseTensorIndexCSF"),
157 _ => None,
158 }
159 }
160}
161impl core::fmt::Debug for SparseTensorIndex {
162 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
163 if let Some(name) = self.variant_name() {
164 f.write_str(name)
165 } else {
166 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
167 }
168 }
169}
170impl<'a> flatbuffers::Follow<'a> for SparseTensorIndex {
171 type Inner = Self;
172 #[inline]
173 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
174 let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
175 Self(b)
176 }
177}
178
179impl flatbuffers::Push for SparseTensorIndex {
180 type Output = SparseTensorIndex;
181 #[inline]
182 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
183 unsafe {
184 flatbuffers::emplace_scalar::<u8>(dst, self.0);
185 }
186 }
187}
188
189impl flatbuffers::EndianScalar for SparseTensorIndex {
190 type Scalar = u8;
191 #[inline]
192 fn to_little_endian(self) -> u8 {
193 self.0.to_le()
194 }
195 #[inline]
196 #[allow(clippy::wrong_self_convention)]
197 fn from_little_endian(v: u8) -> Self {
198 let b = u8::from_le(v);
199 Self(b)
200 }
201}
202
203impl<'a> flatbuffers::Verifiable for SparseTensorIndex {
204 #[inline]
205 fn run_verifier(
206 v: &mut flatbuffers::Verifier,
207 pos: usize,
208 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
209 use flatbuffers::Verifiable;
210 u8::run_verifier(v, pos)
211 }
212}
213
214impl flatbuffers::SimpleToVerifyInSlice for SparseTensorIndex {}
215pub struct SparseTensorIndexUnionTableOffset {}
216
217pub enum SparseTensorIndexCOOOffset {}
218#[derive(Copy, Clone, PartialEq)]
219
220pub struct SparseTensorIndexCOO<'a> {
253 pub _tab: flatbuffers::Table<'a>,
254}
255
256impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCOO<'a> {
257 type Inner = SparseTensorIndexCOO<'a>;
258 #[inline]
259 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
260 Self {
261 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
262 }
263 }
264}
265
266impl<'a> SparseTensorIndexCOO<'a> {
267 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 4;
268 pub const VT_INDICESSTRIDES: flatbuffers::VOffsetT = 6;
269 pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 8;
270 pub const VT_ISCANONICAL: flatbuffers::VOffsetT = 10;
271
272 #[inline]
273 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
274 SparseTensorIndexCOO { _tab: table }
275 }
276 #[allow(unused_mut)]
277 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
278 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
279 args: &'args SparseTensorIndexCOOArgs<'args>,
280 ) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'bldr>> {
281 let mut builder = SparseTensorIndexCOOBuilder::new(_fbb);
282 if let Some(x) = args.indicesBuffer {
283 builder.add_indicesBuffer(x);
284 }
285 if let Some(x) = args.indicesStrides {
286 builder.add_indicesStrides(x);
287 }
288 if let Some(x) = args.indicesType {
289 builder.add_indicesType(x);
290 }
291 builder.add_isCanonical(args.isCanonical);
292 builder.finish()
293 }
294
295 #[inline]
297 pub fn indicesType(&self) -> Int<'a> {
298 unsafe {
302 self._tab
303 .get::<flatbuffers::ForwardsUOffset<Int>>(
304 SparseTensorIndexCOO::VT_INDICESTYPE,
305 None,
306 )
307 .unwrap()
308 }
309 }
310 #[inline]
313 pub fn indicesStrides(&self) -> Option<flatbuffers::Vector<'a, i64>> {
314 unsafe {
318 self._tab
319 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i64>>>(
320 SparseTensorIndexCOO::VT_INDICESSTRIDES,
321 None,
322 )
323 }
324 }
325 #[inline]
327 pub fn indicesBuffer(&self) -> &'a Buffer {
328 unsafe {
332 self._tab
333 .get::<Buffer>(SparseTensorIndexCOO::VT_INDICESBUFFER, None)
334 .unwrap()
335 }
336 }
337 #[inline]
343 pub fn isCanonical(&self) -> bool {
344 unsafe {
348 self._tab
349 .get::<bool>(SparseTensorIndexCOO::VT_ISCANONICAL, Some(false))
350 .unwrap()
351 }
352 }
353}
354
355impl flatbuffers::Verifiable for SparseTensorIndexCOO<'_> {
356 #[inline]
357 fn run_verifier(
358 v: &mut flatbuffers::Verifier,
359 pos: usize,
360 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
361 use flatbuffers::Verifiable;
362 v.visit_table(pos)?
363 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
364 "indicesType",
365 Self::VT_INDICESTYPE,
366 true,
367 )?
368 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
369 "indicesStrides",
370 Self::VT_INDICESSTRIDES,
371 false,
372 )?
373 .visit_field::<Buffer>("indicesBuffer", Self::VT_INDICESBUFFER, true)?
374 .visit_field::<bool>("isCanonical", Self::VT_ISCANONICAL, false)?
375 .finish();
376 Ok(())
377 }
378}
379pub struct SparseTensorIndexCOOArgs<'a> {
380 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
381 pub indicesStrides: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
382 pub indicesBuffer: Option<&'a Buffer>,
383 pub isCanonical: bool,
384}
385impl<'a> Default for SparseTensorIndexCOOArgs<'a> {
386 #[inline]
387 fn default() -> Self {
388 SparseTensorIndexCOOArgs {
389 indicesType: None, indicesStrides: None,
391 indicesBuffer: None, isCanonical: false,
393 }
394 }
395}
396
397pub struct SparseTensorIndexCOOBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
398 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
399 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
400}
401impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorIndexCOOBuilder<'a, 'b, A> {
402 #[inline]
403 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
404 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
405 SparseTensorIndexCOO::VT_INDICESTYPE,
406 indicesType,
407 );
408 }
409 #[inline]
410 pub fn add_indicesStrides(
411 &mut self,
412 indicesStrides: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i64>>,
413 ) {
414 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
415 SparseTensorIndexCOO::VT_INDICESSTRIDES,
416 indicesStrides,
417 );
418 }
419 #[inline]
420 pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
421 self.fbb_
422 .push_slot_always::<&Buffer>(SparseTensorIndexCOO::VT_INDICESBUFFER, indicesBuffer);
423 }
424 #[inline]
425 pub fn add_isCanonical(&mut self, isCanonical: bool) {
426 self.fbb_
427 .push_slot::<bool>(SparseTensorIndexCOO::VT_ISCANONICAL, isCanonical, false);
428 }
429 #[inline]
430 pub fn new(
431 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
432 ) -> SparseTensorIndexCOOBuilder<'a, 'b, A> {
433 let start = _fbb.start_table();
434 SparseTensorIndexCOOBuilder {
435 fbb_: _fbb,
436 start_: start,
437 }
438 }
439 #[inline]
440 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'a>> {
441 let o = self.fbb_.end_table(self.start_);
442 self.fbb_
443 .required(o, SparseTensorIndexCOO::VT_INDICESTYPE, "indicesType");
444 self.fbb_
445 .required(o, SparseTensorIndexCOO::VT_INDICESBUFFER, "indicesBuffer");
446 flatbuffers::WIPOffset::new(o.value())
447 }
448}
449
450impl core::fmt::Debug for SparseTensorIndexCOO<'_> {
451 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
452 let mut ds = f.debug_struct("SparseTensorIndexCOO");
453 ds.field("indicesType", &self.indicesType());
454 ds.field("indicesStrides", &self.indicesStrides());
455 ds.field("indicesBuffer", &self.indicesBuffer());
456 ds.field("isCanonical", &self.isCanonical());
457 ds.finish()
458 }
459}
460pub enum SparseMatrixIndexCSXOffset {}
461#[derive(Copy, Clone, PartialEq)]
462
463pub struct SparseMatrixIndexCSX<'a> {
465 pub _tab: flatbuffers::Table<'a>,
466}
467
468impl<'a> flatbuffers::Follow<'a> for SparseMatrixIndexCSX<'a> {
469 type Inner = SparseMatrixIndexCSX<'a>;
470 #[inline]
471 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
472 Self {
473 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
474 }
475 }
476}
477
478impl<'a> SparseMatrixIndexCSX<'a> {
479 pub const VT_COMPRESSEDAXIS: flatbuffers::VOffsetT = 4;
480 pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 6;
481 pub const VT_INDPTRBUFFER: flatbuffers::VOffsetT = 8;
482 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 10;
483 pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 12;
484
485 #[inline]
486 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
487 SparseMatrixIndexCSX { _tab: table }
488 }
489 #[allow(unused_mut)]
490 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
491 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
492 args: &'args SparseMatrixIndexCSXArgs<'args>,
493 ) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'bldr>> {
494 let mut builder = SparseMatrixIndexCSXBuilder::new(_fbb);
495 if let Some(x) = args.indicesBuffer {
496 builder.add_indicesBuffer(x);
497 }
498 if let Some(x) = args.indicesType {
499 builder.add_indicesType(x);
500 }
501 if let Some(x) = args.indptrBuffer {
502 builder.add_indptrBuffer(x);
503 }
504 if let Some(x) = args.indptrType {
505 builder.add_indptrType(x);
506 }
507 builder.add_compressedAxis(args.compressedAxis);
508 builder.finish()
509 }
510
511 #[inline]
513 pub fn compressedAxis(&self) -> SparseMatrixCompressedAxis {
514 unsafe {
518 self._tab
519 .get::<SparseMatrixCompressedAxis>(
520 SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
521 Some(SparseMatrixCompressedAxis::Row),
522 )
523 .unwrap()
524 }
525 }
526 #[inline]
528 pub fn indptrType(&self) -> Int<'a> {
529 unsafe {
533 self._tab
534 .get::<flatbuffers::ForwardsUOffset<Int>>(SparseMatrixIndexCSX::VT_INDPTRTYPE, None)
535 .unwrap()
536 }
537 }
538 #[inline]
562 pub fn indptrBuffer(&self) -> &'a Buffer {
563 unsafe {
567 self._tab
568 .get::<Buffer>(SparseMatrixIndexCSX::VT_INDPTRBUFFER, None)
569 .unwrap()
570 }
571 }
572 #[inline]
574 pub fn indicesType(&self) -> Int<'a> {
575 unsafe {
579 self._tab
580 .get::<flatbuffers::ForwardsUOffset<Int>>(
581 SparseMatrixIndexCSX::VT_INDICESTYPE,
582 None,
583 )
584 .unwrap()
585 }
586 }
587 #[inline]
597 pub fn indicesBuffer(&self) -> &'a Buffer {
598 unsafe {
602 self._tab
603 .get::<Buffer>(SparseMatrixIndexCSX::VT_INDICESBUFFER, None)
604 .unwrap()
605 }
606 }
607}
608
609impl flatbuffers::Verifiable for SparseMatrixIndexCSX<'_> {
610 #[inline]
611 fn run_verifier(
612 v: &mut flatbuffers::Verifier,
613 pos: usize,
614 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
615 use flatbuffers::Verifiable;
616 v.visit_table(pos)?
617 .visit_field::<SparseMatrixCompressedAxis>(
618 "compressedAxis",
619 Self::VT_COMPRESSEDAXIS,
620 false,
621 )?
622 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
623 "indptrType",
624 Self::VT_INDPTRTYPE,
625 true,
626 )?
627 .visit_field::<Buffer>("indptrBuffer", Self::VT_INDPTRBUFFER, true)?
628 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
629 "indicesType",
630 Self::VT_INDICESTYPE,
631 true,
632 )?
633 .visit_field::<Buffer>("indicesBuffer", Self::VT_INDICESBUFFER, true)?
634 .finish();
635 Ok(())
636 }
637}
638pub struct SparseMatrixIndexCSXArgs<'a> {
639 pub compressedAxis: SparseMatrixCompressedAxis,
640 pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
641 pub indptrBuffer: Option<&'a Buffer>,
642 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
643 pub indicesBuffer: Option<&'a Buffer>,
644}
645impl<'a> Default for SparseMatrixIndexCSXArgs<'a> {
646 #[inline]
647 fn default() -> Self {
648 SparseMatrixIndexCSXArgs {
649 compressedAxis: SparseMatrixCompressedAxis::Row,
650 indptrType: None, indptrBuffer: None, indicesType: None, indicesBuffer: None, }
655 }
656}
657
658pub struct SparseMatrixIndexCSXBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
659 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
660 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
661}
662impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseMatrixIndexCSXBuilder<'a, 'b, A> {
663 #[inline]
664 pub fn add_compressedAxis(&mut self, compressedAxis: SparseMatrixCompressedAxis) {
665 self.fbb_.push_slot::<SparseMatrixCompressedAxis>(
666 SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
667 compressedAxis,
668 SparseMatrixCompressedAxis::Row,
669 );
670 }
671 #[inline]
672 pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
673 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
674 SparseMatrixIndexCSX::VT_INDPTRTYPE,
675 indptrType,
676 );
677 }
678 #[inline]
679 pub fn add_indptrBuffer(&mut self, indptrBuffer: &Buffer) {
680 self.fbb_
681 .push_slot_always::<&Buffer>(SparseMatrixIndexCSX::VT_INDPTRBUFFER, indptrBuffer);
682 }
683 #[inline]
684 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
685 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
686 SparseMatrixIndexCSX::VT_INDICESTYPE,
687 indicesType,
688 );
689 }
690 #[inline]
691 pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
692 self.fbb_
693 .push_slot_always::<&Buffer>(SparseMatrixIndexCSX::VT_INDICESBUFFER, indicesBuffer);
694 }
695 #[inline]
696 pub fn new(
697 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
698 ) -> SparseMatrixIndexCSXBuilder<'a, 'b, A> {
699 let start = _fbb.start_table();
700 SparseMatrixIndexCSXBuilder {
701 fbb_: _fbb,
702 start_: start,
703 }
704 }
705 #[inline]
706 pub fn finish(self) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'a>> {
707 let o = self.fbb_.end_table(self.start_);
708 self.fbb_
709 .required(o, SparseMatrixIndexCSX::VT_INDPTRTYPE, "indptrType");
710 self.fbb_
711 .required(o, SparseMatrixIndexCSX::VT_INDPTRBUFFER, "indptrBuffer");
712 self.fbb_
713 .required(o, SparseMatrixIndexCSX::VT_INDICESTYPE, "indicesType");
714 self.fbb_
715 .required(o, SparseMatrixIndexCSX::VT_INDICESBUFFER, "indicesBuffer");
716 flatbuffers::WIPOffset::new(o.value())
717 }
718}
719
720impl core::fmt::Debug for SparseMatrixIndexCSX<'_> {
721 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
722 let mut ds = f.debug_struct("SparseMatrixIndexCSX");
723 ds.field("compressedAxis", &self.compressedAxis());
724 ds.field("indptrType", &self.indptrType());
725 ds.field("indptrBuffer", &self.indptrBuffer());
726 ds.field("indicesType", &self.indicesType());
727 ds.field("indicesBuffer", &self.indicesBuffer());
728 ds.finish()
729 }
730}
731pub enum SparseTensorIndexCSFOffset {}
732#[derive(Copy, Clone, PartialEq)]
733
734pub struct SparseTensorIndexCSF<'a> {
736 pub _tab: flatbuffers::Table<'a>,
737}
738
739impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCSF<'a> {
740 type Inner = SparseTensorIndexCSF<'a>;
741 #[inline]
742 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
743 Self {
744 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
745 }
746 }
747}
748
749impl<'a> SparseTensorIndexCSF<'a> {
750 pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 4;
751 pub const VT_INDPTRBUFFERS: flatbuffers::VOffsetT = 6;
752 pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 8;
753 pub const VT_INDICESBUFFERS: flatbuffers::VOffsetT = 10;
754 pub const VT_AXISORDER: flatbuffers::VOffsetT = 12;
755
756 #[inline]
757 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
758 SparseTensorIndexCSF { _tab: table }
759 }
760 #[allow(unused_mut)]
761 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
762 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
763 args: &'args SparseTensorIndexCSFArgs<'args>,
764 ) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'bldr>> {
765 let mut builder = SparseTensorIndexCSFBuilder::new(_fbb);
766 if let Some(x) = args.axisOrder {
767 builder.add_axisOrder(x);
768 }
769 if let Some(x) = args.indicesBuffers {
770 builder.add_indicesBuffers(x);
771 }
772 if let Some(x) = args.indicesType {
773 builder.add_indicesType(x);
774 }
775 if let Some(x) = args.indptrBuffers {
776 builder.add_indptrBuffers(x);
777 }
778 if let Some(x) = args.indptrType {
779 builder.add_indptrType(x);
780 }
781 builder.finish()
782 }
783
784 #[inline]
816 pub fn indptrType(&self) -> Int<'a> {
817 unsafe {
821 self._tab
822 .get::<flatbuffers::ForwardsUOffset<Int>>(SparseTensorIndexCSF::VT_INDPTRTYPE, None)
823 .unwrap()
824 }
825 }
826 #[inline]
841 pub fn indptrBuffers(&self) -> flatbuffers::Vector<'a, Buffer> {
842 unsafe {
846 self._tab
847 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
848 SparseTensorIndexCSF::VT_INDPTRBUFFERS,
849 None,
850 )
851 .unwrap()
852 }
853 }
854 #[inline]
856 pub fn indicesType(&self) -> Int<'a> {
857 unsafe {
861 self._tab
862 .get::<flatbuffers::ForwardsUOffset<Int>>(
863 SparseTensorIndexCSF::VT_INDICESTYPE,
864 None,
865 )
866 .unwrap()
867 }
868 }
869 #[inline]
881 pub fn indicesBuffers(&self) -> flatbuffers::Vector<'a, Buffer> {
882 unsafe {
886 self._tab
887 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
888 SparseTensorIndexCSF::VT_INDICESBUFFERS,
889 None,
890 )
891 .unwrap()
892 }
893 }
894 #[inline]
901 pub fn axisOrder(&self) -> flatbuffers::Vector<'a, i32> {
902 unsafe {
906 self._tab
907 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(
908 SparseTensorIndexCSF::VT_AXISORDER,
909 None,
910 )
911 .unwrap()
912 }
913 }
914}
915
916impl flatbuffers::Verifiable for SparseTensorIndexCSF<'_> {
917 #[inline]
918 fn run_verifier(
919 v: &mut flatbuffers::Verifier,
920 pos: usize,
921 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
922 use flatbuffers::Verifiable;
923 v.visit_table(pos)?
924 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
925 "indptrType",
926 Self::VT_INDPTRTYPE,
927 true,
928 )?
929 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
930 "indptrBuffers",
931 Self::VT_INDPTRBUFFERS,
932 true,
933 )?
934 .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
935 "indicesType",
936 Self::VT_INDICESTYPE,
937 true,
938 )?
939 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
940 "indicesBuffers",
941 Self::VT_INDICESBUFFERS,
942 true,
943 )?
944 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(
945 "axisOrder",
946 Self::VT_AXISORDER,
947 true,
948 )?
949 .finish();
950 Ok(())
951 }
952}
953pub struct SparseTensorIndexCSFArgs<'a> {
954 pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
955 pub indptrBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
956 pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
957 pub indicesBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
958 pub axisOrder: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
959}
960impl<'a> Default for SparseTensorIndexCSFArgs<'a> {
961 #[inline]
962 fn default() -> Self {
963 SparseTensorIndexCSFArgs {
964 indptrType: None, indptrBuffers: None, indicesType: None, indicesBuffers: None, axisOrder: None, }
970 }
971}
972
973pub struct SparseTensorIndexCSFBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
974 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
975 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
976}
977impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorIndexCSFBuilder<'a, 'b, A> {
978 #[inline]
979 pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
980 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
981 SparseTensorIndexCSF::VT_INDPTRTYPE,
982 indptrType,
983 );
984 }
985 #[inline]
986 pub fn add_indptrBuffers(
987 &mut self,
988 indptrBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
989 ) {
990 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
991 SparseTensorIndexCSF::VT_INDPTRBUFFERS,
992 indptrBuffers,
993 );
994 }
995 #[inline]
996 pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
997 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
998 SparseTensorIndexCSF::VT_INDICESTYPE,
999 indicesType,
1000 );
1001 }
1002 #[inline]
1003 pub fn add_indicesBuffers(
1004 &mut self,
1005 indicesBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
1006 ) {
1007 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1008 SparseTensorIndexCSF::VT_INDICESBUFFERS,
1009 indicesBuffers,
1010 );
1011 }
1012 #[inline]
1013 pub fn add_axisOrder(
1014 &mut self,
1015 axisOrder: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i32>>,
1016 ) {
1017 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1018 SparseTensorIndexCSF::VT_AXISORDER,
1019 axisOrder,
1020 );
1021 }
1022 #[inline]
1023 pub fn new(
1024 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1025 ) -> SparseTensorIndexCSFBuilder<'a, 'b, A> {
1026 let start = _fbb.start_table();
1027 SparseTensorIndexCSFBuilder {
1028 fbb_: _fbb,
1029 start_: start,
1030 }
1031 }
1032 #[inline]
1033 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'a>> {
1034 let o = self.fbb_.end_table(self.start_);
1035 self.fbb_
1036 .required(o, SparseTensorIndexCSF::VT_INDPTRTYPE, "indptrType");
1037 self.fbb_
1038 .required(o, SparseTensorIndexCSF::VT_INDPTRBUFFERS, "indptrBuffers");
1039 self.fbb_
1040 .required(o, SparseTensorIndexCSF::VT_INDICESTYPE, "indicesType");
1041 self.fbb_
1042 .required(o, SparseTensorIndexCSF::VT_INDICESBUFFERS, "indicesBuffers");
1043 self.fbb_
1044 .required(o, SparseTensorIndexCSF::VT_AXISORDER, "axisOrder");
1045 flatbuffers::WIPOffset::new(o.value())
1046 }
1047}
1048
1049impl core::fmt::Debug for SparseTensorIndexCSF<'_> {
1050 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1051 let mut ds = f.debug_struct("SparseTensorIndexCSF");
1052 ds.field("indptrType", &self.indptrType());
1053 ds.field("indptrBuffers", &self.indptrBuffers());
1054 ds.field("indicesType", &self.indicesType());
1055 ds.field("indicesBuffers", &self.indicesBuffers());
1056 ds.field("axisOrder", &self.axisOrder());
1057 ds.finish()
1058 }
1059}
1060pub enum SparseTensorOffset {}
1061#[derive(Copy, Clone, PartialEq)]
1062
1063pub struct SparseTensor<'a> {
1069 pub _tab: flatbuffers::Table<'a>,
1070}
1071
1072impl<'a> flatbuffers::Follow<'a> for SparseTensor<'a> {
1073 type Inner = SparseTensor<'a>;
1074 #[inline]
1075 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
1076 Self {
1077 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
1078 }
1079 }
1080}
1081
1082impl<'a> SparseTensor<'a> {
1083 pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4;
1084 pub const VT_TYPE_: flatbuffers::VOffsetT = 6;
1085 pub const VT_SHAPE: flatbuffers::VOffsetT = 8;
1086 pub const VT_NON_ZERO_LENGTH: flatbuffers::VOffsetT = 10;
1087 pub const VT_SPARSEINDEX_TYPE: flatbuffers::VOffsetT = 12;
1088 pub const VT_SPARSEINDEX: flatbuffers::VOffsetT = 14;
1089 pub const VT_DATA: flatbuffers::VOffsetT = 16;
1090
1091 #[inline]
1092 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
1093 SparseTensor { _tab: table }
1094 }
1095 #[allow(unused_mut)]
1096 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
1097 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
1098 args: &'args SparseTensorArgs<'args>,
1099 ) -> flatbuffers::WIPOffset<SparseTensor<'bldr>> {
1100 let mut builder = SparseTensorBuilder::new(_fbb);
1101 builder.add_non_zero_length(args.non_zero_length);
1102 if let Some(x) = args.data {
1103 builder.add_data(x);
1104 }
1105 if let Some(x) = args.sparseIndex {
1106 builder.add_sparseIndex(x);
1107 }
1108 if let Some(x) = args.shape {
1109 builder.add_shape(x);
1110 }
1111 if let Some(x) = args.type_ {
1112 builder.add_type_(x);
1113 }
1114 builder.add_sparseIndex_type(args.sparseIndex_type);
1115 builder.add_type_type(args.type_type);
1116 builder.finish()
1117 }
1118
1119 #[inline]
1120 pub fn type_type(&self) -> Type {
1121 unsafe {
1125 self._tab
1126 .get::<Type>(SparseTensor::VT_TYPE_TYPE, Some(Type::NONE))
1127 .unwrap()
1128 }
1129 }
1130 #[inline]
1134 pub fn type_(&self) -> flatbuffers::Table<'a> {
1135 unsafe {
1139 self._tab
1140 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1141 SparseTensor::VT_TYPE_,
1142 None,
1143 )
1144 .unwrap()
1145 }
1146 }
1147 #[inline]
1149 pub fn shape(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
1150 unsafe {
1154 self._tab
1155 .get::<flatbuffers::ForwardsUOffset<
1156 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim>>,
1157 >>(SparseTensor::VT_SHAPE, None)
1158 .unwrap()
1159 }
1160 }
1161 #[inline]
1163 pub fn non_zero_length(&self) -> i64 {
1164 unsafe {
1168 self._tab
1169 .get::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, Some(0))
1170 .unwrap()
1171 }
1172 }
1173 #[inline]
1174 pub fn sparseIndex_type(&self) -> SparseTensorIndex {
1175 unsafe {
1179 self._tab
1180 .get::<SparseTensorIndex>(
1181 SparseTensor::VT_SPARSEINDEX_TYPE,
1182 Some(SparseTensorIndex::NONE),
1183 )
1184 .unwrap()
1185 }
1186 }
1187 #[inline]
1189 pub fn sparseIndex(&self) -> flatbuffers::Table<'a> {
1190 unsafe {
1194 self._tab
1195 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1196 SparseTensor::VT_SPARSEINDEX,
1197 None,
1198 )
1199 .unwrap()
1200 }
1201 }
1202 #[inline]
1204 pub fn data(&self) -> &'a Buffer {
1205 unsafe {
1209 self._tab
1210 .get::<Buffer>(SparseTensor::VT_DATA, None)
1211 .unwrap()
1212 }
1213 }
1214 #[inline]
1215 #[allow(non_snake_case)]
1216 pub fn type_as_null(&self) -> Option<Null<'a>> {
1217 if self.type_type() == Type::Null {
1218 let u = self.type_();
1219 Some(unsafe { Null::init_from_table(u) })
1223 } else {
1224 None
1225 }
1226 }
1227
1228 #[inline]
1229 #[allow(non_snake_case)]
1230 pub fn type_as_int(&self) -> Option<Int<'a>> {
1231 if self.type_type() == Type::Int {
1232 let u = self.type_();
1233 Some(unsafe { Int::init_from_table(u) })
1237 } else {
1238 None
1239 }
1240 }
1241
1242 #[inline]
1243 #[allow(non_snake_case)]
1244 pub fn type_as_floating_point(&self) -> Option<FloatingPoint<'a>> {
1245 if self.type_type() == Type::FloatingPoint {
1246 let u = self.type_();
1247 Some(unsafe { FloatingPoint::init_from_table(u) })
1251 } else {
1252 None
1253 }
1254 }
1255
1256 #[inline]
1257 #[allow(non_snake_case)]
1258 pub fn type_as_binary(&self) -> Option<Binary<'a>> {
1259 if self.type_type() == Type::Binary {
1260 let u = self.type_();
1261 Some(unsafe { Binary::init_from_table(u) })
1265 } else {
1266 None
1267 }
1268 }
1269
1270 #[inline]
1271 #[allow(non_snake_case)]
1272 pub fn type_as_utf_8(&self) -> Option<Utf8<'a>> {
1273 if self.type_type() == Type::Utf8 {
1274 let u = self.type_();
1275 Some(unsafe { Utf8::init_from_table(u) })
1279 } else {
1280 None
1281 }
1282 }
1283
1284 #[inline]
1285 #[allow(non_snake_case)]
1286 pub fn type_as_bool(&self) -> Option<Bool<'a>> {
1287 if self.type_type() == Type::Bool {
1288 let u = self.type_();
1289 Some(unsafe { Bool::init_from_table(u) })
1293 } else {
1294 None
1295 }
1296 }
1297
1298 #[inline]
1299 #[allow(non_snake_case)]
1300 pub fn type_as_decimal(&self) -> Option<Decimal<'a>> {
1301 if self.type_type() == Type::Decimal {
1302 let u = self.type_();
1303 Some(unsafe { Decimal::init_from_table(u) })
1307 } else {
1308 None
1309 }
1310 }
1311
1312 #[inline]
1313 #[allow(non_snake_case)]
1314 pub fn type_as_date(&self) -> Option<Date<'a>> {
1315 if self.type_type() == Type::Date {
1316 let u = self.type_();
1317 Some(unsafe { Date::init_from_table(u) })
1321 } else {
1322 None
1323 }
1324 }
1325
1326 #[inline]
1327 #[allow(non_snake_case)]
1328 pub fn type_as_time(&self) -> Option<Time<'a>> {
1329 if self.type_type() == Type::Time {
1330 let u = self.type_();
1331 Some(unsafe { Time::init_from_table(u) })
1335 } else {
1336 None
1337 }
1338 }
1339
1340 #[inline]
1341 #[allow(non_snake_case)]
1342 pub fn type_as_timestamp(&self) -> Option<Timestamp<'a>> {
1343 if self.type_type() == Type::Timestamp {
1344 let u = self.type_();
1345 Some(unsafe { Timestamp::init_from_table(u) })
1349 } else {
1350 None
1351 }
1352 }
1353
1354 #[inline]
1355 #[allow(non_snake_case)]
1356 pub fn type_as_interval(&self) -> Option<Interval<'a>> {
1357 if self.type_type() == Type::Interval {
1358 let u = self.type_();
1359 Some(unsafe { Interval::init_from_table(u) })
1363 } else {
1364 None
1365 }
1366 }
1367
1368 #[inline]
1369 #[allow(non_snake_case)]
1370 pub fn type_as_list(&self) -> Option<List<'a>> {
1371 if self.type_type() == Type::List {
1372 let u = self.type_();
1373 Some(unsafe { List::init_from_table(u) })
1377 } else {
1378 None
1379 }
1380 }
1381
1382 #[inline]
1383 #[allow(non_snake_case)]
1384 pub fn type_as_struct_(&self) -> Option<Struct_<'a>> {
1385 if self.type_type() == Type::Struct_ {
1386 let u = self.type_();
1387 Some(unsafe { Struct_::init_from_table(u) })
1391 } else {
1392 None
1393 }
1394 }
1395
1396 #[inline]
1397 #[allow(non_snake_case)]
1398 pub fn type_as_union(&self) -> Option<Union<'a>> {
1399 if self.type_type() == Type::Union {
1400 let u = self.type_();
1401 Some(unsafe { Union::init_from_table(u) })
1405 } else {
1406 None
1407 }
1408 }
1409
1410 #[inline]
1411 #[allow(non_snake_case)]
1412 pub fn type_as_fixed_size_binary(&self) -> Option<FixedSizeBinary<'a>> {
1413 if self.type_type() == Type::FixedSizeBinary {
1414 let u = self.type_();
1415 Some(unsafe { FixedSizeBinary::init_from_table(u) })
1419 } else {
1420 None
1421 }
1422 }
1423
1424 #[inline]
1425 #[allow(non_snake_case)]
1426 pub fn type_as_fixed_size_list(&self) -> Option<FixedSizeList<'a>> {
1427 if self.type_type() == Type::FixedSizeList {
1428 let u = self.type_();
1429 Some(unsafe { FixedSizeList::init_from_table(u) })
1433 } else {
1434 None
1435 }
1436 }
1437
1438 #[inline]
1439 #[allow(non_snake_case)]
1440 pub fn type_as_map(&self) -> Option<Map<'a>> {
1441 if self.type_type() == Type::Map {
1442 let u = self.type_();
1443 Some(unsafe { Map::init_from_table(u) })
1447 } else {
1448 None
1449 }
1450 }
1451
1452 #[inline]
1453 #[allow(non_snake_case)]
1454 pub fn type_as_duration(&self) -> Option<Duration<'a>> {
1455 if self.type_type() == Type::Duration {
1456 let u = self.type_();
1457 Some(unsafe { Duration::init_from_table(u) })
1461 } else {
1462 None
1463 }
1464 }
1465
1466 #[inline]
1467 #[allow(non_snake_case)]
1468 pub fn type_as_large_binary(&self) -> Option<LargeBinary<'a>> {
1469 if self.type_type() == Type::LargeBinary {
1470 let u = self.type_();
1471 Some(unsafe { LargeBinary::init_from_table(u) })
1475 } else {
1476 None
1477 }
1478 }
1479
1480 #[inline]
1481 #[allow(non_snake_case)]
1482 pub fn type_as_large_utf_8(&self) -> Option<LargeUtf8<'a>> {
1483 if self.type_type() == Type::LargeUtf8 {
1484 let u = self.type_();
1485 Some(unsafe { LargeUtf8::init_from_table(u) })
1489 } else {
1490 None
1491 }
1492 }
1493
1494 #[inline]
1495 #[allow(non_snake_case)]
1496 pub fn type_as_large_list(&self) -> Option<LargeList<'a>> {
1497 if self.type_type() == Type::LargeList {
1498 let u = self.type_();
1499 Some(unsafe { LargeList::init_from_table(u) })
1503 } else {
1504 None
1505 }
1506 }
1507
1508 #[inline]
1509 #[allow(non_snake_case)]
1510 pub fn type_as_run_end_encoded(&self) -> Option<RunEndEncoded<'a>> {
1511 if self.type_type() == Type::RunEndEncoded {
1512 let u = self.type_();
1513 Some(unsafe { RunEndEncoded::init_from_table(u) })
1517 } else {
1518 None
1519 }
1520 }
1521
1522 #[inline]
1523 #[allow(non_snake_case)]
1524 pub fn type_as_binary_view(&self) -> Option<BinaryView<'a>> {
1525 if self.type_type() == Type::BinaryView {
1526 let u = self.type_();
1527 Some(unsafe { BinaryView::init_from_table(u) })
1531 } else {
1532 None
1533 }
1534 }
1535
1536 #[inline]
1537 #[allow(non_snake_case)]
1538 pub fn type_as_utf_8_view(&self) -> Option<Utf8View<'a>> {
1539 if self.type_type() == Type::Utf8View {
1540 let u = self.type_();
1541 Some(unsafe { Utf8View::init_from_table(u) })
1545 } else {
1546 None
1547 }
1548 }
1549
1550 #[inline]
1551 #[allow(non_snake_case)]
1552 pub fn type_as_list_view(&self) -> Option<ListView<'a>> {
1553 if self.type_type() == Type::ListView {
1554 let u = self.type_();
1555 Some(unsafe { ListView::init_from_table(u) })
1559 } else {
1560 None
1561 }
1562 }
1563
1564 #[inline]
1565 #[allow(non_snake_case)]
1566 pub fn type_as_large_list_view(&self) -> Option<LargeListView<'a>> {
1567 if self.type_type() == Type::LargeListView {
1568 let u = self.type_();
1569 Some(unsafe { LargeListView::init_from_table(u) })
1573 } else {
1574 None
1575 }
1576 }
1577
1578 #[inline]
1579 #[allow(non_snake_case)]
1580 pub fn sparseIndex_as_sparse_tensor_index_coo(&self) -> Option<SparseTensorIndexCOO<'a>> {
1581 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCOO {
1582 let u = self.sparseIndex();
1583 Some(unsafe { SparseTensorIndexCOO::init_from_table(u) })
1587 } else {
1588 None
1589 }
1590 }
1591
1592 #[inline]
1593 #[allow(non_snake_case)]
1594 pub fn sparseIndex_as_sparse_matrix_index_csx(&self) -> Option<SparseMatrixIndexCSX<'a>> {
1595 if self.sparseIndex_type() == SparseTensorIndex::SparseMatrixIndexCSX {
1596 let u = self.sparseIndex();
1597 Some(unsafe { SparseMatrixIndexCSX::init_from_table(u) })
1601 } else {
1602 None
1603 }
1604 }
1605
1606 #[inline]
1607 #[allow(non_snake_case)]
1608 pub fn sparseIndex_as_sparse_tensor_index_csf(&self) -> Option<SparseTensorIndexCSF<'a>> {
1609 if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCSF {
1610 let u = self.sparseIndex();
1611 Some(unsafe { SparseTensorIndexCSF::init_from_table(u) })
1615 } else {
1616 None
1617 }
1618 }
1619}
1620
1621impl flatbuffers::Verifiable for SparseTensor<'_> {
1622 #[inline]
1623 fn run_verifier(
1624 v: &mut flatbuffers::Verifier,
1625 pos: usize,
1626 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
1627 use flatbuffers::Verifiable;
1628 v.visit_table(pos)?
1629 .visit_union::<Type, _>(
1630 "type_type",
1631 Self::VT_TYPE_TYPE,
1632 "type_",
1633 Self::VT_TYPE_,
1634 true,
1635 |key, v, pos| match key {
1636 Type::Null => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>(
1637 "Type::Null",
1638 pos,
1639 ),
1640 Type::Int => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>(
1641 "Type::Int",
1642 pos,
1643 ),
1644 Type::FloatingPoint => v
1645 .verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>(
1646 "Type::FloatingPoint",
1647 pos,
1648 ),
1649 Type::Binary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>(
1650 "Type::Binary",
1651 pos,
1652 ),
1653 Type::Utf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>(
1654 "Type::Utf8",
1655 pos,
1656 ),
1657 Type::Bool => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>(
1658 "Type::Bool",
1659 pos,
1660 ),
1661 Type::Decimal => v
1662 .verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>(
1663 "Type::Decimal",
1664 pos,
1665 ),
1666 Type::Date => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>(
1667 "Type::Date",
1668 pos,
1669 ),
1670 Type::Time => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>(
1671 "Type::Time",
1672 pos,
1673 ),
1674 Type::Timestamp => v
1675 .verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>(
1676 "Type::Timestamp",
1677 pos,
1678 ),
1679 Type::Interval => v
1680 .verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>(
1681 "Type::Interval",
1682 pos,
1683 ),
1684 Type::List => v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>(
1685 "Type::List",
1686 pos,
1687 ),
1688 Type::Struct_ => v
1689 .verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>(
1690 "Type::Struct_",
1691 pos,
1692 ),
1693 Type::Union => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>(
1694 "Type::Union",
1695 pos,
1696 ),
1697 Type::FixedSizeBinary => v
1698 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>(
1699 "Type::FixedSizeBinary",
1700 pos,
1701 ),
1702 Type::FixedSizeList => v
1703 .verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>(
1704 "Type::FixedSizeList",
1705 pos,
1706 ),
1707 Type::Map => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>(
1708 "Type::Map",
1709 pos,
1710 ),
1711 Type::Duration => v
1712 .verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>(
1713 "Type::Duration",
1714 pos,
1715 ),
1716 Type::LargeBinary => v
1717 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>(
1718 "Type::LargeBinary",
1719 pos,
1720 ),
1721 Type::LargeUtf8 => v
1722 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>(
1723 "Type::LargeUtf8",
1724 pos,
1725 ),
1726 Type::LargeList => v
1727 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>(
1728 "Type::LargeList",
1729 pos,
1730 ),
1731 Type::RunEndEncoded => v
1732 .verify_union_variant::<flatbuffers::ForwardsUOffset<RunEndEncoded>>(
1733 "Type::RunEndEncoded",
1734 pos,
1735 ),
1736 Type::BinaryView => v
1737 .verify_union_variant::<flatbuffers::ForwardsUOffset<BinaryView>>(
1738 "Type::BinaryView",
1739 pos,
1740 ),
1741 Type::Utf8View => v
1742 .verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8View>>(
1743 "Type::Utf8View",
1744 pos,
1745 ),
1746 Type::ListView => v
1747 .verify_union_variant::<flatbuffers::ForwardsUOffset<ListView>>(
1748 "Type::ListView",
1749 pos,
1750 ),
1751 Type::LargeListView => v
1752 .verify_union_variant::<flatbuffers::ForwardsUOffset<LargeListView>>(
1753 "Type::LargeListView",
1754 pos,
1755 ),
1756 _ => Ok(()),
1757 },
1758 )?
1759 .visit_field::<flatbuffers::ForwardsUOffset<
1760 flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<TensorDim>>,
1761 >>("shape", Self::VT_SHAPE, true)?
1762 .visit_field::<i64>("non_zero_length", Self::VT_NON_ZERO_LENGTH, false)?
1763 .visit_union::<SparseTensorIndex, _>(
1764 "sparseIndex_type",
1765 Self::VT_SPARSEINDEX_TYPE,
1766 "sparseIndex",
1767 Self::VT_SPARSEINDEX,
1768 true,
1769 |key, v, pos| match key {
1770 SparseTensorIndex::SparseTensorIndexCOO => v
1771 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCOO>>(
1772 "SparseTensorIndex::SparseTensorIndexCOO",
1773 pos,
1774 ),
1775 SparseTensorIndex::SparseMatrixIndexCSX => v
1776 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseMatrixIndexCSX>>(
1777 "SparseTensorIndex::SparseMatrixIndexCSX",
1778 pos,
1779 ),
1780 SparseTensorIndex::SparseTensorIndexCSF => v
1781 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCSF>>(
1782 "SparseTensorIndex::SparseTensorIndexCSF",
1783 pos,
1784 ),
1785 _ => Ok(()),
1786 },
1787 )?
1788 .visit_field::<Buffer>("data", Self::VT_DATA, true)?
1789 .finish();
1790 Ok(())
1791 }
1792}
1793pub struct SparseTensorArgs<'a> {
1794 pub type_type: Type,
1795 pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1796 pub shape: Option<
1797 flatbuffers::WIPOffset<
1798 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
1799 >,
1800 >,
1801 pub non_zero_length: i64,
1802 pub sparseIndex_type: SparseTensorIndex,
1803 pub sparseIndex: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1804 pub data: Option<&'a Buffer>,
1805}
1806impl<'a> Default for SparseTensorArgs<'a> {
1807 #[inline]
1808 fn default() -> Self {
1809 SparseTensorArgs {
1810 type_type: Type::NONE,
1811 type_: None, shape: None, non_zero_length: 0,
1814 sparseIndex_type: SparseTensorIndex::NONE,
1815 sparseIndex: None, data: None, }
1818 }
1819}
1820
1821pub struct SparseTensorBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
1822 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1823 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
1824}
1825impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SparseTensorBuilder<'a, 'b, A> {
1826 #[inline]
1827 pub fn add_type_type(&mut self, type_type: Type) {
1828 self.fbb_
1829 .push_slot::<Type>(SparseTensor::VT_TYPE_TYPE, type_type, Type::NONE);
1830 }
1831 #[inline]
1832 pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
1833 self.fbb_
1834 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_TYPE_, type_);
1835 }
1836 #[inline]
1837 pub fn add_shape(
1838 &mut self,
1839 shape: flatbuffers::WIPOffset<
1840 flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<TensorDim<'b>>>,
1841 >,
1842 ) {
1843 self.fbb_
1844 .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_SHAPE, shape);
1845 }
1846 #[inline]
1847 pub fn add_non_zero_length(&mut self, non_zero_length: i64) {
1848 self.fbb_
1849 .push_slot::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, non_zero_length, 0);
1850 }
1851 #[inline]
1852 pub fn add_sparseIndex_type(&mut self, sparseIndex_type: SparseTensorIndex) {
1853 self.fbb_.push_slot::<SparseTensorIndex>(
1854 SparseTensor::VT_SPARSEINDEX_TYPE,
1855 sparseIndex_type,
1856 SparseTensorIndex::NONE,
1857 );
1858 }
1859 #[inline]
1860 pub fn add_sparseIndex(
1861 &mut self,
1862 sparseIndex: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
1863 ) {
1864 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1865 SparseTensor::VT_SPARSEINDEX,
1866 sparseIndex,
1867 );
1868 }
1869 #[inline]
1870 pub fn add_data(&mut self, data: &Buffer) {
1871 self.fbb_
1872 .push_slot_always::<&Buffer>(SparseTensor::VT_DATA, data);
1873 }
1874 #[inline]
1875 pub fn new(
1876 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
1877 ) -> SparseTensorBuilder<'a, 'b, A> {
1878 let start = _fbb.start_table();
1879 SparseTensorBuilder {
1880 fbb_: _fbb,
1881 start_: start,
1882 }
1883 }
1884 #[inline]
1885 pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensor<'a>> {
1886 let o = self.fbb_.end_table(self.start_);
1887 self.fbb_.required(o, SparseTensor::VT_TYPE_, "type_");
1888 self.fbb_.required(o, SparseTensor::VT_SHAPE, "shape");
1889 self.fbb_
1890 .required(o, SparseTensor::VT_SPARSEINDEX, "sparseIndex");
1891 self.fbb_.required(o, SparseTensor::VT_DATA, "data");
1892 flatbuffers::WIPOffset::new(o.value())
1893 }
1894}
1895
1896impl core::fmt::Debug for SparseTensor<'_> {
1897 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1898 let mut ds = f.debug_struct("SparseTensor");
1899 ds.field("type_type", &self.type_type());
1900 match self.type_type() {
1901 Type::Null => {
1902 if let Some(x) = self.type_as_null() {
1903 ds.field("type_", &x)
1904 } else {
1905 ds.field(
1906 "type_",
1907 &"InvalidFlatbuffer: Union discriminant does not match value.",
1908 )
1909 }
1910 }
1911 Type::Int => {
1912 if let Some(x) = self.type_as_int() {
1913 ds.field("type_", &x)
1914 } else {
1915 ds.field(
1916 "type_",
1917 &"InvalidFlatbuffer: Union discriminant does not match value.",
1918 )
1919 }
1920 }
1921 Type::FloatingPoint => {
1922 if let Some(x) = self.type_as_floating_point() {
1923 ds.field("type_", &x)
1924 } else {
1925 ds.field(
1926 "type_",
1927 &"InvalidFlatbuffer: Union discriminant does not match value.",
1928 )
1929 }
1930 }
1931 Type::Binary => {
1932 if let Some(x) = self.type_as_binary() {
1933 ds.field("type_", &x)
1934 } else {
1935 ds.field(
1936 "type_",
1937 &"InvalidFlatbuffer: Union discriminant does not match value.",
1938 )
1939 }
1940 }
1941 Type::Utf8 => {
1942 if let Some(x) = self.type_as_utf_8() {
1943 ds.field("type_", &x)
1944 } else {
1945 ds.field(
1946 "type_",
1947 &"InvalidFlatbuffer: Union discriminant does not match value.",
1948 )
1949 }
1950 }
1951 Type::Bool => {
1952 if let Some(x) = self.type_as_bool() {
1953 ds.field("type_", &x)
1954 } else {
1955 ds.field(
1956 "type_",
1957 &"InvalidFlatbuffer: Union discriminant does not match value.",
1958 )
1959 }
1960 }
1961 Type::Decimal => {
1962 if let Some(x) = self.type_as_decimal() {
1963 ds.field("type_", &x)
1964 } else {
1965 ds.field(
1966 "type_",
1967 &"InvalidFlatbuffer: Union discriminant does not match value.",
1968 )
1969 }
1970 }
1971 Type::Date => {
1972 if let Some(x) = self.type_as_date() {
1973 ds.field("type_", &x)
1974 } else {
1975 ds.field(
1976 "type_",
1977 &"InvalidFlatbuffer: Union discriminant does not match value.",
1978 )
1979 }
1980 }
1981 Type::Time => {
1982 if let Some(x) = self.type_as_time() {
1983 ds.field("type_", &x)
1984 } else {
1985 ds.field(
1986 "type_",
1987 &"InvalidFlatbuffer: Union discriminant does not match value.",
1988 )
1989 }
1990 }
1991 Type::Timestamp => {
1992 if let Some(x) = self.type_as_timestamp() {
1993 ds.field("type_", &x)
1994 } else {
1995 ds.field(
1996 "type_",
1997 &"InvalidFlatbuffer: Union discriminant does not match value.",
1998 )
1999 }
2000 }
2001 Type::Interval => {
2002 if let Some(x) = self.type_as_interval() {
2003 ds.field("type_", &x)
2004 } else {
2005 ds.field(
2006 "type_",
2007 &"InvalidFlatbuffer: Union discriminant does not match value.",
2008 )
2009 }
2010 }
2011 Type::List => {
2012 if let Some(x) = self.type_as_list() {
2013 ds.field("type_", &x)
2014 } else {
2015 ds.field(
2016 "type_",
2017 &"InvalidFlatbuffer: Union discriminant does not match value.",
2018 )
2019 }
2020 }
2021 Type::Struct_ => {
2022 if let Some(x) = self.type_as_struct_() {
2023 ds.field("type_", &x)
2024 } else {
2025 ds.field(
2026 "type_",
2027 &"InvalidFlatbuffer: Union discriminant does not match value.",
2028 )
2029 }
2030 }
2031 Type::Union => {
2032 if let Some(x) = self.type_as_union() {
2033 ds.field("type_", &x)
2034 } else {
2035 ds.field(
2036 "type_",
2037 &"InvalidFlatbuffer: Union discriminant does not match value.",
2038 )
2039 }
2040 }
2041 Type::FixedSizeBinary => {
2042 if let Some(x) = self.type_as_fixed_size_binary() {
2043 ds.field("type_", &x)
2044 } else {
2045 ds.field(
2046 "type_",
2047 &"InvalidFlatbuffer: Union discriminant does not match value.",
2048 )
2049 }
2050 }
2051 Type::FixedSizeList => {
2052 if let Some(x) = self.type_as_fixed_size_list() {
2053 ds.field("type_", &x)
2054 } else {
2055 ds.field(
2056 "type_",
2057 &"InvalidFlatbuffer: Union discriminant does not match value.",
2058 )
2059 }
2060 }
2061 Type::Map => {
2062 if let Some(x) = self.type_as_map() {
2063 ds.field("type_", &x)
2064 } else {
2065 ds.field(
2066 "type_",
2067 &"InvalidFlatbuffer: Union discriminant does not match value.",
2068 )
2069 }
2070 }
2071 Type::Duration => {
2072 if let Some(x) = self.type_as_duration() {
2073 ds.field("type_", &x)
2074 } else {
2075 ds.field(
2076 "type_",
2077 &"InvalidFlatbuffer: Union discriminant does not match value.",
2078 )
2079 }
2080 }
2081 Type::LargeBinary => {
2082 if let Some(x) = self.type_as_large_binary() {
2083 ds.field("type_", &x)
2084 } else {
2085 ds.field(
2086 "type_",
2087 &"InvalidFlatbuffer: Union discriminant does not match value.",
2088 )
2089 }
2090 }
2091 Type::LargeUtf8 => {
2092 if let Some(x) = self.type_as_large_utf_8() {
2093 ds.field("type_", &x)
2094 } else {
2095 ds.field(
2096 "type_",
2097 &"InvalidFlatbuffer: Union discriminant does not match value.",
2098 )
2099 }
2100 }
2101 Type::LargeList => {
2102 if let Some(x) = self.type_as_large_list() {
2103 ds.field("type_", &x)
2104 } else {
2105 ds.field(
2106 "type_",
2107 &"InvalidFlatbuffer: Union discriminant does not match value.",
2108 )
2109 }
2110 }
2111 Type::RunEndEncoded => {
2112 if let Some(x) = self.type_as_run_end_encoded() {
2113 ds.field("type_", &x)
2114 } else {
2115 ds.field(
2116 "type_",
2117 &"InvalidFlatbuffer: Union discriminant does not match value.",
2118 )
2119 }
2120 }
2121 Type::BinaryView => {
2122 if let Some(x) = self.type_as_binary_view() {
2123 ds.field("type_", &x)
2124 } else {
2125 ds.field(
2126 "type_",
2127 &"InvalidFlatbuffer: Union discriminant does not match value.",
2128 )
2129 }
2130 }
2131 Type::Utf8View => {
2132 if let Some(x) = self.type_as_utf_8_view() {
2133 ds.field("type_", &x)
2134 } else {
2135 ds.field(
2136 "type_",
2137 &"InvalidFlatbuffer: Union discriminant does not match value.",
2138 )
2139 }
2140 }
2141 Type::ListView => {
2142 if let Some(x) = self.type_as_list_view() {
2143 ds.field("type_", &x)
2144 } else {
2145 ds.field(
2146 "type_",
2147 &"InvalidFlatbuffer: Union discriminant does not match value.",
2148 )
2149 }
2150 }
2151 Type::LargeListView => {
2152 if let Some(x) = self.type_as_large_list_view() {
2153 ds.field("type_", &x)
2154 } else {
2155 ds.field(
2156 "type_",
2157 &"InvalidFlatbuffer: Union discriminant does not match value.",
2158 )
2159 }
2160 }
2161 _ => {
2162 let x: Option<()> = None;
2163 ds.field("type_", &x)
2164 }
2165 };
2166 ds.field("shape", &self.shape());
2167 ds.field("non_zero_length", &self.non_zero_length());
2168 ds.field("sparseIndex_type", &self.sparseIndex_type());
2169 match self.sparseIndex_type() {
2170 SparseTensorIndex::SparseTensorIndexCOO => {
2171 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_coo() {
2172 ds.field("sparseIndex", &x)
2173 } else {
2174 ds.field(
2175 "sparseIndex",
2176 &"InvalidFlatbuffer: Union discriminant does not match value.",
2177 )
2178 }
2179 }
2180 SparseTensorIndex::SparseMatrixIndexCSX => {
2181 if let Some(x) = self.sparseIndex_as_sparse_matrix_index_csx() {
2182 ds.field("sparseIndex", &x)
2183 } else {
2184 ds.field(
2185 "sparseIndex",
2186 &"InvalidFlatbuffer: Union discriminant does not match value.",
2187 )
2188 }
2189 }
2190 SparseTensorIndex::SparseTensorIndexCSF => {
2191 if let Some(x) = self.sparseIndex_as_sparse_tensor_index_csf() {
2192 ds.field("sparseIndex", &x)
2193 } else {
2194 ds.field(
2195 "sparseIndex",
2196 &"InvalidFlatbuffer: Union discriminant does not match value.",
2197 )
2198 }
2199 }
2200 _ => {
2201 let x: Option<()> = None;
2202 ds.field("sparseIndex", &x)
2203 }
2204 };
2205 ds.field("data", &self.data());
2206 ds.finish()
2207 }
2208}
2209#[inline]
2210pub fn root_as_sparse_tensor(buf: &[u8]) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2217 flatbuffers::root::<SparseTensor>(buf)
2218}
2219#[inline]
2220pub fn size_prefixed_root_as_sparse_tensor(
2227 buf: &[u8],
2228) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
2229 flatbuffers::size_prefixed_root::<SparseTensor>(buf)
2230}
2231#[inline]
2232pub fn root_as_sparse_tensor_with_opts<'b, 'o>(
2239 opts: &'o flatbuffers::VerifierOptions,
2240 buf: &'b [u8],
2241) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
2242 flatbuffers::root_with_opts::<SparseTensor<'b>>(opts, buf)
2243}
2244#[inline]
2245pub fn size_prefixed_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::size_prefixed_root_with_opts::<SparseTensor<'b>>(opts, buf)
2256}
2257#[inline]
2258pub unsafe fn root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2262 unsafe { flatbuffers::root_unchecked::<SparseTensor>(buf) }
2263}
2264#[inline]
2265pub unsafe fn size_prefixed_root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
2269 unsafe { flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf) }
2270}
2271#[inline]
2272pub fn finish_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
2273 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
2274 root: flatbuffers::WIPOffset<SparseTensor<'a>>,
2275) {
2276 fbb.finish(root, None);
2277}
2278
2279#[inline]
2280pub fn finish_size_prefixed_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_size_prefixed(root, None);
2285}