1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

#![allow(dead_code)]
#![allow(unused_imports)]

use crate::ipc::gen::Schema::*;
use crate::ipc::gen::Tensor::*;
use flatbuffers::EndianScalar;
use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify

#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MIN_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 0;
#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MAX_SPARSE_MATRIX_COMPRESSED_AXIS: i16 = 1;
#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_SPARSE_MATRIX_COMPRESSED_AXIS: [SparseMatrixCompressedAxis; 2] = [
    SparseMatrixCompressedAxis::Row,
    SparseMatrixCompressedAxis::Column,
];

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SparseMatrixCompressedAxis(pub i16);
#[allow(non_upper_case_globals)]
impl SparseMatrixCompressedAxis {
    pub const Row: Self = Self(0);
    pub const Column: Self = Self(1);

    pub const ENUM_MIN: i16 = 0;
    pub const ENUM_MAX: i16 = 1;
    pub const ENUM_VALUES: &'static [Self] = &[Self::Row, Self::Column];
    /// Returns the variant's name or "" if unknown.
    pub fn variant_name(self) -> Option<&'static str> {
        match self {
            Self::Row => Some("Row"),
            Self::Column => Some("Column"),
            _ => None,
        }
    }
}
impl std::fmt::Debug for SparseMatrixCompressedAxis {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        if let Some(name) = self.variant_name() {
            f.write_str(name)
        } else {
            f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
        }
    }
}
impl<'a> flatbuffers::Follow<'a> for SparseMatrixCompressedAxis {
    type Inner = Self;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
        Self(b)
    }
}

impl flatbuffers::Push for SparseMatrixCompressedAxis {
    type Output = SparseMatrixCompressedAxis;
    #[inline]
    fn push(&self, dst: &mut [u8], _rest: &[u8]) {
        unsafe { flatbuffers::emplace_scalar::<i16>(dst, self.0) };
    }
}

impl flatbuffers::EndianScalar for SparseMatrixCompressedAxis {
    #[inline]
    fn to_little_endian(self) -> Self {
        let b = i16::to_le(self.0);
        Self(b)
    }
    #[inline]
    fn from_little_endian(self) -> Self {
        let b = i16::from_le(self.0);
        Self(b)
    }
}

impl<'a> flatbuffers::Verifiable for SparseMatrixCompressedAxis {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        i16::run_verifier(v, pos)
    }
}

impl flatbuffers::SimpleToVerifyInSlice for SparseMatrixCompressedAxis {}
#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MIN_SPARSE_TENSOR_INDEX: u8 = 0;
#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MAX_SPARSE_TENSOR_INDEX: u8 = 3;
#[deprecated(
    since = "2.0.0",
    note = "Use associated constants instead. This will no longer be generated in 2021."
)]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_SPARSE_TENSOR_INDEX: [SparseTensorIndex; 4] = [
    SparseTensorIndex::NONE,
    SparseTensorIndex::SparseTensorIndexCOO,
    SparseTensorIndex::SparseMatrixIndexCSX,
    SparseTensorIndex::SparseTensorIndexCSF,
];

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SparseTensorIndex(pub u8);
#[allow(non_upper_case_globals)]
impl SparseTensorIndex {
    pub const NONE: Self = Self(0);
    pub const SparseTensorIndexCOO: Self = Self(1);
    pub const SparseMatrixIndexCSX: Self = Self(2);
    pub const SparseTensorIndexCSF: Self = Self(3);

    pub const ENUM_MIN: u8 = 0;
    pub const ENUM_MAX: u8 = 3;
    pub const ENUM_VALUES: &'static [Self] = &[
        Self::NONE,
        Self::SparseTensorIndexCOO,
        Self::SparseMatrixIndexCSX,
        Self::SparseTensorIndexCSF,
    ];
    /// Returns the variant's name or "" if unknown.
    pub fn variant_name(self) -> Option<&'static str> {
        match self {
            Self::NONE => Some("NONE"),
            Self::SparseTensorIndexCOO => Some("SparseTensorIndexCOO"),
            Self::SparseMatrixIndexCSX => Some("SparseMatrixIndexCSX"),
            Self::SparseTensorIndexCSF => Some("SparseTensorIndexCSF"),
            _ => None,
        }
    }
}
impl std::fmt::Debug for SparseTensorIndex {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        if let Some(name) = self.variant_name() {
            f.write_str(name)
        } else {
            f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
        }
    }
}
pub struct SparseTensorIndexUnionTableOffset {}
impl<'a> flatbuffers::Follow<'a> for SparseTensorIndex {
    type Inner = Self;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
        Self(b)
    }
}

impl flatbuffers::Push for SparseTensorIndex {
    type Output = SparseTensorIndex;
    #[inline]
    fn push(&self, dst: &mut [u8], _rest: &[u8]) {
        unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0) };
    }
}

impl flatbuffers::EndianScalar for SparseTensorIndex {
    #[inline]
    fn to_little_endian(self) -> Self {
        let b = u8::to_le(self.0);
        Self(b)
    }
    #[inline]
    fn from_little_endian(self) -> Self {
        let b = u8::from_le(self.0);
        Self(b)
    }
}

impl<'a> flatbuffers::Verifiable for SparseTensorIndex {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        u8::run_verifier(v, pos)
    }
}

impl flatbuffers::SimpleToVerifyInSlice for SparseTensorIndex {}
pub enum SparseTensorIndexCOOOffset {}
#[derive(Copy, Clone, PartialEq)]

/// ----------------------------------------------------------------------
/// EXPERIMENTAL: Data structures for sparse tensors
/// Coordinate (COO) format of sparse tensor index.
///
/// COO's index list are represented as a NxM matrix,
/// where N is the number of non-zero values,
/// and M is the number of dimensions of a sparse tensor.
///
/// indicesBuffer stores the location and size of the data of this indices
/// matrix.  The value type and the stride of the indices matrix is
/// specified in indicesType and indicesStrides fields.
///
/// For example, let X be a 2x3x4x5 tensor, and it has the following
/// 6 non-zero values:
/// ```text
///   X[0, 1, 2, 0] := 1
///   X[1, 1, 2, 3] := 2
///   X[0, 2, 1, 0] := 3
///   X[0, 1, 3, 0] := 4
///   X[0, 1, 2, 1] := 5
///   X[1, 2, 0, 4] := 6
/// ```
/// In COO format, the index matrix of X is the following 4x6 matrix:
/// ```text
///   [[0, 0, 0, 0, 1, 1],
///    [1, 1, 1, 2, 1, 2],
///    [2, 2, 3, 1, 2, 0],
///    [0, 1, 0, 0, 3, 4]]
/// ```
/// When isCanonical is true, the indices is sorted in lexicographical order
/// (row-major order), and it does not have duplicated entries.  Otherwise,
/// the indices may not be sorted, or may have duplicated entries.
pub struct SparseTensorIndexCOO<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCOO<'a> {
    type Inner = SparseTensorIndexCOO<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> SparseTensorIndexCOO<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        SparseTensorIndexCOO { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args SparseTensorIndexCOOArgs<'args>,
    ) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'bldr>> {
        let mut builder = SparseTensorIndexCOOBuilder::new(_fbb);
        if let Some(x) = args.indicesBuffer {
            builder.add_indicesBuffer(x);
        }
        if let Some(x) = args.indicesStrides {
            builder.add_indicesStrides(x);
        }
        if let Some(x) = args.indicesType {
            builder.add_indicesType(x);
        }
        builder.add_isCanonical(args.isCanonical);
        builder.finish()
    }

    pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 4;
    pub const VT_INDICESSTRIDES: flatbuffers::VOffsetT = 6;
    pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 8;
    pub const VT_ISCANONICAL: flatbuffers::VOffsetT = 10;

    /// The type of values in indicesBuffer
    #[inline]
    pub fn indicesType(&self) -> Int<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<Int>>(
                SparseTensorIndexCOO::VT_INDICESTYPE,
                None,
            )
            .unwrap()
    }
    /// Non-negative byte offsets to advance one value cell along each dimension
    /// If omitted, default to row-major order (C-like).
    #[inline]
    pub fn indicesStrides(&self) -> Option<flatbuffers::Vector<'a, i64>> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i64>>>(
                SparseTensorIndexCOO::VT_INDICESSTRIDES,
                None,
            )
    }
    /// The location and size of the indices matrix's data
    #[inline]
    pub fn indicesBuffer(&self) -> &'a Buffer {
        self._tab
            .get::<Buffer>(SparseTensorIndexCOO::VT_INDICESBUFFER, None)
            .unwrap()
    }
    /// This flag is true if and only if the indices matrix is sorted in
    /// row-major order, and does not have duplicated entries.
    /// This sort order is the same as of Tensorflow's SparseTensor,
    /// but it is inverse order of SciPy's canonical coo_matrix
    /// (SciPy employs column-major order for its coo_matrix).
    #[inline]
    pub fn isCanonical(&self) -> bool {
        self._tab
            .get::<bool>(SparseTensorIndexCOO::VT_ISCANONICAL, Some(false))
            .unwrap()
    }
}

impl flatbuffers::Verifiable for SparseTensorIndexCOO<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
                &"indicesType",
                Self::VT_INDICESTYPE,
                true,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
                &"indicesStrides",
                Self::VT_INDICESSTRIDES,
                false,
            )?
            .visit_field::<Buffer>(&"indicesBuffer", Self::VT_INDICESBUFFER, true)?
            .visit_field::<bool>(&"isCanonical", Self::VT_ISCANONICAL, false)?
            .finish();
        Ok(())
    }
}
pub struct SparseTensorIndexCOOArgs<'a> {
    pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
    pub indicesStrides: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
    pub indicesBuffer: Option<&'a Buffer>,
    pub isCanonical: bool,
}
impl<'a> Default for SparseTensorIndexCOOArgs<'a> {
    #[inline]
    fn default() -> Self {
        SparseTensorIndexCOOArgs {
            indicesType: None, // required field
            indicesStrides: None,
            indicesBuffer: None, // required field
            isCanonical: false,
        }
    }
}
pub struct SparseTensorIndexCOOBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> SparseTensorIndexCOOBuilder<'a, 'b> {
    #[inline]
    pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
            SparseTensorIndexCOO::VT_INDICESTYPE,
            indicesType,
        );
    }
    #[inline]
    pub fn add_indicesStrides(
        &mut self,
        indicesStrides: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i64>>,
    ) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
            SparseTensorIndexCOO::VT_INDICESSTRIDES,
            indicesStrides,
        );
    }
    #[inline]
    pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
        self.fbb_.push_slot_always::<&Buffer>(
            SparseTensorIndexCOO::VT_INDICESBUFFER,
            indicesBuffer,
        );
    }
    #[inline]
    pub fn add_isCanonical(&mut self, isCanonical: bool) {
        self.fbb_.push_slot::<bool>(
            SparseTensorIndexCOO::VT_ISCANONICAL,
            isCanonical,
            false,
        );
    }
    #[inline]
    pub fn new(
        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    ) -> SparseTensorIndexCOOBuilder<'a, 'b> {
        let start = _fbb.start_table();
        SparseTensorIndexCOOBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCOO<'a>> {
        let o = self.fbb_.end_table(self.start_);
        self.fbb_
            .required(o, SparseTensorIndexCOO::VT_INDICESTYPE, "indicesType");
        self.fbb_
            .required(o, SparseTensorIndexCOO::VT_INDICESBUFFER, "indicesBuffer");
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for SparseTensorIndexCOO<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("SparseTensorIndexCOO");
        ds.field("indicesType", &self.indicesType());
        ds.field("indicesStrides", &self.indicesStrides());
        ds.field("indicesBuffer", &self.indicesBuffer());
        ds.field("isCanonical", &self.isCanonical());
        ds.finish()
    }
}
pub enum SparseMatrixIndexCSXOffset {}
#[derive(Copy, Clone, PartialEq)]

/// Compressed Sparse format, that is matrix-specific.
pub struct SparseMatrixIndexCSX<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for SparseMatrixIndexCSX<'a> {
    type Inner = SparseMatrixIndexCSX<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> SparseMatrixIndexCSX<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        SparseMatrixIndexCSX { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args SparseMatrixIndexCSXArgs<'args>,
    ) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'bldr>> {
        let mut builder = SparseMatrixIndexCSXBuilder::new(_fbb);
        if let Some(x) = args.indicesBuffer {
            builder.add_indicesBuffer(x);
        }
        if let Some(x) = args.indicesType {
            builder.add_indicesType(x);
        }
        if let Some(x) = args.indptrBuffer {
            builder.add_indptrBuffer(x);
        }
        if let Some(x) = args.indptrType {
            builder.add_indptrType(x);
        }
        builder.add_compressedAxis(args.compressedAxis);
        builder.finish()
    }

    pub const VT_COMPRESSEDAXIS: flatbuffers::VOffsetT = 4;
    pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 6;
    pub const VT_INDPTRBUFFER: flatbuffers::VOffsetT = 8;
    pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 10;
    pub const VT_INDICESBUFFER: flatbuffers::VOffsetT = 12;

    /// Which axis, row or column, is compressed
    #[inline]
    pub fn compressedAxis(&self) -> SparseMatrixCompressedAxis {
        self._tab
            .get::<SparseMatrixCompressedAxis>(
                SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
                Some(SparseMatrixCompressedAxis::Row),
            )
            .unwrap()
    }
    /// The type of values in indptrBuffer
    #[inline]
    pub fn indptrType(&self) -> Int<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<Int>>(
                SparseMatrixIndexCSX::VT_INDPTRTYPE,
                None,
            )
            .unwrap()
    }
    /// indptrBuffer stores the location and size of indptr array that
    /// represents the range of the rows.
    /// The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
    /// The length of this array is 1 + (the number of rows), and the type
    /// of index value is long.
    ///
    /// For example, let X be the following 6x4 matrix:
    /// ```text
    ///   X := [[0, 1, 2, 0],
    ///         [0, 0, 3, 0],
    ///         [0, 4, 0, 5],
    ///         [0, 0, 0, 0],
    ///         [6, 0, 7, 8],
    ///         [0, 9, 0, 0]].
    /// ```
    /// The array of non-zero values in X is:
    /// ```text
    ///   values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
    /// ```
    /// And the indptr of X is:
    /// ```text
    ///   indptr(X) = [0, 2, 3, 5, 5, 8, 10].
    /// ```
    #[inline]
    pub fn indptrBuffer(&self) -> &'a Buffer {
        self._tab
            .get::<Buffer>(SparseMatrixIndexCSX::VT_INDPTRBUFFER, None)
            .unwrap()
    }
    /// The type of values in indicesBuffer
    #[inline]
    pub fn indicesType(&self) -> Int<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<Int>>(
                SparseMatrixIndexCSX::VT_INDICESTYPE,
                None,
            )
            .unwrap()
    }
    /// indicesBuffer stores the location and size of the array that
    /// contains the column indices of the corresponding non-zero values.
    /// The type of index value is long.
    ///
    /// For example, the indices of the above X is:
    /// ```text
    ///   indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
    /// ```
    /// Note that the indices are sorted in lexicographical order for each row.
    #[inline]
    pub fn indicesBuffer(&self) -> &'a Buffer {
        self._tab
            .get::<Buffer>(SparseMatrixIndexCSX::VT_INDICESBUFFER, None)
            .unwrap()
    }
}

impl flatbuffers::Verifiable for SparseMatrixIndexCSX<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<SparseMatrixCompressedAxis>(
                &"compressedAxis",
                Self::VT_COMPRESSEDAXIS,
                false,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
                &"indptrType",
                Self::VT_INDPTRTYPE,
                true,
            )?
            .visit_field::<Buffer>(&"indptrBuffer", Self::VT_INDPTRBUFFER, true)?
            .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
                &"indicesType",
                Self::VT_INDICESTYPE,
                true,
            )?
            .visit_field::<Buffer>(&"indicesBuffer", Self::VT_INDICESBUFFER, true)?
            .finish();
        Ok(())
    }
}
pub struct SparseMatrixIndexCSXArgs<'a> {
    pub compressedAxis: SparseMatrixCompressedAxis,
    pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
    pub indptrBuffer: Option<&'a Buffer>,
    pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
    pub indicesBuffer: Option<&'a Buffer>,
}
impl<'a> Default for SparseMatrixIndexCSXArgs<'a> {
    #[inline]
    fn default() -> Self {
        SparseMatrixIndexCSXArgs {
            compressedAxis: SparseMatrixCompressedAxis::Row,
            indptrType: None,    // required field
            indptrBuffer: None,  // required field
            indicesType: None,   // required field
            indicesBuffer: None, // required field
        }
    }
}
pub struct SparseMatrixIndexCSXBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> SparseMatrixIndexCSXBuilder<'a, 'b> {
    #[inline]
    pub fn add_compressedAxis(&mut self, compressedAxis: SparseMatrixCompressedAxis) {
        self.fbb_.push_slot::<SparseMatrixCompressedAxis>(
            SparseMatrixIndexCSX::VT_COMPRESSEDAXIS,
            compressedAxis,
            SparseMatrixCompressedAxis::Row,
        );
    }
    #[inline]
    pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
            SparseMatrixIndexCSX::VT_INDPTRTYPE,
            indptrType,
        );
    }
    #[inline]
    pub fn add_indptrBuffer(&mut self, indptrBuffer: &Buffer) {
        self.fbb_.push_slot_always::<&Buffer>(
            SparseMatrixIndexCSX::VT_INDPTRBUFFER,
            indptrBuffer,
        );
    }
    #[inline]
    pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
            SparseMatrixIndexCSX::VT_INDICESTYPE,
            indicesType,
        );
    }
    #[inline]
    pub fn add_indicesBuffer(&mut self, indicesBuffer: &Buffer) {
        self.fbb_.push_slot_always::<&Buffer>(
            SparseMatrixIndexCSX::VT_INDICESBUFFER,
            indicesBuffer,
        );
    }
    #[inline]
    pub fn new(
        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    ) -> SparseMatrixIndexCSXBuilder<'a, 'b> {
        let start = _fbb.start_table();
        SparseMatrixIndexCSXBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<SparseMatrixIndexCSX<'a>> {
        let o = self.fbb_.end_table(self.start_);
        self.fbb_
            .required(o, SparseMatrixIndexCSX::VT_INDPTRTYPE, "indptrType");
        self.fbb_
            .required(o, SparseMatrixIndexCSX::VT_INDPTRBUFFER, "indptrBuffer");
        self.fbb_
            .required(o, SparseMatrixIndexCSX::VT_INDICESTYPE, "indicesType");
        self.fbb_
            .required(o, SparseMatrixIndexCSX::VT_INDICESBUFFER, "indicesBuffer");
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for SparseMatrixIndexCSX<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("SparseMatrixIndexCSX");
        ds.field("compressedAxis", &self.compressedAxis());
        ds.field("indptrType", &self.indptrType());
        ds.field("indptrBuffer", &self.indptrBuffer());
        ds.field("indicesType", &self.indicesType());
        ds.field("indicesBuffer", &self.indicesBuffer());
        ds.finish()
    }
}
pub enum SparseTensorIndexCSFOffset {}
#[derive(Copy, Clone, PartialEq)]

/// Compressed Sparse Fiber (CSF) sparse tensor index.
pub struct SparseTensorIndexCSF<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for SparseTensorIndexCSF<'a> {
    type Inner = SparseTensorIndexCSF<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> SparseTensorIndexCSF<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        SparseTensorIndexCSF { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args SparseTensorIndexCSFArgs<'args>,
    ) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'bldr>> {
        let mut builder = SparseTensorIndexCSFBuilder::new(_fbb);
        if let Some(x) = args.axisOrder {
            builder.add_axisOrder(x);
        }
        if let Some(x) = args.indicesBuffers {
            builder.add_indicesBuffers(x);
        }
        if let Some(x) = args.indicesType {
            builder.add_indicesType(x);
        }
        if let Some(x) = args.indptrBuffers {
            builder.add_indptrBuffers(x);
        }
        if let Some(x) = args.indptrType {
            builder.add_indptrType(x);
        }
        builder.finish()
    }

    pub const VT_INDPTRTYPE: flatbuffers::VOffsetT = 4;
    pub const VT_INDPTRBUFFERS: flatbuffers::VOffsetT = 6;
    pub const VT_INDICESTYPE: flatbuffers::VOffsetT = 8;
    pub const VT_INDICESBUFFERS: flatbuffers::VOffsetT = 10;
    pub const VT_AXISORDER: flatbuffers::VOffsetT = 12;

    /// CSF is a generalization of compressed sparse row (CSR) index.
    /// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf)
    ///
    /// CSF index recursively compresses each dimension of a tensor into a set
    /// of prefix trees. Each path from a root to leaf forms one tensor
    /// non-zero index. CSF is implemented with two arrays of buffers and one
    /// arrays of integers.
    ///
    /// For example, let X be a 2x3x4x5 tensor and let it have the following
    /// 8 non-zero values:
    /// ```text
    ///   X[0, 0, 0, 1] := 1
    ///   X[0, 0, 0, 2] := 2
    ///   X[0, 1, 0, 0] := 3
    ///   X[0, 1, 0, 2] := 4
    ///   X[0, 1, 1, 0] := 5
    ///   X[1, 1, 1, 0] := 6
    ///   X[1, 1, 1, 1] := 7
    ///   X[1, 1, 1, 2] := 8
    /// ```
    /// As a prefix tree this would be represented as:
    /// ```text
    ///         0          1
    ///        / \         |
    ///       0   1        1
    ///      /   / \       |
    ///     0   0   1      1
    ///    /|  /|   |    /| |
    ///   1 2 0 2   0   0 1 2
    /// ```
    /// The type of values in indptrBuffers
    #[inline]
    pub fn indptrType(&self) -> Int<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<Int>>(
                SparseTensorIndexCSF::VT_INDPTRTYPE,
                None,
            )
            .unwrap()
    }
    /// indptrBuffers stores the sparsity structure.
    /// Each two consecutive dimensions in a tensor correspond to a buffer in
    /// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]`
    /// and `indptrBuffers[dim][i + 1]` signify a range of nodes in
    /// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node.
    ///
    /// For example, the indptrBuffers for the above X is:
    /// ```text
    ///   indptrBuffer(X) = [
    ///                       [0, 2, 3],
    ///                       [0, 1, 3, 4],
    ///                       [0, 2, 4, 5, 8]
    ///                     ].
    /// ```
    #[inline]
    pub fn indptrBuffers(&self) -> &'a [Buffer] {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
                SparseTensorIndexCSF::VT_INDPTRBUFFERS,
                None,
            )
            .map(|v| v.safe_slice())
            .unwrap()
    }
    /// The type of values in indicesBuffers
    #[inline]
    pub fn indicesType(&self) -> Int<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<Int>>(
                SparseTensorIndexCSF::VT_INDICESTYPE,
                None,
            )
            .unwrap()
    }
    /// indicesBuffers stores values of nodes.
    /// Each tensor dimension corresponds to a buffer in indicesBuffers.
    /// For example, the indicesBuffers for the above X is:
    /// ```text
    ///   indicesBuffer(X) = [
    ///                        [0, 1],
    ///                        [0, 1, 1],
    ///                        [0, 0, 1, 1],
    ///                        [1, 2, 0, 2, 0, 0, 1, 2]
    ///                      ].
    /// ```
    #[inline]
    pub fn indicesBuffers(&self) -> &'a [Buffer] {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
                SparseTensorIndexCSF::VT_INDICESBUFFERS,
                None,
            )
            .map(|v| v.safe_slice())
            .unwrap()
    }
    /// axisOrder stores the sequence in which dimensions were traversed to
    /// produce the prefix tree.
    /// For example, the axisOrder for the above X is:
    /// ```text
    ///   axisOrder(X) = [0, 1, 2, 3].
    /// ```
    #[inline]
    pub fn axisOrder(&self) -> flatbuffers::Vector<'a, i32> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(
                SparseTensorIndexCSF::VT_AXISORDER,
                None,
            )
            .unwrap()
    }
}

impl flatbuffers::Verifiable for SparseTensorIndexCSF<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
                &"indptrType",
                Self::VT_INDPTRTYPE,
                true,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
                &"indptrBuffers",
                Self::VT_INDPTRBUFFERS,
                true,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
                &"indicesType",
                Self::VT_INDICESTYPE,
                true,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
                &"indicesBuffers",
                Self::VT_INDICESBUFFERS,
                true,
            )?
            .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(
                &"axisOrder",
                Self::VT_AXISORDER,
                true,
            )?
            .finish();
        Ok(())
    }
}
pub struct SparseTensorIndexCSFArgs<'a> {
    pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
    pub indptrBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
    pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
    pub indicesBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
    pub axisOrder: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
}
impl<'a> Default for SparseTensorIndexCSFArgs<'a> {
    #[inline]
    fn default() -> Self {
        SparseTensorIndexCSFArgs {
            indptrType: None,     // required field
            indptrBuffers: None,  // required field
            indicesType: None,    // required field
            indicesBuffers: None, // required field
            axisOrder: None,      // required field
        }
    }
}
pub struct SparseTensorIndexCSFBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> SparseTensorIndexCSFBuilder<'a, 'b> {
    #[inline]
    pub fn add_indptrType(&mut self, indptrType: flatbuffers::WIPOffset<Int<'b>>) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
            SparseTensorIndexCSF::VT_INDPTRTYPE,
            indptrType,
        );
    }
    #[inline]
    pub fn add_indptrBuffers(
        &mut self,
        indptrBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
    ) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
            SparseTensorIndexCSF::VT_INDPTRBUFFERS,
            indptrBuffers,
        );
    }
    #[inline]
    pub fn add_indicesType(&mut self, indicesType: flatbuffers::WIPOffset<Int<'b>>) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Int>>(
            SparseTensorIndexCSF::VT_INDICESTYPE,
            indicesType,
        );
    }
    #[inline]
    pub fn add_indicesBuffers(
        &mut self,
        indicesBuffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
    ) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
            SparseTensorIndexCSF::VT_INDICESBUFFERS,
            indicesBuffers,
        );
    }
    #[inline]
    pub fn add_axisOrder(
        &mut self,
        axisOrder: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i32>>,
    ) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
            SparseTensorIndexCSF::VT_AXISORDER,
            axisOrder,
        );
    }
    #[inline]
    pub fn new(
        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    ) -> SparseTensorIndexCSFBuilder<'a, 'b> {
        let start = _fbb.start_table();
        SparseTensorIndexCSFBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensorIndexCSF<'a>> {
        let o = self.fbb_.end_table(self.start_);
        self.fbb_
            .required(o, SparseTensorIndexCSF::VT_INDPTRTYPE, "indptrType");
        self.fbb_
            .required(o, SparseTensorIndexCSF::VT_INDPTRBUFFERS, "indptrBuffers");
        self.fbb_
            .required(o, SparseTensorIndexCSF::VT_INDICESTYPE, "indicesType");
        self.fbb_
            .required(o, SparseTensorIndexCSF::VT_INDICESBUFFERS, "indicesBuffers");
        self.fbb_
            .required(o, SparseTensorIndexCSF::VT_AXISORDER, "axisOrder");
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for SparseTensorIndexCSF<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("SparseTensorIndexCSF");
        ds.field("indptrType", &self.indptrType());
        ds.field("indptrBuffers", &self.indptrBuffers());
        ds.field("indicesType", &self.indicesType());
        ds.field("indicesBuffers", &self.indicesBuffers());
        ds.field("axisOrder", &self.axisOrder());
        ds.finish()
    }
}
pub enum SparseTensorOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct SparseTensor<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for SparseTensor<'a> {
    type Inner = SparseTensor<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> SparseTensor<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        SparseTensor { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args SparseTensorArgs<'args>,
    ) -> flatbuffers::WIPOffset<SparseTensor<'bldr>> {
        let mut builder = SparseTensorBuilder::new(_fbb);
        builder.add_non_zero_length(args.non_zero_length);
        if let Some(x) = args.data {
            builder.add_data(x);
        }
        if let Some(x) = args.sparseIndex {
            builder.add_sparseIndex(x);
        }
        if let Some(x) = args.shape {
            builder.add_shape(x);
        }
        if let Some(x) = args.type_ {
            builder.add_type_(x);
        }
        builder.add_sparseIndex_type(args.sparseIndex_type);
        builder.add_type_type(args.type_type);
        builder.finish()
    }

    pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4;
    pub const VT_TYPE_: flatbuffers::VOffsetT = 6;
    pub const VT_SHAPE: flatbuffers::VOffsetT = 8;
    pub const VT_NON_ZERO_LENGTH: flatbuffers::VOffsetT = 10;
    pub const VT_SPARSEINDEX_TYPE: flatbuffers::VOffsetT = 12;
    pub const VT_SPARSEINDEX: flatbuffers::VOffsetT = 14;
    pub const VT_DATA: flatbuffers::VOffsetT = 16;

    #[inline]
    pub fn type_type(&self) -> Type {
        self._tab
            .get::<Type>(SparseTensor::VT_TYPE_TYPE, Some(Type::NONE))
            .unwrap()
    }
    /// The type of data contained in a value cell.
    /// Currently only fixed-width value types are supported,
    /// no strings or nested types.
    #[inline]
    pub fn type_(&self) -> flatbuffers::Table<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
                SparseTensor::VT_TYPE_,
                None,
            )
            .unwrap()
    }
    /// The dimensions of the tensor, optionally named.
    #[inline]
    pub fn shape(
        &self,
    ) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<
                flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim>>,
            >>(SparseTensor::VT_SHAPE, None)
            .unwrap()
    }
    /// The number of non-zero values in a sparse tensor.
    #[inline]
    pub fn non_zero_length(&self) -> i64 {
        self._tab
            .get::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, Some(0))
            .unwrap()
    }
    #[inline]
    pub fn sparseIndex_type(&self) -> SparseTensorIndex {
        self._tab
            .get::<SparseTensorIndex>(
                SparseTensor::VT_SPARSEINDEX_TYPE,
                Some(SparseTensorIndex::NONE),
            )
            .unwrap()
    }
    /// Sparse tensor index
    #[inline]
    pub fn sparseIndex(&self) -> flatbuffers::Table<'a> {
        self._tab
            .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
                SparseTensor::VT_SPARSEINDEX,
                None,
            )
            .unwrap()
    }
    /// The location and size of the tensor's data
    #[inline]
    pub fn data(&self) -> &'a Buffer {
        self._tab
            .get::<Buffer>(SparseTensor::VT_DATA, None)
            .unwrap()
    }
    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_null(&self) -> Option<Null<'a>> {
        if self.type_type() == Type::Null {
            let u = self.type_();
            Some(Null::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_int(&self) -> Option<Int<'a>> {
        if self.type_type() == Type::Int {
            let u = self.type_();
            Some(Int::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_floating_point(&self) -> Option<FloatingPoint<'a>> {
        if self.type_type() == Type::FloatingPoint {
            let u = self.type_();
            Some(FloatingPoint::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_binary(&self) -> Option<Binary<'a>> {
        if self.type_type() == Type::Binary {
            let u = self.type_();
            Some(Binary::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_utf_8(&self) -> Option<Utf8<'a>> {
        if self.type_type() == Type::Utf8 {
            let u = self.type_();
            Some(Utf8::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_bool(&self) -> Option<Bool<'a>> {
        if self.type_type() == Type::Bool {
            let u = self.type_();
            Some(Bool::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_decimal(&self) -> Option<Decimal<'a>> {
        if self.type_type() == Type::Decimal {
            let u = self.type_();
            Some(Decimal::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_date(&self) -> Option<Date<'a>> {
        if self.type_type() == Type::Date {
            let u = self.type_();
            Some(Date::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_time(&self) -> Option<Time<'a>> {
        if self.type_type() == Type::Time {
            let u = self.type_();
            Some(Time::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_timestamp(&self) -> Option<Timestamp<'a>> {
        if self.type_type() == Type::Timestamp {
            let u = self.type_();
            Some(Timestamp::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_interval(&self) -> Option<Interval<'a>> {
        if self.type_type() == Type::Interval {
            let u = self.type_();
            Some(Interval::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_list(&self) -> Option<List<'a>> {
        if self.type_type() == Type::List {
            let u = self.type_();
            Some(List::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_struct_(&self) -> Option<Struct_<'a>> {
        if self.type_type() == Type::Struct_ {
            let u = self.type_();
            Some(Struct_::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_union(&self) -> Option<Union<'a>> {
        if self.type_type() == Type::Union {
            let u = self.type_();
            Some(Union::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_fixed_size_binary(&self) -> Option<FixedSizeBinary<'a>> {
        if self.type_type() == Type::FixedSizeBinary {
            let u = self.type_();
            Some(FixedSizeBinary::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_fixed_size_list(&self) -> Option<FixedSizeList<'a>> {
        if self.type_type() == Type::FixedSizeList {
            let u = self.type_();
            Some(FixedSizeList::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_map(&self) -> Option<Map<'a>> {
        if self.type_type() == Type::Map {
            let u = self.type_();
            Some(Map::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_duration(&self) -> Option<Duration<'a>> {
        if self.type_type() == Type::Duration {
            let u = self.type_();
            Some(Duration::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_large_binary(&self) -> Option<LargeBinary<'a>> {
        if self.type_type() == Type::LargeBinary {
            let u = self.type_();
            Some(LargeBinary::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_large_utf_8(&self) -> Option<LargeUtf8<'a>> {
        if self.type_type() == Type::LargeUtf8 {
            let u = self.type_();
            Some(LargeUtf8::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn type_as_large_list(&self) -> Option<LargeList<'a>> {
        if self.type_type() == Type::LargeList {
            let u = self.type_();
            Some(LargeList::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn sparseIndex_as_sparse_tensor_index_coo(
        &self,
    ) -> Option<SparseTensorIndexCOO<'a>> {
        if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCOO {
            let u = self.sparseIndex();
            Some(SparseTensorIndexCOO::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn sparseIndex_as_sparse_matrix_index_csx(
        &self,
    ) -> Option<SparseMatrixIndexCSX<'a>> {
        if self.sparseIndex_type() == SparseTensorIndex::SparseMatrixIndexCSX {
            let u = self.sparseIndex();
            Some(SparseMatrixIndexCSX::init_from_table(u))
        } else {
            None
        }
    }

    #[inline]
    #[allow(non_snake_case)]
    pub fn sparseIndex_as_sparse_tensor_index_csf(
        &self,
    ) -> Option<SparseTensorIndexCSF<'a>> {
        if self.sparseIndex_type() == SparseTensorIndex::SparseTensorIndexCSF {
            let u = self.sparseIndex();
            Some(SparseTensorIndexCSF::init_from_table(u))
        } else {
            None
        }
    }
}

impl flatbuffers::Verifiable for SparseTensor<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use flatbuffers::Verifiable;
        v.visit_table(pos)?
     .visit_union::<Type, _>(&"type_type", Self::VT_TYPE_TYPE, &"type_", Self::VT_TYPE_, true, |key, v, pos| {
        match key {
          Type::Null => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>("Type::Null", pos),
          Type::Int => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>("Type::Int", pos),
          Type::FloatingPoint => v.verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>("Type::FloatingPoint", pos),
          Type::Binary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>("Type::Binary", pos),
          Type::Utf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>("Type::Utf8", pos),
          Type::Bool => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>("Type::Bool", pos),
          Type::Decimal => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>("Type::Decimal", pos),
          Type::Date => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>("Type::Date", pos),
          Type::Time => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>("Type::Time", pos),
          Type::Timestamp => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>("Type::Timestamp", pos),
          Type::Interval => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>("Type::Interval", pos),
          Type::List => v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>("Type::List", pos),
          Type::Struct_ => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>("Type::Struct_", pos),
          Type::Union => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>("Type::Union", pos),
          Type::FixedSizeBinary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>("Type::FixedSizeBinary", pos),
          Type::FixedSizeList => v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>("Type::FixedSizeList", pos),
          Type::Map => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>("Type::Map", pos),
          Type::Duration => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>("Type::Duration", pos),
          Type::LargeBinary => v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>("Type::LargeBinary", pos),
          Type::LargeUtf8 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>("Type::LargeUtf8", pos),
          Type::LargeList => v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>("Type::LargeList", pos),
          _ => Ok(()),
        }
     })?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<TensorDim>>>>(&"shape", Self::VT_SHAPE, true)?
     .visit_field::<i64>(&"non_zero_length", Self::VT_NON_ZERO_LENGTH, false)?
     .visit_union::<SparseTensorIndex, _>(&"sparseIndex_type", Self::VT_SPARSEINDEX_TYPE, &"sparseIndex", Self::VT_SPARSEINDEX, true, |key, v, pos| {
        match key {
          SparseTensorIndex::SparseTensorIndexCOO => v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCOO>>("SparseTensorIndex::SparseTensorIndexCOO", pos),
          SparseTensorIndex::SparseMatrixIndexCSX => v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseMatrixIndexCSX>>("SparseTensorIndex::SparseMatrixIndexCSX", pos),
          SparseTensorIndex::SparseTensorIndexCSF => v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCSF>>("SparseTensorIndex::SparseTensorIndexCSF", pos),
          _ => Ok(()),
        }
     })?
     .visit_field::<Buffer>(&"data", Self::VT_DATA, true)?
     .finish();
        Ok(())
    }
}
pub struct SparseTensorArgs<'a> {
    pub type_type: Type,
    pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
    pub shape: Option<
        flatbuffers::WIPOffset<
            flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
        >,
    >,
    pub non_zero_length: i64,
    pub sparseIndex_type: SparseTensorIndex,
    pub sparseIndex: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
    pub data: Option<&'a Buffer>,
}
impl<'a> Default for SparseTensorArgs<'a> {
    #[inline]
    fn default() -> Self {
        SparseTensorArgs {
            type_type: Type::NONE,
            type_: None, // required field
            shape: None, // required field
            non_zero_length: 0,
            sparseIndex_type: SparseTensorIndex::NONE,
            sparseIndex: None, // required field
            data: None,        // required field
        }
    }
}
pub struct SparseTensorBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> SparseTensorBuilder<'a, 'b> {
    #[inline]
    pub fn add_type_type(&mut self, type_type: Type) {
        self.fbb_
            .push_slot::<Type>(SparseTensor::VT_TYPE_TYPE, type_type, Type::NONE);
    }
    #[inline]
    pub fn add_type_(
        &mut self,
        type_: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
    ) {
        self.fbb_
            .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_TYPE_, type_);
    }
    #[inline]
    pub fn add_shape(
        &mut self,
        shape: flatbuffers::WIPOffset<
            flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<TensorDim<'b>>>,
        >,
    ) {
        self.fbb_
            .push_slot_always::<flatbuffers::WIPOffset<_>>(SparseTensor::VT_SHAPE, shape);
    }
    #[inline]
    pub fn add_non_zero_length(&mut self, non_zero_length: i64) {
        self.fbb_
            .push_slot::<i64>(SparseTensor::VT_NON_ZERO_LENGTH, non_zero_length, 0);
    }
    #[inline]
    pub fn add_sparseIndex_type(&mut self, sparseIndex_type: SparseTensorIndex) {
        self.fbb_.push_slot::<SparseTensorIndex>(
            SparseTensor::VT_SPARSEINDEX_TYPE,
            sparseIndex_type,
            SparseTensorIndex::NONE,
        );
    }
    #[inline]
    pub fn add_sparseIndex(
        &mut self,
        sparseIndex: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
    ) {
        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
            SparseTensor::VT_SPARSEINDEX,
            sparseIndex,
        );
    }
    #[inline]
    pub fn add_data(&mut self, data: &Buffer) {
        self.fbb_
            .push_slot_always::<&Buffer>(SparseTensor::VT_DATA, data);
    }
    #[inline]
    pub fn new(
        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    ) -> SparseTensorBuilder<'a, 'b> {
        let start = _fbb.start_table();
        SparseTensorBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<SparseTensor<'a>> {
        let o = self.fbb_.end_table(self.start_);
        self.fbb_.required(o, SparseTensor::VT_TYPE_, "type_");
        self.fbb_.required(o, SparseTensor::VT_SHAPE, "shape");
        self.fbb_
            .required(o, SparseTensor::VT_SPARSEINDEX, "sparseIndex");
        self.fbb_.required(o, SparseTensor::VT_DATA, "data");
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for SparseTensor<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("SparseTensor");
        ds.field("type_type", &self.type_type());
        match self.type_type() {
            Type::Null => {
                if let Some(x) = self.type_as_null() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Int => {
                if let Some(x) = self.type_as_int() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::FloatingPoint => {
                if let Some(x) = self.type_as_floating_point() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Binary => {
                if let Some(x) = self.type_as_binary() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Utf8 => {
                if let Some(x) = self.type_as_utf_8() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Bool => {
                if let Some(x) = self.type_as_bool() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Decimal => {
                if let Some(x) = self.type_as_decimal() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Date => {
                if let Some(x) = self.type_as_date() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Time => {
                if let Some(x) = self.type_as_time() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Timestamp => {
                if let Some(x) = self.type_as_timestamp() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Interval => {
                if let Some(x) = self.type_as_interval() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::List => {
                if let Some(x) = self.type_as_list() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Struct_ => {
                if let Some(x) = self.type_as_struct_() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Union => {
                if let Some(x) = self.type_as_union() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::FixedSizeBinary => {
                if let Some(x) = self.type_as_fixed_size_binary() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::FixedSizeList => {
                if let Some(x) = self.type_as_fixed_size_list() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Map => {
                if let Some(x) = self.type_as_map() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::Duration => {
                if let Some(x) = self.type_as_duration() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::LargeBinary => {
                if let Some(x) = self.type_as_large_binary() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::LargeUtf8 => {
                if let Some(x) = self.type_as_large_utf_8() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            Type::LargeList => {
                if let Some(x) = self.type_as_large_list() {
                    ds.field("type_", &x)
                } else {
                    ds.field(
                        "type_",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            _ => {
                let x: Option<()> = None;
                ds.field("type_", &x)
            }
        };
        ds.field("shape", &self.shape());
        ds.field("non_zero_length", &self.non_zero_length());
        ds.field("sparseIndex_type", &self.sparseIndex_type());
        match self.sparseIndex_type() {
            SparseTensorIndex::SparseTensorIndexCOO => {
                if let Some(x) = self.sparseIndex_as_sparse_tensor_index_coo() {
                    ds.field("sparseIndex", &x)
                } else {
                    ds.field(
                        "sparseIndex",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            SparseTensorIndex::SparseMatrixIndexCSX => {
                if let Some(x) = self.sparseIndex_as_sparse_matrix_index_csx() {
                    ds.field("sparseIndex", &x)
                } else {
                    ds.field(
                        "sparseIndex",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            SparseTensorIndex::SparseTensorIndexCSF => {
                if let Some(x) = self.sparseIndex_as_sparse_tensor_index_csf() {
                    ds.field("sparseIndex", &x)
                } else {
                    ds.field(
                        "sparseIndex",
                        &"InvalidFlatbuffer: Union discriminant does not match value.",
                    )
                }
            }
            _ => {
                let x: Option<()> = None;
                ds.field("sparseIndex", &x)
            }
        };
        ds.field("data", &self.data());
        ds.finish()
    }
}
#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_sparse_tensor<'a>(buf: &'a [u8]) -> SparseTensor<'a> {
    unsafe { flatbuffers::root_unchecked::<SparseTensor<'a>>(buf) }
}

#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_sparse_tensor<'a>(buf: &'a [u8]) -> SparseTensor<'a> {
    unsafe { flatbuffers::size_prefixed_root_unchecked::<SparseTensor<'a>>(buf) }
}

#[inline]
/// Verifies that a buffer of bytes contains a `SparseTensor`
/// and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_sparse_tensor_unchecked`.
pub fn root_as_sparse_tensor(
    buf: &[u8],
) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::root::<SparseTensor>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `SparseTensor` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_sparse_tensor_unchecked`.
pub fn size_prefixed_root_as_sparse_tensor(
    buf: &[u8],
) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::size_prefixed_root::<SparseTensor>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `SparseTensor` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_sparse_tensor_unchecked`.
pub fn root_as_sparse_tensor_with_opts<'b, 'o>(
    opts: &'o flatbuffers::VerifierOptions,
    buf: &'b [u8],
) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::root_with_opts::<SparseTensor<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `SparseTensor` and returns
/// it. Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_sparse_tensor_unchecked`.
pub fn size_prefixed_root_as_sparse_tensor_with_opts<'b, 'o>(
    opts: &'o flatbuffers::VerifierOptions,
    buf: &'b [u8],
) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::size_prefixed_root_with_opts::<SparseTensor<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a SparseTensor and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `SparseTensor`.
pub unsafe fn root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
    flatbuffers::root_unchecked::<SparseTensor>(buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed SparseTensor and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `SparseTensor`.
pub unsafe fn size_prefixed_root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
    flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf)
}
#[inline]
pub fn finish_sparse_tensor_buffer<'a, 'b>(
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    root: flatbuffers::WIPOffset<SparseTensor<'a>>,
) {
    fbb.finish(root, None);
}

#[inline]
pub fn finish_size_prefixed_sparse_tensor_buffer<'a, 'b>(
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    root: flatbuffers::WIPOffset<SparseTensor<'a>>,
) {
    fbb.finish_size_prefixed(root, None);
}