singe-cutensor-sys 0.1.0-alpha.7

Low-level FFI bindings for the NVIDIA cuTENSOR tensor algebra library.
Documentation
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
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
/* automatically generated by rust-bindgen 0.72.1 */

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage> {
    storage: Storage,
}
impl<Storage> __BindgenBitfieldUnit<Storage> {
    #[inline]
    pub const fn new(storage: Storage) -> Self {
        Self { storage }
    }
}
impl<Storage> __BindgenBitfieldUnit<Storage>
where
    Storage: AsRef<[u8]> + AsMut<[u8]>,
{
    #[inline]
    fn extract_bit(byte: u8, index: usize) -> bool {
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        byte & mask == mask
    }
    #[inline]
    pub fn get_bit(&self, index: usize) -> bool {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = self.storage.as_ref()[byte_index];
        Self::extract_bit(byte, index)
    }
    #[inline]
    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
        debug_assert!(index / 8 < core::mem::size_of::< Storage > ());
        let byte_index = index / 8;
        let byte = unsafe {
            *(core::ptr::addr_of!((* this).storage) as *const u8)
                .offset(byte_index as isize)
        };
        Self::extract_bit(byte, index)
    }
    #[inline]
    fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        if val { byte | mask } else { byte & !mask }
    }
    #[inline]
    pub fn set_bit(&mut self, index: usize, val: bool) {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = &mut self.storage.as_mut()[byte_index];
        *byte = Self::change_bit(*byte, index, val);
    }
    #[inline]
    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
        debug_assert!(index / 8 < core::mem::size_of::< Storage > ());
        let byte_index = index / 8;
        let byte = unsafe {
            (core::ptr::addr_of_mut!((* this).storage) as *mut u8)
                .offset(byte_index as isize)
        };
        unsafe { *byte = Self::change_bit(*byte, index, val) };
    }
    #[inline]
    pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!(
            (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()
        );
        let mut val = 0;
        for i in 0..(bit_width as usize) {
            if self.get_bit(i + bit_offset) {
                let index = if cfg!(target_endian = "big") {
                    bit_width as usize - 1 - i
                } else {
                    i
                };
                val |= 1 << index;
            }
        }
        val
    }
    #[inline]
    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < core::mem::size_of::< Storage > ());
        debug_assert!(
            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::< Storage > ()
        );
        let mut val = 0;
        for i in 0..(bit_width as usize) {
            if unsafe { Self::raw_get_bit(this, i + bit_offset) } {
                let index = if cfg!(target_endian = "big") {
                    bit_width as usize - 1 - i
                } else {
                    i
                };
                val |= 1 << index;
            }
        }
        val
    }
    #[inline]
    pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!(
            (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()
        );
        for i in 0..(bit_width as usize) {
            let mask = 1 << i;
            let val_bit_is_set = val & mask == mask;
            let index = if cfg!(target_endian = "big") {
                bit_width as usize - 1 - i
            } else {
                i
            };
            self.set_bit(index + bit_offset, val_bit_is_set);
        }
    }
    #[inline]
    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < core::mem::size_of::< Storage > ());
        debug_assert!(
            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::< Storage > ()
        );
        for i in 0..(bit_width as usize) {
            let mask = 1 << i;
            let val_bit_is_set = val & mask == mask;
            let index = if cfg!(target_endian = "big") {
                bit_width as usize - 1 - i
            } else {
                i
            };
            unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
        }
    }
}
pub const CUTENSOR_MAJOR: u32 = 2;
pub const CUTENSOR_MINOR: u32 = 6;
pub const CUTENSOR_PATCH: u32 = 0;
pub const CUTENSOR_VERSION: u32 = 20600;
pub type __uint64_t = ::core::ffi::c_ulong;
pub type __off_t = ::core::ffi::c_long;
pub type __off64_t = ::core::ffi::c_long;
pub type size_t = ::core::ffi::c_ulong;
pub type FILE = _IO_FILE;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IO_marker {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IO_codecvt {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IO_wide_data {
    _unused: [u8; 0],
}
pub type _IO_lock_t = ::core::ffi::c_void;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct _IO_FILE {
    pub _flags: ::core::ffi::c_int,
    pub _IO_read_ptr: *mut ::core::ffi::c_char,
    pub _IO_read_end: *mut ::core::ffi::c_char,
    pub _IO_read_base: *mut ::core::ffi::c_char,
    pub _IO_write_base: *mut ::core::ffi::c_char,
    pub _IO_write_ptr: *mut ::core::ffi::c_char,
    pub _IO_write_end: *mut ::core::ffi::c_char,
    pub _IO_buf_base: *mut ::core::ffi::c_char,
    pub _IO_buf_end: *mut ::core::ffi::c_char,
    pub _IO_save_base: *mut ::core::ffi::c_char,
    pub _IO_backup_base: *mut ::core::ffi::c_char,
    pub _IO_save_end: *mut ::core::ffi::c_char,
    pub _markers: *mut _IO_marker,
    pub _chain: *mut _IO_FILE,
    pub _fileno: ::core::ffi::c_int,
    pub _bitfield_align_1: [u32; 0],
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize]>,
    pub _short_backupbuf: [::core::ffi::c_char; 1usize],
    pub _old_offset: __off_t,
    pub _cur_column: ::core::ffi::c_ushort,
    pub _vtable_offset: ::core::ffi::c_schar,
    pub _shortbuf: [::core::ffi::c_char; 1usize],
    pub _lock: *mut _IO_lock_t,
    pub _offset: __off64_t,
    pub _codecvt: *mut _IO_codecvt,
    pub _wide_data: *mut _IO_wide_data,
    pub _freeres_list: *mut _IO_FILE,
    pub _freeres_buf: *mut ::core::ffi::c_void,
    pub _prevchain: *mut *mut _IO_FILE,
    pub _mode: ::core::ffi::c_int,
    pub _unused3: ::core::ffi::c_int,
    pub _total_written: __uint64_t,
    pub _unused2: [::core::ffi::c_char; 8usize],
}
impl Default for _IO_FILE {
    fn default() -> Self {
        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
impl _IO_FILE {
    #[inline]
    pub fn _flags2(&self) -> ::core::ffi::c_int {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 24u8) as u32) }
    }
    #[inline]
    pub fn set__flags2(&mut self, val: ::core::ffi::c_int) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 24u8, val as u64)
        }
    }
    #[inline]
    pub unsafe fn _flags2_raw(this: *const Self) -> ::core::ffi::c_int {
        unsafe {
            ::core::mem::transmute(
                <__BindgenBitfieldUnit<
                    [u8; 3usize],
                >>::raw_get(::core::ptr::addr_of!((* this)._bitfield_1), 0usize, 24u8)
                    as u32,
            )
        }
    }
    #[inline]
    pub unsafe fn set__flags2_raw(this: *mut Self, val: ::core::ffi::c_int) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            <__BindgenBitfieldUnit<
                [u8; 3usize],
            >>::raw_set(
                ::core::ptr::addr_of_mut!((* this)._bitfield_1),
                0usize,
                24u8,
                val as u64,
            )
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        _flags2: ::core::ffi::c_int,
    ) -> __BindgenBitfieldUnit<[u8; 3usize]> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 3usize]> = Default::default();
        __bindgen_bitfield_unit
            .set(
                0usize,
                24u8,
                {
                    let _flags2: u32 = unsafe { ::core::mem::transmute(_flags2) };
                    _flags2 as u64
                },
            );
        __bindgen_bitfield_unit
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUstream_st {
    _unused: [u8; 0],
}
pub use self::cudaDataType_t as cutensorDataType_t;
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_16F"]
    pub static CUTENSOR_R_16F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_16F"]
    pub static CUTENSOR_C_16F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL15CUTENSOR_R_16BF"]
    pub static CUTENSOR_R_16BF: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL15CUTENSOR_C_16BF"]
    pub static CUTENSOR_C_16BF: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_32F"]
    pub static CUTENSOR_R_32F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_32F"]
    pub static CUTENSOR_C_32F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_64F"]
    pub static CUTENSOR_R_64F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_64F"]
    pub static CUTENSOR_C_64F: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_R_4I"]
    pub static CUTENSOR_R_4I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_C_4I"]
    pub static CUTENSOR_C_4I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_R_4U"]
    pub static CUTENSOR_R_4U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_C_4U"]
    pub static CUTENSOR_C_4U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_R_8I"]
    pub static CUTENSOR_R_8I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_C_8I"]
    pub static CUTENSOR_C_8I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_R_8U"]
    pub static CUTENSOR_R_8U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL13CUTENSOR_C_8U"]
    pub static CUTENSOR_C_8U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_16I"]
    pub static CUTENSOR_R_16I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_16I"]
    pub static CUTENSOR_C_16I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_16U"]
    pub static CUTENSOR_R_16U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_16U"]
    pub static CUTENSOR_C_16U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_32I"]
    pub static CUTENSOR_R_32I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_32I"]
    pub static CUTENSOR_C_32I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_32U"]
    pub static CUTENSOR_R_32U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_32U"]
    pub static CUTENSOR_C_32U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_64I"]
    pub static CUTENSOR_R_64I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_64I"]
    pub static CUTENSOR_C_64I: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_R_64U"]
    pub static CUTENSOR_R_64U: cutensorDataType_t;
}
unsafe extern "C" {
    #[link_name = "\u{1}_ZL14CUTENSOR_C_64U"]
    pub static CUTENSOR_C_64U: cutensorDataType_t;
}
/// This enum captures all unary and binary element-wise operations supported by the cuTENSOR library.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorOperator_t {
    /// Identity operator (i.e., elements are not changed).
    CUTENSOR_OP_IDENTITY = 1,
    /// Square root.
    CUTENSOR_OP_SQRT = 2,
    /// Rectified linear unit.
    CUTENSOR_OP_RELU = 8,
    /// Complex conjugate.
    CUTENSOR_OP_CONJ = 9,
    /// Reciprocal.
    CUTENSOR_OP_RCP = 10,
    /// y=1/(1+exp(-x)).
    CUTENSOR_OP_SIGMOID = 11,
    /// y=tanh(x).
    CUTENSOR_OP_TANH = 12,
    /// Exponentiation.
    CUTENSOR_OP_EXP = 22,
    /// Log (base e).
    CUTENSOR_OP_LOG = 23,
    /// Absolute value.
    CUTENSOR_OP_ABS = 24,
    /// Negation.
    CUTENSOR_OP_NEG = 25,
    /// Sine.
    CUTENSOR_OP_SIN = 26,
    /// Cosine.
    CUTENSOR_OP_COS = 27,
    /// Tangent.
    CUTENSOR_OP_TAN = 28,
    /// Hyperbolic sine.
    CUTENSOR_OP_SINH = 29,
    /// Hyperbolic cosine.
    CUTENSOR_OP_COSH = 30,
    /// Inverse sine.
    CUTENSOR_OP_ASIN = 31,
    /// Inverse cosine.
    CUTENSOR_OP_ACOS = 32,
    /// Inverse tangent.
    CUTENSOR_OP_ATAN = 33,
    /// Inverse hyperbolic sine.
    CUTENSOR_OP_ASINH = 34,
    /// Inverse hyperbolic cosine.
    CUTENSOR_OP_ACOSH = 35,
    /// Inverse hyperbolic tangent.
    CUTENSOR_OP_ATANH = 36,
    /// Ceiling.
    CUTENSOR_OP_CEIL = 37,
    /// Floor.
    CUTENSOR_OP_FLOOR = 38,
    /// Mish y=x\*tanh(softplus(x)).
    CUTENSOR_OP_MISH = 39,
    /// Swish y=x\*sigmoid(x).
    CUTENSOR_OP_SWISH = 40,
    /// Softplus y=log(exp(x)+1).
    CUTENSOR_OP_SOFT_PLUS = 41,
    /// Softsign y=x/(abs(x)+1).
    CUTENSOR_OP_SOFT_SIGN = 42,
    /// Addition of two elements.
    CUTENSOR_OP_ADD = 3,
    /// Multiplication of two elements.
    CUTENSOR_OP_MUL = 5,
    /// Maximum of two elements.
    CUTENSOR_OP_MAX = 6,
    /// Minimum of two elements.
    CUTENSOR_OP_MIN = 7,
    /// reserved for internal use only.
    CUTENSOR_OP_UNKNOWN = 126,
}
/// cuTENSOR status type returns
///
/// The type is used for function status returns. All cuTENSOR library functions return their status, which can have the following values.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorStatus_t {
    /// The operation completed successfully.
    CUTENSOR_STATUS_SUCCESS = 0,
    /// The opaque data structure was not initialized.
    CUTENSOR_STATUS_NOT_INITIALIZED = 1,
    /// Resource allocation failed inside the cuTENSOR library.
    CUTENSOR_STATUS_ALLOC_FAILED = 3,
    /// An unsupported value or parameter was passed to the function (indicates an user error).
    CUTENSOR_STATUS_INVALID_VALUE = 7,
    /// Indicates that the device is either not ready, or the target architecture is not supported.
    CUTENSOR_STATUS_ARCH_MISMATCH = 8,
    /// An access to GPU memory space failed, which is usually caused by a failure to bind a texture.
    CUTENSOR_STATUS_MAPPING_ERROR = 11,
    /// The GPU program failed to execute. This is often caused by a launch failure of the kernel on the GPU, which can be caused by multiple reasons.
    CUTENSOR_STATUS_EXECUTION_FAILED = 13,
    /// An internal cuTENSOR error has occurred.
    CUTENSOR_STATUS_INTERNAL_ERROR = 14,
    /// The requested operation is not supported.
    CUTENSOR_STATUS_NOT_SUPPORTED = 15,
    /// The functionality requested requires some license and an error was detected when trying to check the current licensing.
    CUTENSOR_STATUS_LICENSE_ERROR = 16,
    /// A call to CUBLAS did not succeed.
    CUTENSOR_STATUS_CUBLAS_ERROR = 17,
    /// Some unknown CUDA error has occurred.
    CUTENSOR_STATUS_CUDA_ERROR = 18,
    /// The provided workspace was insufficient.
    CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE = 19,
    /// Indicates that the driver version is insufficient.
    CUTENSOR_STATUS_INSUFFICIENT_DRIVER = 20,
    /// Indicates an error related to file I/O.
    CUTENSOR_STATUS_IO_ERROR = 21,
}
/// Allows users to specify the algorithm to be used for performing the desired tensor operation.
#[repr(i32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorAlgo_t {
    /// More time-consuming than CUTENSOR_DEFAULT, but typically provides a more accurate kernel selection.
    CUTENSOR_ALGO_DEFAULT_PATIENT = -6,
    /// Choose the GETT algorithm (only applicable to contractions).
    CUTENSOR_ALGO_GETT = -4,
    /// Transpose (A or B) + GETT (only applicable to contractions).
    CUTENSOR_ALGO_TGETT = -3,
    /// Transpose-Transpose-GEMM-Transpose (requires additional memory) (only applicable to contractions).
    CUTENSOR_ALGO_TTGT = -2,
    /// A performance model chooses the appropriate algorithm and kernel.
    CUTENSOR_ALGO_DEFAULT = -1,
}
/// This enum gives users finer control over the suggested workspace.
///
/// This enum gives users finer control over the amount of workspace that is suggested by [`cutensorEstimateWorkspaceSize`].
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorWorksizePreference_t {
    /// Least memory requirement; at least one algorithm will be available.
    CUTENSOR_WORKSPACE_MIN = 1,
    /// Aims to attain high performance while also reducing the workspace requirement.
    CUTENSOR_WORKSPACE_DEFAULT = 2,
    /// Highest memory requirement; all algorithms will be available (choose this option if memory footprint is not a concern).
    CUTENSOR_WORKSPACE_MAX = 3,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorComputeDescriptor {
    _unused: [u8; 0],
}
/// Opaque structure representing a compute descriptor.
pub type cutensorComputeDescriptor_t = *mut cutensorComputeDescriptor;
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_16F: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_16BF: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_TF32: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_3XTF32: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_32F: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_64F: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_9X16BF: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_8XINT8: cutensorComputeDescriptor_t;
}
unsafe extern "C" {
    pub static CUTENSOR_COMPUTE_DESC_4X16F: cutensorComputeDescriptor_t;
}
/// This enum lists all attributes of a [`cutensorOperationDescriptor_t`] that can be modified (see [`cutensorOperationDescriptorSetAttribute`] and [`cutensorOperationDescriptorGetAttribute`]).
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorOperationDescriptorAttribute_t {
    /// int32_t: enables users to distinguish two identical problems with respect to the sw-managed plan-cache. (default value: 0).
    CUTENSOR_OPERATION_DESCRIPTOR_TAG = 0,
    /// cudaDataType_t: data type of the scaling factors.
    CUTENSOR_OPERATION_DESCRIPTOR_SCALAR_TYPE = 1,
    /// float: number of floating-point operations necessary to perform this operation (assuming all scalar are not equal to zero, unless otherwise specified).
    CUTENSOR_OPERATION_DESCRIPTOR_FLOPS = 2,
    /// float: minimal number of bytes transferred from/to global-memory (assuming all scalar are not equal to zero, unless otherwise specified).
    CUTENSOR_OPERATION_DESCRIPTOR_MOVED_BYTES = 3,
    /// uint32_t[] (of size descOut->numModes): Each entry i holds the number of padded values that should be padded to the left of the ith dimension.
    CUTENSOR_OPERATION_DESCRIPTOR_PADDING_LEFT = 4,
    /// uint32_t[] (of size descOut->numModes): Each entry i holds the number of padded values that should be padded to the right of the ith dimension.
    CUTENSOR_OPERATION_DESCRIPTOR_PADDING_RIGHT = 5,
    /// host-side pointer to element of the same type as the output tensor: Constant padding value.
    CUTENSOR_OPERATION_DESCRIPTOR_PADDING_VALUE = 6,
}
/// This enum lists all attributes of a [`cutensorPlanPreference_t`] object that can be modified.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorPlanPreferenceAttribute_t {
    /// cutensorAutotuneMode_t: Determines if recurrent executions of the plan (e.g., via cutensorContract, cutensorPermute) should autotune (i.e., try different kernels); see section “Plan Cache” for details.
    CUTENSOR_PLAN_PREFERENCE_AUTOTUNE_MODE = 0,
    /// cutensorCacheMode_t: Determines if the corresponding algorithm/kernel for this plan should be cached and it gives fine control over what is considered a cachehit.
    CUTENSOR_PLAN_PREFERENCE_CACHE_MODE = 1,
    /// int32_t: Only applicable if [`cutensorPlanPreferenceAttribute_t::CUTENSOR_PLAN_PREFERENCE_CACHE_MODE`] is set to [`cutensorAutotuneMode_t::CUTENSOR_AUTOTUNE_MODE_INCREMENTAL`].
    CUTENSOR_PLAN_PREFERENCE_INCREMENTAL_COUNT = 2,
    /// cutensorAlgo_t: Fixes a certain [`cutensorAlgo_t`].
    CUTENSOR_PLAN_PREFERENCE_ALGO = 3,
    /// int32_t: Fixes a kernel (a sub variant of an algo; e.g., kernel_rank==1 while algo == [`cutensorAlgo_t::CUTENSOR_ALGO_TGETT`] would select the second-best GETT kernel/variant according to cuTENSOR’s performance model; kernel_rank==2 would select the third-best).
    CUTENSOR_PLAN_PREFERENCE_KERNEL_RANK = 4,
    /// cutensorJitMode_t: determines if just-in-time compilation is enabled or disabled (default: [`cutensorJitMode_t::CUTENSOR_JIT_MODE_NONE`]).
    CUTENSOR_PLAN_PREFERENCE_JIT = 5,
    /// int32_t: Plan for a specific GPU architecture and not one associated with the context. Value should encode SM version via `10 * SM.major + SM.minor`. Currently only SM versions 80, 90 and 100 are supported.
    CUTENSOR_PLAN_PREFERENCE_GPU_ARCH = 6,
}
/// This enum determines the mode with respect to cuTENSOR’s auto-tuning capability.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorAutotuneMode_t {
    /// Indicates no autotuning (default); in this case the cache will help to reduce the plan-creation overhead. In the case of a cachehit: the cached plan will be reused, otherwise the plancache will be neglected.
    CUTENSOR_AUTOTUNE_MODE_NONE = 0,
    /// Indicates an incremental autotuning (i.e., each invocation of corresponding [`cutensorCreatePlan`] will create a plan based on a different algorithm/kernel; the maximum number of kernels that will be tested is defined by the [`cutensorPlanPreferenceAttribute_t::CUTENSOR_PLAN_PREFERENCE_INCREMENTAL_COUNT`] of [`cutensorPlanPreferenceAttribute_t`]). WARNING: If this autotuning mode is selected, then we cannot guarantee bit-wise identical results (since different algorithms could be executed).
    CUTENSOR_AUTOTUNE_MODE_INCREMENTAL = 1,
}
/// This enum determines the mode with respect to cuTENSOR’s just-in-time compilation capability.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorJitMode_t {
    /// Indicates that no kernel will be just-in-time compiled.
    CUTENSOR_JIT_MODE_NONE = 0,
    /// Indicates that the corresponding plan will try to compile a dedicated kernel for the given operation. Only supported for GPUs with compute capability >= 8.0 (Ampere or newer).
    CUTENSOR_JIT_MODE_DEFAULT = 1,
}
/// This enum defines what is considered a cache hit.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorCacheMode_t {
    /// Plan will not be cached.
    CUTENSOR_CACHE_MODE_NONE = 0,
    /// All parameters of the corresponding descriptor must be identical to the cached plan (default).
    CUTENSOR_CACHE_MODE_PEDANTIC = 1,
}
/// This enum lists all attributes of a [`cutensorPlan_t`] object that can be retrieved via [`cutensorPlanGetAttribute`].
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum cutensorPlanAttribute_t {
    /// uint64_t: exact required workspace in bytes that is needed to execute the plan.
    CUTENSOR_PLAN_REQUIRED_WORKSPACE = 0,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorOperationDescriptor {
    _unused: [u8; 0],
}
/// Opaque structure representing any type of problem descriptor (e.g., contraction, reduction, elementwise).
pub type cutensorOperationDescriptor_t = *mut cutensorOperationDescriptor;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorPlan {
    _unused: [u8; 0],
}
/// Opaque structure representing a plan (e.g, contraction, reduction, elementwise).
pub type cutensorPlan_t = *mut cutensorPlan;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorPlanPreference {
    _unused: [u8; 0],
}
/// Opaque structure that narrows down the space of applicable algorithms/variants/kernels.
pub type cutensorPlanPreference_t = *mut cutensorPlanPreference;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorHandle {
    _unused: [u8; 0],
}
/// Opaque structure holding cuTENSOR’s library context.
pub type cutensorHandle_t = *mut cutensorHandle;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorTensorDescriptor {
    _unused: [u8; 0],
}
/// Opaque structure representing a tensor descriptor.
pub type cutensorTensorDescriptor_t = *mut cutensorTensorDescriptor;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cutensorBlockSparseTensorDescriptor {
    _unused: [u8; 0],
}
/// Opaque structure representing a block-sparse tensor descriptor.
pub type cutensorBlockSparseTensorDescriptor_t = *mut cutensorBlockSparseTensorDescriptor;
/// A function pointer type for logging.
pub type cutensorLoggerCallback_t = ::core::option::Option<
    unsafe extern "C" fn(
        logLevel: i32,
        functionName: *const ::core::ffi::c_char,
        message: *const ::core::ffi::c_char,
    ),
>;
unsafe extern "C" {
    /// Initializes the cuTENSOR library and allocates the memory for the library context.
    ///
    /// The device associated with a particular cuTENSOR handle is assumed to remain unchanged after the [`cutensorCreate`] call. In order for the cuTENSOR library to use a different device, the application must set the new device to be used by calling cudaSetDevice and then create another cuTENSOR handle, which will be associated with the new device, by calling [`cutensorCreate`].
    ///
    /// Moreover, each handle by default has a plan cache that can store the least recently used [`cutensorPlan_t`]; its default capacity is 64, but it can be changed via [`cutensorHandleResizePlanCache`] if this is too little storage space. See the [Plan Cache Guide](https://docs.nvidia.com/cuda/cutensor/2.6.0/plan_cache.html) for more information.
    ///
    /// The user is responsible for calling [`cutensorDestroy`] to free the resources associated with the handle.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorCreate(handle: *mut cutensorHandle_t) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided library handle.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroy(handle: cutensorHandle_t) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Resizes the plan cache.
    ///
    /// This function changes the number of plans that can be stored in the plan cache of the handle.
    ///
    /// Resizing invalidates the cache.
    ///
    /// While this function is not thread-safe, the resulting cache can be shared across different threads in a thread-safe manner.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and not thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context. The cache will be attached to the handle.
    /// - `numEntries`: Number of entries the cache will support.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorHandleResizePlanCache(
        handle: cutensorHandle_t,
        numEntries: u32,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Writes the Plan-Cache (that belongs to the provided handle) to file.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `filename`: Specifies the filename (including the absolute path) to the file that should hold all the cache information. Warning: an existing file will be overwritten.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if the no cache has been attached.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_IO_ERROR`]: if the file cannot be written to.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorHandleWritePlanCacheToFile(
        handle: cutensorHandle_t,
        filename: *const ::core::ffi::c_char,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Reads a Plan-Cache from file and overwrites the cachelines of the provided handle.
    ///
    /// A cache is only valid for the same cuTENSOR version and CUDA version; moreover, the GPU architecture (incl. multiprocessor count) must match, otherwise [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`] will be returned.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `filename`: Specifies the filename (including the absolute path) to the file that holds all the cache information that have previously been written by [`cutensorHandleWritePlanCacheToFile`].
    /// - `numCachelinesRead`: On exit, this variable will hold the number of successfully-read cachelines, if [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`] is returned. Otherwise, this variable will hold the number of cachelines that are required to read all cachelines associated to the cache pointed to by `filename`; in that case [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE`] is returned.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE`]: if the stored cache requires more cachelines than those that are currently attached to the handle.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if the stored cache was created by a different cuTENSOR- or CUDA-version or if the GPU architecture (incl. multiprocessor count) doesn’t match.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_IO_ERROR`]: if the file cannot be read.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorHandleReadPlanCacheFromFile(
        handle: cutensorHandle_t,
        filename: *const ::core::ffi::c_char,
        numCachelinesRead: *mut u32,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Writes the —per library— kernel cache to file.
    ///
    /// Writes the just-in-time compiled kernels to the provided file (those kernels belong to the library—not to the handle).
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `filename`: Specifies the filename (including the absolute path) to the file that should hold all the cache information. Warning: an existing file will be overwritten.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_IO_ERROR`]: if the file cannot be written to.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the function is not available for the operating system, CUDA Toolkit, or compute capability of the device.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully or there were no kernels in the cache.
    pub fn cutensorWriteKernelCacheToFile(
        handle: cutensorHandle_t,
        filename: *const ::core::ffi::c_char,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Reads a kernel cache from file and adds all non-existing JIT compiled kernels to the kernel cache.
    ///
    /// A cache is only valid for the same cuTENSOR version and CUDA version; moreover, the GPU architecture (incl. multiprocessor count) must match, otherwise [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`] will be returned.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `filename`: Specifies the filename (including the absolute path) to the file that holds all the cache information that have previously been written by cutensorWriteKernelCacheToFile.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if the stored cache was created by a different cuTENSOR- or CUDA-version or if the GPU architecture (incl. multiprocessor count) doesn’t match.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_IO_ERROR`]: if the file cannot be read.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the function is not available for the operating system, CUDA Toolkit, or compute capability of the device.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully, or the file pointed to by filename was empty.
    pub fn cutensorReadKernelCacheFromFile(
        handle: cutensorHandle_t,
        filename: *const ::core::ffi::c_char,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Creates a tensor descriptor.
    ///
    /// This allocates a small amount of host-memory.
    ///
    /// The user is responsible for calling [`cutensorDestroyTensorDescriptor`] to free the associated resources once the tensor descriptor is no longer used.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: Pointer to the address where the allocated tensor descriptor object will be stored.
    /// - `numModes`: Number of modes.
    /// - `extent`: Extent of each mode (must be larger than zero).
    /// - `stride`: stride\[i\] denotes the displacement (a.k.a. stride)—in elements of the base type—between two consecutive elements in the ith-mode. If stride is NULL, a packed generalized column-major memory layout is assumed (i.e., the strides increase monotonically from left to right). Each stride must be larger than zero; to be precise, a stride of zero can be achieved by omitting this mode entirely; for instance instead of writing C\[a,b\] = A\[b,a\] with strideA(a) = 0, you can write C\[a,b\] = A\[b\] directly; cuTENSOR will then automatically infer that the a-mode in A should be broadcasted.
    /// - `dataType`: Data type of the stored entries.
    /// - `alignmentRequirement`: Alignment (in bytes) to the base pointer that will be used in conjunction with this tensor descriptor (e.g., `cudaMalloc` has a default alignment of 256 bytes).
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the requested descriptor is not supported (e.g., due to non-supported data type).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorCreateTensorDescriptor(
        handle: cutensorHandle_t,
        desc: *mut cutensorTensorDescriptor_t,
        numModes: u32,
        extent: *const i64,
        stride: *const i64,
        dataType: cudaDataType_t,
        alignmentRequirement: u32,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided tensor descriptor.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroyTensorDescriptor(
        desc: cutensorTensorDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function creates an operation descriptor that encodes an elementwise trinary operation.
    ///
    /// Said trinary operation has the following general form:
    /// $$
    /// D_{\Pi^C(i_0,i_1,...,i_n)} = \Phi_{ABC}(\Phi_{AB}(\alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)}), \beta op_B(B_{\Pi^B(i_0,i_1,...,i_n)})), \gamma op_C(C_{\Pi^C(i_0,i_1,...,i_n)}))
    /// $$
    ///
    /// Where
    ///
    /// * A,B,C,D are multi-mode tensors (of arbitrary data types).
    /// * $\Pi^A, \Pi^B, \Pi^C$ are permutation operators that permute the modes of A, B, and C respectively.
    /// * $op_{A},op_{B},op_{C}$ are unary element-wise operators (e.g., IDENTITY, CONJUGATE).
    /// * $\Phi_{ABC}, \Phi_{AB}$ are binary element-wise operators (e.g., ADD, MUL, MAX, MIN).
    ///
    /// Notice that the broadcasting (of a mode) can be achieved by simply omitting that mode from the respective tensor.
    ///
    /// Moreover, modes may appear in any order, giving users a greater flexibility. The only **restrictions** are:
    ///
    /// * modes that appear in A or B `must` also appear in the output tensor; a mode that only appears in the input would be contracted and such an operation would be covered by either [`cutensorContract`] or [`cutensorReduce`].
    /// * each mode may appear in each tensor at most once.
    ///
    /// Input tensors may be read even if the value of the corresponding scalar is zero.
    ///
    /// Examples:
    ///
    /// * $D_{a,b,c,d} = A_{b,d,a,c}$
    /// * $D_{a,b,c,d} = 2.2 \\* A_{b,d,a,c} + 1.3 \\* B_{c,b,d,a}$
    /// * $D_{a,b,c,d} = 2.2 \\* A_{b,d,a,c} + 1.3 \\* B_{c,b,d,a} + C_{a,b,c,d}$
    /// * $D_{a,b,c,d} = min((2.2 \\* A_{b,d,a,c} + 1.3 \\* B_{c,b,d,a}), C_{a,b,c,d})$
    ///
    /// Call [`cutensorElementwiseTrinaryExecute`] to perform the actual operation.
    ///
    /// Please use [`cutensorDestroyOperationDescriptor`] to deallocated the descriptor once it is no longer used.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeB | typeC | descCompute |
    /// | --- | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_16F`] |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_16BF`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the requested elementwise operation.
    /// - `descA`: A descriptor that holds the information about the data type, modes, and strides of A.
    /// - `modeA`: Array (in host memory) of size descA->numModes that holds the names of the modes of A (e.g., if $A_{a,b,c}$ then modeA = {‘a’,’b’,’c’}). The modeA\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to [`cutensorCreateTensorDescriptor`].
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descB`: A descriptor that holds information about the data type, modes, and strides of B.
    /// - `modeB`: Array (in host memory) of size descB->numModes that holds the names of the modes of B. modeB\[i\] corresponds to extent\[i\] and stride\[i\] of the [`cutensorCreateTensorDescriptor`].
    /// - `opB`: Unary operator that will be applied to each element of B before it is further processed. The original data of this tensor remains unchanged.
    /// - `descC`: A descriptor that holds information about the data type, modes, and strides of C.
    /// - `modeC`: Array (in host memory) of size descC->numModes that holds the names of the modes of C. The modeC\[i\] corresponds to extent\[i\] and stride\[i\] of the [`cutensorCreateTensorDescriptor`].
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
    /// - `descD`: A descriptor that holds information about the data type, modes, and strides of D. Notice that we currently request descD and descC to be identical.
    /// - `modeD`: Array (in host memory) of size descD->numModes that holds the names of the modes of D. The modeD\[i\] corresponds to extent\[i\] and stride\[i\] of the [`cutensorCreateTensorDescriptor`].
    /// - `opAB`: Element-wise binary operator (see $\Phi_{AB}$ above).
    /// - `opABC`: Element-wise binary operator (see $\Phi_{ABC}$ above).
    /// - `descCompute`: Determines the precision in which this operations is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_ARCH_MISMATCH`]: if the device is either not ready, or the target architecture is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorCreateElementwiseTrinary(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descB: cutensorTensorDescriptor_t,
        modeB: *const i32,
        opB: cutensorOperator_t,
        descC: cutensorTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorTensorDescriptor_t,
        modeD: *const i32,
        opAB: cutensorOperator_t,
        opABC: cutensorOperator_t,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Performs an element-wise tensor operation for three input tensors (see [`cutensorCreateElementwiseTrinary`])
    ///
    /// This function performs a element-wise tensor operation of the form:
    /// $$
    /// D_{\Pi^C(i_0,i_1,...,i_n)} = \Phi_{ABC}(\Phi_{AB}(\alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)}), \beta op_B(B_{\Pi^B(i_0,i_1,...,i_n)})), \gamma op_C(C_{\Pi^C(i_0,i_1,...,i_n)}))
    /// $$
    ///
    /// See [`cutensorCreateElementwiseTrinary`] for details.
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding all information about the desired elementwise operation (created by [`cutensorCreateElementwiseTrinary`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling factor for A (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE) to query the expected data type). Pointer to the host memory. If alpha is zero, A is not read and the corresponding unary operator is not applied.
    /// - `A`: Multi-mode tensor (described by `descA` as part of [`cutensorCreateElementwiseTrinary`]). Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `beta`: Scaling factor for B (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE) to query the expected data type). Pointer to the host memory. If beta is zero, B is not read and the corresponding unary operator is not applied.
    /// - `B`: Multi-mode tensor (described by `descB` as part of [`cutensorCreateElementwiseTrinary`]). Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `gamma`: Scaling factor for C (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE) to query the expected data type). Pointer to the host memory. If gamma is zero, C is not read and the corresponding unary operator is not applied.
    /// - `C`: Multi-mode tensor (described by `descC` as part of [`cutensorCreateElementwiseTrinary`]). Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `D`: Multi-mode tensor (described by `descD` as part of [`cutensorCreateElementwiseTrinary`]). Pointer to the GPU-accessible memory (`C` and `D` may be identical, if and only if `descC == descD`).
    /// - `stream`: The CUDA stream used to perform the operation.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorElementwiseTrinaryExecute(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        beta: *const ::core::ffi::c_void,
        B: *const ::core::ffi::c_void,
        gamma: *const ::core::ffi::c_void,
        C: *const ::core::ffi::c_void,
        D: *mut ::core::ffi::c_void,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function creates an operation descriptor for an elementwise binary operation.
    ///
    /// The binary operation has the following general form:
    /// $$
    /// D_{\Pi^C(i_0,i_1,...,i_n)} = \Phi_{AC}(\alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)}), \gamma op_C(C_{\Pi^C(i_0,i_1,...,i_n)}))
    /// $$
    ///
    /// Call [`cutensorElementwiseBinaryExecute`] to perform the actual operation.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeC | descCompute |
    /// | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_16F`] |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_16BF`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the requested elementwise operation.
    /// - `descA`: The descriptor that holds the information about the data type, modes, and strides of A.
    /// - `modeA`: Array (in host memory) of size descA->numModes that holds the names of the modes of A (e.g., if A_{a,b,c} => modeA = {‘a’,’b’,’c’}). The modeA\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to [`cutensorCreateTensorDescriptor`].
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descC`: The descriptor that holds information about the data type, modes, and strides of C.
    /// - `modeC`: Array (in host memory) of size descC->numModes that holds the names of the modes of C. The modeC\[i\] corresponds to extent\[i\] and stride\[i\] of the [`cutensorCreateTensorDescriptor`].
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
    /// - `descD`: The descriptor that holds information about the data type, modes, and strides of D. Notice that we currently request descD and descC to be identical.
    /// - `modeD`: Array (in host memory) of size descD->numModes that holds the names of the modes of D. The modeD\[i\] corresponds to extent\[i\] and stride\[i\] of the [`cutensorCreateTensorDescriptor`].
    /// - `opAC`: Element-wise binary operator (corresponding to $\Phi_{AC}$ above).
    /// - `descCompute`: Determines the precision in which this operations is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorCreateElementwiseBinary(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descC: cutensorTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorTensorDescriptor_t,
        modeD: *const i32,
        opAC: cutensorOperator_t,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Performs an element-wise tensor operation for two input tensors (see [`cutensorCreateElementwiseBinary`])
    ///
    /// This function performs a element-wise tensor operation of the form:
    /// $$
    /// D_{\Pi^C(i_0,i_1,...,i_n)} = \Phi_{AC}(\alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)}), \gamma op_C(C_{\Pi^C(i_0,i_1,...,i_n)}))
    /// $$
    ///
    /// See [`cutensorCreateElementwiseBinary`] for details.
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding all information about the desired elementwise operation (created by [`cutensorCreateElementwiseBinary`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling factor for A (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE) to query the expected data type). Pointer to the host memory. If alpha is zero, A is not read and the corresponding unary operator is not applied.
    /// - `A`: Multi-mode tensor (described by `descA` as part of [`cutensorCreateElementwiseBinary`]). Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `gamma`: Scaling factor for C (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE) to query the expected data type). Pointer to the host memory. If gamma is zero, C is not read and the corresponding unary operator is not applied.
    /// - `C`: Multi-mode tensor (described by `descC` as part of [`cutensorCreateElementwiseBinary`]). Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `D`: Multi-mode tensor (described by `descD` as part of [`cutensorCreateElementwiseBinary`]). Pointer to the GPU-accessible memory (`C` and `D` may be identical, if and only if `descC == descD`).
    /// - `stream`: The CUDA stream used to perform the operation.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorElementwiseBinaryExecute(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        gamma: *const ::core::ffi::c_void,
        C: *const ::core::ffi::c_void,
        D: *mut ::core::ffi::c_void,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function creates an operation descriptor for a tensor permutation.
    ///
    /// The tensor permutation has the following general form:
    /// $$
    /// B_{\Pi^B(i_0,i_1,...,i_n)} = \alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)})
    /// $$
    ///
    /// Consequently, this function performs an out-of-place tensor permutation and is a specialization of [`cutensorCreateElementwiseBinary`].
    ///
    /// Where
    ///
    /// * A and B are multi-mode tensors (of arbitrary data types),
    /// * $\Pi^A, \Pi^B$ are permutation operators that permute the modes of A, B respectively,
    /// * $op_A$ is an unary element-wise operators (e.g., IDENTITY, SQR, CONJUGATE), and
    ///
    /// Broadcasting (of a mode) can be achieved by simply omitting that mode from the respective tensor.
    ///
    /// Modes may appear in any order. The only **restrictions** are:
    ///
    /// * modes that appear in A `must` also appear in the output tensor.
    /// * each mode may appear in each tensor at most once.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeB | descCompute |
    /// | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_16F`] |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_16BF`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the requested permutation.
    /// - `descA`: The descriptor that holds information about the data type, modes, and strides of A.
    /// - `modeA`: Array of size descA->numModes that holds the names of the modes of A (e.g., if A_{a,b,c} => modeA = {‘a’,’b’,’c’}).
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descB`: The descriptor that holds information about the data type, modes, and strides of B.
    /// - `modeB`: Array of size descB->numModes that holds the names of the modes of B.
    /// - `descCompute`: Determines the precision in which this operations is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorCreatePermutation(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descB: cutensorTensorDescriptor_t,
        modeB: *const i32,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Performs the tensor permutation that is encoded by `plan` (see [`cutensorCreatePermutation`]).
    ///
    /// This function performs an elementwise tensor operation of the form:
    /// $$
    /// B_{\Pi^B(i_0,i_1,...,i_n)} = \alpha op_A(A_{\Pi^A(i_0,i_1,...,i_n)})
    /// $$
    ///
    /// Consequently, this function performs an out-of-place tensor permutation.
    ///
    /// Where
    ///
    /// * A and B are multi-mode tensors (of arbitrary data types),
    /// * $\Pi^A, \Pi^B$ are permutation operators that permute the modes of A, B respectively,
    /// * $op_A$ is an unary element-wise operators (e.g., IDENTITY, SQR, CONJUGATE), and is specified when creating the operation descriptor using [`cutensorCreatePermutation`]
    ///
    /// Remark
    ///
    /// calls asynchronous functions, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding all information about the desired tensor reduction (created by [`cutensorCreatePermutation`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling factor for A (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory. If alpha is zero, A is not read and the corresponding unary operator is not applied.
    /// - `A`: Multi-mode tensor of type typeA with nmodeA modes. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `B`: Multi-mode tensor of type typeB with nmodeB modes. Pointer to the GPU-accessible memory.
    /// - `stream`: The CUDA stream.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorPermute(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        B: *mut ::core::ffi::c_void,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function allocates a cutensorOperationDescriptor_t object that encodes a tensor contraction of the form $D = \alpha \mathcal{A} \mathcal{B} + \beta \mathcal{C}$.
    ///
    /// Allocates data for `desc` to be used to perform a tensor contraction of the form:
    /// $$
    /// \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha op_\mathcal{A}(\mathcal{A}_{{modes}_\mathcal{A}}) op_\mathcal{B}(B_{{modes}_\mathcal{B}}) + \beta op_\mathcal{C}(\mathcal{C}_{{modes}_\mathcal{C}}).
    /// $$
    ///
    /// See [`cutensorCreatePlan`] (or cutensorCreatePlanAutotuned) to create the plan (i.e., to select the kernel) followed by a call to [`cutensorContract`] to perform the actual contraction.
    ///
    /// The user is responsible for calling [`cutensorDestroyOperationDescriptor`] to free the resources associated with the descriptor.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeB | typeC | descCompute | typeScalar | Tensor Core |
    /// | --- | --- | --- | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_R_32F`] | Volta+ |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_R_32F`] | No |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_TF32`] | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_3XTF32`] | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_16BF`] | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_16F`] | [`cudaDataType_t::CUDA_R_32F`] | Volta+ |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_R_64F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_R_64F`] | No |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_C_32F`] | No |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_TF32`] | [`cudaDataType_t::CUDA_C_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_3XTF32`] | [`cudaDataType_t::CUDA_C_32F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_C_64F`] | Ampere+ |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_C_64F`] | No |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_C_64F`] | No |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_C_64F`] | No |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_8XINT8`] | [`cudaDataType_t::CUDA_R_64F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_8XINT8`] | [`cudaDataType_t::CUDA_C_64F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_9X16BF`] | [`cudaDataType_t::CUDA_R_32F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_9X16BF`] | [`cudaDataType_t::CUDA_C_32F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_4X16F`] | [`cudaDataType_t::CUDA_R_32F`] | Blackwell+ |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_4X16F`] | [`cudaDataType_t::CUDA_C_32F`] | Blackwell+ |
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the tensor contraction operation.
    /// - `descA`: The descriptor that holds the information about the data type, modes and strides of A.
    /// - `modeA`: Array with ‘nmodeA’ entries that represent the modes of A. The modeA\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descB`: The descriptor that holds information about the data type, modes, and strides of B.
    /// - `modeB`: Array with ‘nmodeB’ entries that represent the modes of B. The modeB\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opB`: Unary operator that will be applied to each element of B before it is further processed. The original data of this tensor remains unchanged.
    /// - `descC`: The escriptor that holds information about the data type, modes, and strides of C.
    /// - `modeC`: Array with ‘nmodeC’ entries that represent the modes of C. The modeC\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
    /// - `descD`: The descriptor that holds information about the data type, modes, and strides of D (must be identical to `descC` for now).
    /// - `modeD`: Array with ‘nmodeD’ entries that represent the modes of D (must be identical to modeC for now). The modeD\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `descCompute`: Determines the precision in which this operations is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorCreateContraction(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descB: cutensorTensorDescriptor_t,
        modeB: *const i32,
        opB: cutensorOperator_t,
        descC: cutensorTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorTensorDescriptor_t,
        modeD: *const i32,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided descriptor.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroyOperationDescriptor(
        desc: cutensorOperationDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Set attribute of a cutensorOperationDescriptor_t object.
    ///
    /// Currently not supported for blocksparse contraction descriptors.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: Operation descriptor that will be modified.
    /// - `attr`: Specifies the attribute that will be set.
    /// - `buf`: This buffer (of size `sizeInBytes`) determines the value to which `attr` will be set.
    /// - `sizeInBytes`: Size of buf (in bytes).
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorOperationDescriptorSetAttribute(
        handle: cutensorHandle_t,
        desc: cutensorOperationDescriptor_t,
        attr: cutensorOperationDescriptorAttribute_t,
        buf: *const ::core::ffi::c_void,
        sizeInBytes: size_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function retrieves an attribute of the provided cutensorOperationDescriptor_t object (see [`cutensorOperationDescriptorAttribute_t`]).
    ///
    /// Block-sparse contraction descriptors only support the attributes [`cutensorOperationDescriptorAttribute_t::CUTENSOR_OPERATION_DESCRIPTOR_SCALAR_TYPE`] and [`cutensorOperationDescriptorAttribute_t::CUTENSOR_OPERATION_DESCRIPTOR_MOVED_BYTES`].
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: The cutensorOperationDescriptor_t object whos attribute is queried.
    /// - `attr`: Specifies the attribute that will be retrieved.
    /// - `buf`: This buffer (of size sizeInBytes) will hold the requested attribute of the provided cutensorOperationDescriptor_t object.
    /// - `sizeInBytes`: Size of buf (in bytes); see [`cutensorOperationDescriptorAttribute_t`] for the exact size.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorOperationDescriptorGetAttribute(
        handle: cutensorHandle_t,
        desc: cutensorOperationDescriptor_t,
        attr: cutensorOperationDescriptorAttribute_t,
        buf: *mut ::core::ffi::c_void,
        sizeInBytes: size_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Allocates the cutensorPlanPreference_t, enabling users to limit the applicable kernels for a given plan/operation.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `pref`: Pointer to the structure holding the [`cutensorPlanPreference_t`] allocated by this function. See [`cutensorPlanPreference_t`].
    /// - `algo`: Allows users to select a specific algorithm. [`cutensorAlgo_t::CUTENSOR_ALGO_DEFAULT`] lets the heuristic choose the algorithm. Any value >= 0 selects a specific GEMM-like algorithm and deactivates the heuristic. If a specified algorithm is not supported [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`] is returned. See [`cutensorAlgo_t`] for additional choices.
    /// - `jitMode`: Determines if cuTENSOR is allowed to use JIT-compiled kernels (leading to a longer plan-creation phase); see [`cutensorJitMode_t`].
    pub fn cutensorCreatePlanPreference(
        handle: cutensorHandle_t,
        pref: *mut cutensorPlanPreference_t,
        algo: cutensorAlgo_t,
        jitMode: cutensorJitMode_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided preference.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroyPlanPreference(
        pref: cutensorPlanPreference_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Get attribute of a cutensorPlanPreference_t object.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `pref`: This opaque struct restricts the search space of viable candidates.
    /// - `attr`: Requested attribute.
    /// - `buf`: On successful exit: Holds the information of the requested attribute.
    /// - `sizeInBytes`: Size of buf (in bytes); see [`cutensorPlanPreferenceAttribute_t`] for the exact size.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorPlanPreferenceGetAttribute(
        handle: cutensorHandle_t,
        pref: cutensorPlanPreference_t,
        attr: cutensorPlanPreferenceAttribute_t,
        buf: *mut ::core::ffi::c_void,
        sizeInBytes: size_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Set attribute of a cutensorPlanPreference_t object.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `pref`: This opaque struct restricts the search space of viable candidates.
    /// - `attr`: Specifies the attribute that will be set.
    /// - `buf`: This buffer (of size sizeInBytes) determines the value to which `attr` will be set.
    /// - `sizeInBytes`: Size of buf (in bytes); see [`cutensorPlanPreferenceAttribute_t`] for the exact size.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorPlanPreferenceSetAttribute(
        handle: cutensorHandle_t,
        pref: cutensorPlanPreference_t,
        attr: cutensorPlanPreferenceAttribute_t,
        buf: *const ::core::ffi::c_void,
        sizeInBytes: size_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Retrieves information about an already-created plan (see [`cutensorPlanAttribute_t`])
    ///
    /// Block-sparse contraction plans only support [`cutensorPlanAttribute_t::CUTENSOR_PLAN_REQUIRED_WORKSPACE`].
    ///
    /// # Parameters
    ///
    /// - `plan`: Denotes an already-created plan (e.g., via [`cutensorCreatePlan`] or cutensorCreatePlanAutotuned).
    /// - `attr`: Requested attribute.
    /// - `buf`: On successful exit: Holds the information of the requested attribute.
    /// - `sizeInBytes`: size of `buf` in bytes.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorPlanGetAttribute(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        attr: cutensorPlanAttribute_t,
        buf: *mut ::core::ffi::c_void,
        sizeInBytes: size_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Determines the required workspaceSize for the given operation encoded by `desc`.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct encodes the operation.
    /// - `planPref`: This opaque struct restricts the space of viable candidates.
    /// - `workspacePref`: This parameter influences the size of the workspace; see [`cutensorWorksizePreference_t`] for details.
    /// - `workspaceSizeEstimate`: The workspace size (in bytes) that is required for the given operation.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorEstimateWorkspaceSize(
        handle: cutensorHandle_t,
        desc: cutensorOperationDescriptor_t,
        planPref: cutensorPlanPreference_t,
        workspacePref: cutensorWorksizePreference_t,
        workspaceSizeEstimate: *mut u64,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function allocates a cutensorPlan_t object, selects an appropriate kernel for a given operation (encoded by `desc`) and prepares a plan that encodes the execution.
    ///
    /// This function applies cuTENSOR’s heuristic to select a candidate/kernel for a given operation (created by either [`cutensorCreateContraction`], [`cutensorCreateReduction`], [`cutensorCreatePermutation`], [`cutensorCreateElementwiseBinary`], [`cutensorCreateElementwiseTrinary`], [`cutensorCreateContractionTrinary`], or [`cutensorCreateBlockSparseContraction`]). The created plan can then be passed to either [`cutensorContract`], [`cutensorReduce`], [`cutensorPermute`], [`cutensorElementwiseBinaryExecute`], [`cutensorElementwiseTrinaryExecute`], or [`cutensorContractTrinary`] to perform the actual operation.
    ///
    /// The plan is created for the active CUDA device.
    ///
    /// Note: [`cutensorCreatePlan`] must not be captured via CUDA graphs if Just-In-Time compilation is enabled (i.e., [`cutensorJitMode_t`] is not [`cutensorJitMode_t::CUTENSOR_JIT_MODE_NONE`]).
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Pointer to the data structure created by this function that holds all information (e.g., selected kernel) necessary to perform the desired operation.
    /// - `desc`: This opaque struct encodes the given operation (see [`cutensorCreateContraction`], [`cutensorCreateReduction`], [`cutensorCreatePermutation`], [`cutensorCreateElementwiseBinary`], [`cutensorCreateElementwiseTrinary`], or [`cutensorCreateContractionTrinary`]).
    /// - `pref`: This opaque struct is used to restrict the space of applicable candidates/kernels (see [`cutensorCreatePlanPreference`] or [`cutensorPlanPreferenceAttribute_t`]). May be `nullptr`, in that case default choices are assumed. Block-sparse contractions currently only support these default settings and ignore other supplied preferences.
    /// - `workspaceSizeLimit`: Denotes the maximal workspace that the corresponding operation is allowed to use (see [`cutensorEstimateWorkspaceSize`]).
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE`]: if the provided workspace was insufficient.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: If no viable candidate could be found.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: If a viable candidate has been found.
    pub fn cutensorCreatePlan(
        handle: cutensorHandle_t,
        plan: *mut cutensorPlan_t,
        desc: cutensorOperationDescriptor_t,
        pref: cutensorPlanPreference_t,
        workspaceSizeLimit: u64,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided plan.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroyPlan(plan: cutensorPlan_t) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This routine computes the tensor contraction $D = alpha \\* A \\* B + beta \\* C$.
    /// $$
    /// \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha \\* \mathcal{A}_{{modes}_\mathcal{A}} B_{{modes}_\mathcal{B}} + \beta \mathcal{C}_{{modes}_\mathcal{C}}
    /// $$
    ///
    /// The active CUDA device must match the CUDA device that was active at the time at which the plan was created.
    ///
    /// **\[Example\]**
    /// :   See [NVIDIA/CUDALibrarySamples](https://github.com/NVIDIA/CUDALibrarySamples/tree/master/cuTENSOR/contraction.cu) for a concrete example.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding the contraction execution plan (created by [`cutensorCreateContraction`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling for A\*B. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `A`: Pointer to the data corresponding to A. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `B`: Pointer to the data corresponding to B. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `beta`: Scaling for C. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `C`: Pointer to the data corresponding to C. Pointer to the GPU-accessible memory.
    /// - `D`: Pointer to the data corresponding to D. Pointer to the GPU-accessible memory.
    /// - `workspace`: Optional parameter that may be NULL. This pointer provides additional workspace, in device memory, to the library for additional optimizations; the workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
    /// - `workspaceSize`: Size of the workspace array in bytes; please refer to [`cutensorEstimateWorkspaceSize`] to query the required workspace. While [`cutensorContract`] does not strictly require a workspace for the contraction, it is still recommended to provide some small workspace (e.g., 128 MB).
    /// - `stream`: The CUDA stream in which all the computation is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_ARCH_MISMATCH`]: if the plan was created for a different device than the currently active device.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_CUDA_ERROR`]: if some unknown CUDA error has occurred (e.g., out of memory).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_DRIVER`]: if the driver is insufficient.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if operation is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorContract(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        B: *const ::core::ffi::c_void,
        beta: *const ::core::ffi::c_void,
        C: *const ::core::ffi::c_void,
        D: *mut ::core::ffi::c_void,
        workspace: *mut ::core::ffi::c_void,
        workspaceSize: u64,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Creates a cutensorOperatorDescriptor_t object that encodes a tensor reduction of the form $D = alpha \\* opReduce(opA(A)) + beta \\* opC(C)$.
    ///
    /// For example this function enables users to reduce an entire tensor to a scalar: C[] = alpha \* A\[i,j,k\];
    ///
    /// This function is also able to perform partial reductions; for instance: C\[i,j\] = alpha \* A\[k,j,i\]; in this case only elements along the k-mode are contracted.
    ///
    /// The binary opReduce operator provides extra control over what kind of a reduction ought to be performed. For instance, setting opReduce to [`cutensorOperator_t::CUTENSOR_OP_ADD`] reduces element of A via a summation while [`cutensorOperator_t::CUTENSOR_OP_MAX`] would find the largest element in A.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeB | typeC | typeCompute |
    /// | --- | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_16F`] |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_16BF`] |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the requested tensor reduction operation.
    /// - `descA`: The descriptor that holds the information about the data type, modes and strides of A.
    /// - `modeA`: Array with ‘nmodeA’ entries that represent the modes of A. modeA\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to [`cutensorCreateTensorDescriptor`]. Modes that only appear in modeA but not in modeC are reduced (contracted).
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descC`: The descriptor that holds the information about the data type, modes and strides of C.
    /// - `modeC`: Array with ‘nmodeC’ entries that represent the modes of C. modeC\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to [`cutensorCreateTensorDescriptor`].
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
    /// - `descD`: Must be identical to descC for now.
    /// - `modeD`: Must be identical to modeC for now.
    /// - `opReduce`: binary operator used to reduce elements of A.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if operation is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorCreateReduction(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descC: cutensorTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorTensorDescriptor_t,
        modeD: *const i32,
        opReduce: cutensorOperator_t,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Performs the tensor reduction that is encoded by `plan` (see [`cutensorCreateReduction`]).
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding the reduction execution plan (created by [`cutensorCreateReduction`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling for A. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `A`: Pointer to the data corresponding to A in device memory. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to D.
    /// - `beta`: Scaling for C. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `C`: Pointer to the data corresponding to C in device memory. Pointer to the GPU-accessible memory.
    /// - `D`: Pointer to the data corresponding to C in device memory. Pointer to the GPU-accessible memory.
    /// - `workspace`: Scratchpad (device) memory of size —at least— `workspaceSize` bytes; the workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
    /// - `workspaceSize`: Please use [`cutensorEstimateWorkspaceSize`] to query the required workspace.
    /// - `stream`: The CUDA stream in which all the computation is performed.
    pub fn cutensorReduce(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        beta: *const ::core::ffi::c_void,
        C: *const ::core::ffi::c_void,
        D: *mut ::core::ffi::c_void,
        workspace: *mut ::core::ffi::c_void,
        workspaceSize: u64,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function allocates a cutensorOperationDescriptor_t object that encodes a tensor contraction of the form $\mathcal{E} = \alpha \mathcal{A} \mathcal{B} \mathcal{C} + \beta \mathcal{D}$.
    ///
    /// Allocates data for `desc` to be used to perform a tensor contraction of the form:
    /// $$
    /// \mathcal{E}_{{modes}_\mathcal{E}} \gets \alpha op_\mathcal{A}(\mathcal{A}_{{modes}_\mathcal{A}}) op_\mathcal{B}(\mathcal{B}_{{modes}_\mathcal{B}}) op_\mathcal{C}(\mathcal{C}_{{modes}_\mathcal{C}}) + \beta op_\mathcal{D}(\mathcal{D}_{{modes}_\mathcal{D}}).
    /// $$
    ///
    /// See [`cutensorCreatePlan`] (or cutensorCreatePlanAutotuned) to create the plan (i.e., to select the kernel) followed by a call to [`cutensorContractTrinary`] to perform the actual contraction.
    ///
    /// The user is responsible for calling [`cutensorDestroyOperationDescriptor`] to free the resources associated with the descriptor.
    ///
    /// The performance improvements due to this API are currently especially high if your data resides on the host (i.e. out-of-core), targeting Grace-based systems.
    ///
    /// Supported data-type combinations are:
    ///
    /// | typeA | typeB | typeC | typeD | descCompute |  | typeScalar | Tensor Core |  |
    /// | --- | --- | --- | --- | --- | --- | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`cudaDataType_t::CUDA_R_16F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_R_32F`] | Volta+ |  |
    /// | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`cudaDataType_t::CUDA_R_16BF`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_R_32F`] | No |  |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_TF32`] |  | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_3XTF32`] |  | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_16BF`] |  | [`cudaDataType_t::CUDA_R_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_16F`] |  | [`cudaDataType_t::CUDA_R_32F`] | Volta+ |  |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |  | [`cudaDataType_t::CUDA_R_64F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_R_64F`] | No |  |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_C_32F`] | No |  |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_TF32`] |  | [`cudaDataType_t::CUDA_C_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_3XTF32`] |  | [`cudaDataType_t::CUDA_C_32F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] |  | [`cudaDataType_t::CUDA_C_64F`] | Ampere+ |  |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_32F`] |  | [`cudaDataType_t::CUDA_C_64F`] | No |  |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_8XINT8`] |  |  | [`cudaDataType_t::CUDA_R_64F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_8XINT8`] |  |  | [`cudaDataType_t::CUDA_C_64F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_9X16BF`] |  |  | [`cudaDataType_t::CUDA_R_32F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_9X16BF`] |  |  | [`cudaDataType_t::CUDA_C_32F`] | Hopper+ |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_4X16F`] |  |  | [`cudaDataType_t::CUDA_R_32F`] | Blackwell+ |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_4X16F`] |  |  | [`cudaDataType_t::CUDA_C_32F`] | Blackwell+ |
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the tensor contraction operation.
    /// - `descA`: The descriptor that holds the information about the data type, modes and strides of A.
    /// - `modeA`: Array with ‘nmodeA’ entries that represent the modes of A. The modeA\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
    /// - `descB`: The descriptor that holds information about the data type, modes, and strides of B.
    /// - `modeB`: Array with ‘nmodeB’ entries that represent the modes of B. The modeB\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opB`: Unary operator that will be applied to each element of B before it is further processed. The original data of this tensor remains unchanged.
    /// - `descC`: The escriptor that holds information about the data type, modes, and strides of C.
    /// - `modeC`: Array with ‘nmodeC’ entries that represent the modes of C. The modeC\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
    /// - `descD`: The escriptor that holds information about the data type, modes, and strides of D.
    /// - `modeD`: Array with ‘nmodeD’ entries that represent the modes of D. The modeD\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `opD`: Unary operator that will be applied to each element of D before it is further processed. The original data of this tensor remains unchanged.
    /// - `descE`: The descriptor that holds information about the data type, modes, and strides of E (must be identical to `descD` for now).
    /// - `modeE`: Array with ‘nmodeE’ entries that represent the modes of E (must be identical to modeD for now). The modeE\[i\] corresponds to extent\[i\] and stride\[i\] with respect to the arguments provided to cutensorInitTensorDescriptor.
    /// - `descCompute`: Determines the precision in which this operations is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorCreateContractionTrinary(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descB: cutensorTensorDescriptor_t,
        modeB: *const i32,
        opB: cutensorOperator_t,
        descC: cutensorTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorTensorDescriptor_t,
        modeD: *const i32,
        opD: cutensorOperator_t,
        descE: cutensorTensorDescriptor_t,
        modeE: *const i32,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This routine computes the tensor contraction $E = alpha \\* A \\* B \\* C + beta \\* D$.
    /// $$
    /// \mathcal{E}_{{modes}_\mathcal{E}} \gets \alpha \\* \mathcal{A}_{{modes}_\mathcal{A}} \mathcal{B}_{{modes}_\mathcal{B}} \mathcal{C}_{{modes}_\mathcal{C}} + \beta \mathcal{D}_{{modes}_\mathcal{D}}
    /// $$
    ///
    /// The active CUDA device must match the CUDA device that was active at the time at which the plan was created.
    ///
    /// **\[Example\]**
    /// :   See [NVIDIA/CUDALibrarySamples](https://github.com/NVIDIA/CUDALibrarySamples/tree/master/cuTENSOR/contraction_trinary.cu) for a concrete example.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding the contraction execution plan (created by [`cutensorCreateContractionTrinary`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling for A\*B\*C. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `A`: Pointer to the data corresponding to A. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
    /// - `B`: Pointer to the data corresponding to B. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
    /// - `C`: Pointer to the data corresponding to C. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
    /// - `beta`: Scaling for D. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
    /// - `D`: Pointer to the data corresponding to D. Pointer to the GPU-accessible memory.
    /// - `E`: Pointer to the data corresponding to E. Pointer to the GPU-accessible memory.
    /// - `workspace`: Optional parameter that may be NULL. This pointer provides additional workspace, in device memory, to the library for additional optimizations; the workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
    /// - `workspaceSize`: Size of the workspace array in bytes; please refer to [`cutensorEstimateWorkspaceSize`] to query the required workspace. While [`cutensorContract`] does not strictly require a workspace for the contraction, it is still recommended to provide some small workspace (e.g., 128 MB).
    /// - `stream`: The CUDA stream in which all the computation is performed.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_ARCH_MISMATCH`]: if the plan was created for a different device than the currently active device.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_CUDA_ERROR`]: if some unknown CUDA error has occurred (e.g., out of memory).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_DRIVER`]: if the driver is insufficient.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if operation is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorContractTrinary(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const ::core::ffi::c_void,
        B: *const ::core::ffi::c_void,
        C: *const ::core::ffi::c_void,
        beta: *const ::core::ffi::c_void,
        D: *const ::core::ffi::c_void,
        E: *mut ::core::ffi::c_void,
        workspace: *mut ::core::ffi::c_void,
        workspaceSize: u64,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Create a block-sparse tensor descriptor.
    ///
    /// A block-sparse tensor descriptor fully specifies the data layout of a block-sparse tensor (currently limited to up to 8 modes).
    ///
    /// Let us consider an example for a block-sparse tensor of order 2, i.e., a block-sparse matrix `A`. Its first mode (`rows`) is subdivided into 5 sections (with extents 4, 2, 3, 4, 5, respectively), and its second mode (`columns`) is subdivided into 3 sections (with extents 2, 3, 7). The matrix has 8 non-zero blocks:
    ///
    /// |  |  |  |
    /// | --- | --- | --- |
    /// | 4 x 2 |  | 4 x 7 |
    /// |  | 2 x 3 |  |
    /// |  | 3 x 3 | 3 x 7 |
    /// | 4 x 2 |  |  |
    /// |  | 5 x 3 | 5 x 7 |
    ///
    /// Notice that we require the same extent of each sub section across the entire mode, i.e., every block within the same section of a mode has the same extent. For example, in the above picture every block on the right has 7 colums, and all blocks on the bottom have 5 rows.
    ///
    /// Moreover, we only store the non-zero blocks (blocks that are zero are left blank in the above representation).
    ///
    /// To be precise, the above block-sparse tensor could be created via:
    ///
    /// As an example:
    ///
    /// * strides of block #0: 5, 1, 10, 20. Sorted strides would be: 1, 5, 10, 20. The permutation to sort the strides in this case is to swap the first two elements.
    /// * strides of block #1: 10, 1, 30, 60. Applying the permutation would result in: 1, 10, 30, 60. The result is sorted in ascending order, this is allowed.
    /// * strides of block #2: 1, 5, 50, 100. Applying permuation would result in: 5, 1, 50, 100. The result is `not` sorted in ascending order, this is `not` allowed.
    ///
    ///   Remark
    ///
    ///   non-blocking, no reentrant, and thread-safe.
    ///
    /// # Parameters
    ///
    /// - `handle`: The library handle.
    /// - `desc`: The resulting block-sparse tensor descriptor.
    /// - `numModes`: The number of modes. Currently, a maximum of 8 modes is supported.
    /// - `numNonZeroBlocks`: The number of non-zero blocks in the block-sparse tensor.
    /// - `numSectionsPerMode`: The number of sections of each mode (host array of size `numModes`).
    /// - `extent`: The extents of the sections of each mode (host array of size `\sum_i^numModes(numSectionsPerMode\[i\])`). First come the extents of the sections of the first mode, then the extents of the sections of the second mode, and so forth.
    /// - `nonZeroCoordinates`: Block-coordinates of each non-zero block (host array of size `numModes` x `numNonZeroBlocks` Blocks can be specified in any order, however, that order must be consistent with stride and alignmentRequirement arrays.
    /// - `stride`: The strides of each dense block (either nullptr or a host array of size `numModes` x `numNonZeroBlocks`). First the strides of the first block, then the strides of the second block, with the blocks in the same order as in nonZeroCoordinates. Passing nullptr means contiguous column-major order for each block. Moreover, the strides need to be compatible in the following sense: Suppose you sort the strides of the first block, such that they are ascending; this sorting results in a permutation. If you apply this permutation to the strides of any other block, the result needs to be sorted as well.
    /// - `dataType`: Data type of the stored entries. We assume the same datatype for each block. Currently, the only supported values are [`cudaDataType_t::CUDA_C_64F`], [`cudaDataType_t::CUDA_C_32F`], [`cudaDataType_t::CUDA_R_64F`], and [`cudaDataType_t::CUDA_R_32F`].
    pub fn cutensorCreateBlockSparseTensorDescriptor(
        handle: cutensorHandle_t,
        desc: *mut cutensorBlockSparseTensorDescriptor_t,
        numModes: u32,
        numNonZeroBlocks: u64,
        numSectionsPerMode: *const u32,
        extent: *const i64,
        nonZeroCoordinates: *const i32,
        stride: *const i64,
        dataType: cudaDataType_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Frees all resources related to the provided block-sparse tensor descriptor.
    ///
    /// Remark
    ///
    /// blocking, no reentrant, and thread-safe.
    pub fn cutensorDestroyBlockSparseTensorDescriptor(
        desc: cutensorBlockSparseTensorDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function allocates a cutensorOperationDescriptor_t object that encodes a block-sparse tensor contraction of the form $D = \alpha \mathcal{A} \mathcal{B} + \beta \mathcal{C}$.
    ///
    /// Allocates data for `desc` to be used to perform a block-sparse tensor contraction of the form:
    /// $$
    /// \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha op_\mathcal{A}(\mathcal{A}_{{modes}_\mathcal{A}}) op_\mathcal{B}(B_{{modes}_\mathcal{B}}) + \beta op_\mathcal{C}(\mathcal{C}_{{modes}_\mathcal{C}}).
    /// $$
    ///
    /// Only the predefined non-zero blocks of $\mathcal{D}$ that were specified in [`cutensorCreateBlockSparseTensorDescriptor`] are actually computed. The other blocks are omitted, even if the true result of the contraction would be non-zero. Conversely, if a predefined non-zero block of $\mathcal{D}$ is present, but the result of the contraction is zero for this block, explicit zeros will be stored.
    ///
    /// Currently, the data-types for the tensors `A`, `B`, `C`, and `D`, as well as the scalars $\alpha$ and $\beta$ must all be identical, and the only supported types are [`cudaDataType_t::CUDA_C_64F`], [`cudaDataType_t::CUDA_C_32F`], [`cudaDataType_t::CUDA_R_64F`], and [`cudaDataType_t::CUDA_R_32F`]. The compute-type needs to match as well, that is, we currently only support:
    ///
    /// | typeA | typeB | typeC | typeD | descCompute | typeScalar |
    /// | --- | --- | --- | --- | --- | --- |
    /// | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`cudaDataType_t::CUDA_R_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_R_32F`] |
    /// | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`cudaDataType_t::CUDA_R_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_R_64F`] |
    /// | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`cudaDataType_t::CUDA_C_32F`] | [`CUTENSOR_COMPUTE_DESC_32F`] | [`cudaDataType_t::CUDA_C_32F`] |
    /// | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`cudaDataType_t::CUDA_C_64F`] | [`CUTENSOR_COMPUTE_DESC_64F`] | [`cudaDataType_t::CUDA_C_64F`] |
    ///
    /// For every mode, the segmentation of that mode must be identical in all tensors that it occurs in. For example, if modeA\[i\] = modeB\[j\] for some i and j, then numSectionsPerMode\[i\] of tensor A must have the same value as numSectionsPerMode\[j\] of tensor B, and the corresponding section extents must be identical.
    ///
    /// For example, let A, B, and C be block matrices and consider the ordinary matrix-matrix product $C_{mn}=A_{mk}B_{kn}$. Then:
    ///
    /// * Mode ‘m’: C and A need to have the same number of block-rows, and each block-row of C needs to contain the same number of rows as the corresponding block-row of A.
    /// * Mode ‘n’: C and B need to have the same number of block-columns of matching size
    /// * Mode ‘k’: A needs to have the same number of block-columns as B has block-rows, and each block-column of A needs to consist of the same number of columns as the number of rows in the corresponding block-row of B.
    ///
    /// At the moment, descC and descD must be identical, i.e., the same opaque pointer needs to be passed and the layouts of the C and the D tensors need to be identical.
    ///
    /// See [`cutensorCreatePlan`] to create the plan, [`cutensorEstimateWorkspaceSize`] to compute the required workspace, and finally [`cutensorBlockSparseContract`] to perform the actual contraction.
    ///
    /// The user is responsible for calling [`cutensorDestroyOperationDescriptor`] to free the resources associated with the descriptor.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `desc`: This opaque struct gets allocated and filled with the information that encodes the tensor contraction operation.
    /// - `descA`: The descriptor that holds the information about the data type, modes, sections, section extents, strides, and non-zero blocks of A.
    /// - `modeA`: Array with ‘nmodeA’ entries that represent the modes of A. Sections, i.e., block-sizes, must match among the involved block-sparse tensors.
    /// - `opA`: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged. Currently, only [`cutensorOperator_t::CUTENSOR_OP_IDENTITY`] is supported.
    /// - `descB`: The descriptor that holds information about the data type, modes, sections, section extents, strides, and non-zero blocks of B.
    /// - `modeB`: Array with ‘nmodeB’ entries that represent the modes of B. Sections, i.e., block-sizes, must match among the involved block-sparse tensors.
    /// - `opB`: Unary operator that will be applied to each element of B before it is further processed. The original data of this tensor remains unchanged. Currently, only [`cutensorOperator_t::CUTENSOR_OP_IDENTITY`] is supported.
    /// - `descC`: The descriptor that holds information about the data type, modes, sections, section extents, strides, and non-zero blocks of C. Note that the block-sparsity pattern of C (the nonZeroCoordinates[] array used to create the decriptor) of C must be identical to that of D; and it is this block-sparsity pattern that determines which parts of the results are computed; no fill-in is allocated or computed.
    /// - `modeC`: Array with ‘nmodeC’ entries that represent the modes of C. Sections, i.e., block-sizes, must match among the involved block-sparse tensors.
    /// - `opC`: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged. Currently, only [`cutensorOperator_t::CUTENSOR_OP_IDENTITY`] is supported.
    /// - `descD`: For now, this must be the same opaque pointer as descC, and the layouts of C and D must be identical.
    /// - `modeD`: Array with ‘nmodeD’ entries that represent the modes of D (must be identical to modeC for now).
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if tensor dimensions or modes or section sizes have an illegal value.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if the combination of data types or operations is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully without error.
    pub fn cutensorCreateBlockSparseContraction(
        handle: cutensorHandle_t,
        desc: *mut cutensorOperationDescriptor_t,
        descA: cutensorBlockSparseTensorDescriptor_t,
        modeA: *const i32,
        opA: cutensorOperator_t,
        descB: cutensorBlockSparseTensorDescriptor_t,
        modeB: *const i32,
        opB: cutensorOperator_t,
        descC: cutensorBlockSparseTensorDescriptor_t,
        modeC: *const i32,
        opC: cutensorOperator_t,
        descD: cutensorBlockSparseTensorDescriptor_t,
        modeD: *const i32,
        descCompute: cutensorComputeDescriptor_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This routine computes the block-sparse tensor contraction $D = alpha \\* A \\* B + beta \\* C$.
    /// $$
    /// \mathcal{D}_{{modes}_\mathcal{D}} \gets \alpha \\* \mathcal{A}_{{modes}_\mathcal{A}} B_{{modes}_\mathcal{B}} + \beta \mathcal{C}_{{modes}_\mathcal{C}}
    /// $$
    ///
    /// The active CUDA device must match the CUDA device that was active at the time at which the plan was created.
    ///
    /// The array-parameters `A`, `B`, `C`, and `D` are host-arrays containing pointers to GPU-accessible memory. For example, `A` is a host-array whose size equals the number of non-zero blocks in tensor $\mathcal{A}$. `A\[i\]` is a pointer to the GPU-accessible memory location of block number `i` of $\mathcal{A}$. The blocks are numbered in the same way as in the construction of $\mathcal{A}$’s block-sparse tensor descriptor. The same analogously holds for the other array-parameters `B`, `C`, and `D`.
    ///
    /// # Parameters
    ///
    /// - `handle`: Opaque handle holding cuTENSOR’s library context.
    /// - `plan`: Opaque handle holding the contraction execution plan (created by [`cutensorCreateBlockSparseContraction`] followed by [`cutensorCreatePlan`]).
    /// - `alpha`: Scaling for A\*B. Its data type is determined by ‘descCompute’ (see [`cutensorCreateBlockSparseContraction`]). Pointer to host memory.
    /// - `A`: Host-array of size numNonZeroBlocks(A), containing pointers to GPU-accessible memory, corresponding the blocks of A. The data accessed via these pointers must not overlap with the elements written to D.
    /// - `B`: Host-array of size numNonZeroBlocks(B), containing pointers to GPU-accessible memory, corresponding the blocks of B. The data accessed via these pointers must not overlap with the elements written to D.
    /// - `beta`: Scaling for C. Its data type is determined by ‘descCompute’ (see [`cutensorCreateBlockSparseContraction`]). Pointer to host memory.
    /// - `C`: Host-array of size numNonZeroBlocks(C), containing pointers to GPU-accessible memory, corresponding the blocks of C.
    /// - `D`: Host-array of size numNonZeroBlocks(D), containing pointers to GPU-accessible memory, corresponding the blocks of D.
    /// - `workspace`: This pointer provides the required workspace in device memory. The workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
    /// - `workspaceSize`: Size of the workspace array in bytes; please refer to [`cutensorEstimateWorkspaceSize`] to query the required workspace. For block-sparse contractions, this estimate is exact.
    /// - `stream`: The CUDA stream to which all of the computation is synchronised.
    ///
    /// # Return value
    ///
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_ARCH_MISMATCH`]: if the plan was created for a different device than the currently active device.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_CUDA_ERROR`]: if some unknown CUDA error has occurred (e.g., out of memory).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INSUFFICIENT_DRIVER`]: if the driver is insufficient.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: if some input data is invalid (this typically indicates an user error).
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_INITIALIZED`]: if the handle is not initialized.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: if operation is not supported.
    /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
    pub fn cutensorBlockSparseContract(
        handle: cutensorHandle_t,
        plan: cutensorPlan_t,
        alpha: *const ::core::ffi::c_void,
        A: *const *const ::core::ffi::c_void,
        B: *const *const ::core::ffi::c_void,
        beta: *const ::core::ffi::c_void,
        C: *const *const ::core::ffi::c_void,
        D: *const *mut ::core::ffi::c_void,
        workspace: *mut ::core::ffi::c_void,
        workspaceSize: u64,
        stream: cudaStream_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// Returns the description string for an error code.
    ///
    /// Remark
    ///
    /// non-blocking, no reentrant, and thread-safe.
    pub fn cutensorGetErrorString(error: cutensorStatus_t) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
    /// Returns Version number of the CUTENSOR library.
    pub fn cutensorGetVersion() -> size_t;
}
unsafe extern "C" {
    /// Returns version number of the CUDA runtime that cuTENSOR was compiled against.
    ///
    /// Can be compared against the CUDA runtime version from cudaRuntimeGetVersion().
    pub fn cutensorGetCudartVersion() -> size_t;
}
unsafe extern "C" {
    /// This function sets the logging callback routine.
    pub fn cutensorLoggerSetCallback(
        callback: cutensorLoggerCallback_t,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function sets the logging output file.
    pub fn cutensorLoggerSetFile(file: *mut FILE) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function opens a logging output file in the given path.
    pub fn cutensorLoggerOpenFile(
        logFile: *const ::core::ffi::c_char,
    ) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function sets the value of the logging level.
    pub fn cutensorLoggerSetLevel(level: i32) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function sets the value of the log mask.
    pub fn cutensorLoggerSetMask(mask: i32) -> cutensorStatus_t;
}
unsafe extern "C" {
    /// This function disables logging for the entire run.
    pub fn cutensorLoggerForceDisable() -> cutensorStatus_t;
}