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
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
| Help on Tensor in module torch object:
class Tensor(torch._C.TensorBase)
| Method resolution order:
| Tensor
| torch._C.TensorBase
| builtins.object
|
| Methods defined here:
|
| __abs__ = abs(...)
|
| __array__(self, dtype=None) from torch._tensor.Tensor
|
| __array_wrap__(self, array) from torch._tensor.Tensor
| # Wrap Numpy array again in a suitable tensor when done, to support e.g.
| # `numpy.sin(tensor) -> tensor` or `numpy.greater(tensor, 0) -> ByteTensor`
|
| __contains__(self, element) from torch._tensor.Tensor
| Check if `element` is present in tensor
|
| Args:
| element (Tensor or scalar): element to be checked
| for presence in current tensor"
|
| __deepcopy__(self, memo) from torch._tensor.Tensor
|
| __dir__(self) from torch._tensor.Tensor
| Default dir() implementation.
|
| __dlpack__(self, stream=None) from torch._tensor.Tensor
| Creates a DLpack `capsule https://data-apis.org/array-api/latest/design_topics/data_interchange.html#data-interchange`_
| of the current tensor to be exported to other libraries.
|
| This function will be called from the `from_dlpack` method
| of the library that will consume the capsule. `from_dlpack` passes the current
| stream to this method as part of the specification.
|
| Args:
| stream (integer or None): An optional Python integer representing a
| pointer to a CUDA stream. The current stream is synchronized with
| this stream before the capsule is created, and since the capsule
| shares its storage with the tensor this make it safe to access from
| both streams. If None or -1 is passed then no synchronization is performed.
| If 1 (on CUDA) or 0 (on ROCM) then the default stream is used for
| synchronization.
|
| __dlpack_device__(self) -> Tuple[enum.IntEnum, int] from torch._tensor.Tensor
|
| __floordiv__(self, other) from torch._tensor.Tensor
|
| __format__(self, format_spec) from torch._tensor.Tensor
| Default object formatter.
|
| __hash__(self) from torch._tensor.Tensor
| Return hash(self).
|
| __ipow__ = pow_(...) from torch._tensor.TensorBase
|
| __iter__(self) from torch._tensor.Tensor
|
| __itruediv__ = __idiv__(...)
|
| __len__(self) from torch._tensor.Tensor
| Return len(self).
|
| __neg__ = neg(...)
|
| __pos__ = positive(...)
|
| __pow__ = pow(...) from torch._tensor.TensorBase
|
| __rdiv__(self, other) from torch._tensor.Tensor
|
| __reduce_ex__(self, proto) from torch._tensor.Tensor
| Helper for pickle.
|
| __repr__(self, *, tensor_contents=None) from torch._tensor.Tensor
| Return repr(self).
|
| __reversed__(self) from torch._tensor.Tensor
| Reverses the tensor along dimension 0.
|
| __rfloordiv__(self, other) from torch._tensor.Tensor
|
| __rlshift__(self, other) from torch._tensor.Tensor
|
| __rmatmul__(self, other) from torch._tensor.Tensor
|
| __rmod__(self, other) from torch._tensor.Tensor
|
| __rpow__(self, other) from torch._tensor.Tensor
|
| __rrshift__(self, other) from torch._tensor.Tensor
|
| __rsub__(self, other) from torch._tensor.Tensor
|
| __rtruediv__ = __rdiv__(self, other)
|
| __setstate__(self, state) from torch._tensor.Tensor
|
| align_to(self, *names) from torch._tensor.Tensor
| Permutes the dimensions of the :attr:`self` tensor to match the order
| specified in :attr:`names`, adding size-one dims for any new names.
|
| All of the dims of :attr:`self` must be named in order to use this method.
| The resulting tensor is a view on the original tensor.
|
| All dimension names of :attr:`self` must be present in :attr:`names`.
| :attr:`names` may contain additional names that are not in ``self.names``;
| the output tensor has a size-one dimension for each of those new names.
|
| :attr:`names` may contain up to one Ellipsis (``...``).
| The Ellipsis is expanded to be equal to all dimension names of :attr:`self`
| that are not mentioned in :attr:`names`, in the order that they appear
| in :attr:`self`.
|
| Python 2 does not support Ellipsis but one may use a string literal
| instead (``'...'``).
|
| Args:
| names (iterable of str): The desired dimension ordering of the
| output tensor. May contain up to one Ellipsis that is expanded
| to all unmentioned dim names of :attr:`self`.
|
| Examples::
|
| >>> tensor = torch.randn(2, 2, 2, 2, 2, 2)
| >>> named_tensor = tensor.refine_names('A', 'B', 'C', 'D', 'E', 'F')
|
| # Move the F and E dims to the front while keeping the rest in order
| >>> named_tensor.align_to('F', 'E', ...)
|
| .. warning::
| The named tensor API is experimental and subject to change.
|
| backward(self, gradient=None, retain_graph=None, create_graph=False, inputs=None) from torch._tensor.Tensor
| Computes the gradient of current tensor wrt graph leaves.
|
| The graph is differentiated using the chain rule. If the tensor is
| non-scalar (i.e. its data has more than one element) and requires
| gradient, the function additionally requires specifying ``gradient``.
| It should be a tensor of matching type and location, that contains
| the gradient of the differentiated function w.r.t. ``self``.
|
| This function accumulates gradients in the leaves - you might need to zero
| ``.grad`` attributes or set them to ``None`` before calling it.
| See :ref:`Default gradient layouts<default-grad-layouts>`
| for details on the memory layout of accumulated gradients.
|
| .. note::
|
| If you run any forward ops, create ``gradient``, and/or call ``backward``
| in a user-specified CUDA stream context, see
| :ref:`Stream semantics of backward passes<bwd-cuda-stream-semantics>`.
|
| .. note::
|
| When ``inputs`` are provided and a given input is not a leaf,
| the current implementation will call its grad_fn (though it is not strictly needed to get this gradients).
| It is an implementation detail on which the user should not rely.
| See https://github.com/pytorch/pytorch/pull/60521#issuecomment-867061780 for more details.
|
| Args:
| gradient (Tensor or None): Gradient w.r.t. the
| tensor. If it is a tensor, it will be automatically converted
| to a Tensor that does not require grad unless ``create_graph`` is True.
| None values can be specified for scalar Tensors or ones that
| don't require grad. If a None value would be acceptable then
| this argument is optional.
| retain_graph (bool, optional): If ``False``, the graph used to compute
| the grads will be freed. Note that in nearly all cases setting
| this option to True is not needed and often can be worked around
| in a much more efficient way. Defaults to the value of
| ``create_graph``.
| create_graph (bool, optional): If ``True``, graph of the derivative will
| be constructed, allowing to compute higher order derivative
| products. Defaults to ``False``.
| inputs (sequence of Tensor): Inputs w.r.t. which the gradient will be
| accumulated into ``.grad``. All other Tensors will be ignored. If not
| provided, the gradient is accumulated into all the leaf Tensors that were
| used to compute the attr::tensors.
|
| detach(...) from torch._C.TensorBase
| Returns a new Tensor, detached from the current graph.
|
| The result will never require gradient.
|
| This method also affects forward mode AD gradients and the result will never
| have forward mode AD gradients.
|
| .. note::
|
| Returned Tensor shares the same storage with the original one.
| In-place modifications on either of them will be seen, and may trigger
| errors in correctness checks.
|
| detach_(...) from torch._C.TensorBase
| Detaches the Tensor from the graph that created it, making it a leaf.
| Views cannot be detached in-place.
|
| This method also affects forward mode AD gradients and the result will never
| have forward mode AD gradients.
|
| dim_order(self) from torch._tensor.Tensor
| dim_order() -> tuple
|
| Returns a tuple of int describing the dim order or physical layout of :attr:`self`.
|
| Args:
| None
|
| Dim order represents how dimensions are laid out in memory,
| starting from the outermost to the innermost dimension.
|
| Example::
| >>> torch.empty((2, 3, 5, 7)).dim_order()
| (0, 1, 2, 3)
| >>> torch.empty((2, 3, 5, 7), memory_format=torch.channels_last).dim_order()
| (0, 2, 3, 1)
|
| .. warning::
| The dim_order tensor API is experimental and subject to change.
|
| eig(self, eigenvectors=False) from torch._tensor.Tensor
|
| is_shared(self) from torch._tensor.Tensor
| Checks if tensor is in shared memory.
|
| This is always ``True`` for CUDA tensors.
|
| istft(self, n_fft: int, hop_length: Optional[int] = None, win_length: Optional[int] = None, window: 'Optional[Tensor]' = None, center: bool = True, normalized: bool = False, onesided: Optional[bool] = None, length: Optional[int] = None, return_complex: bool = False) from torch._tensor.Tensor
| See :func:`torch.istft`
|
| lstsq(self, other) from torch._tensor.Tensor
|
| lu(self, pivot=True, get_infos=False) from torch._tensor.Tensor
| See :func:`torch.lu`
|
| module_load(self, other, assign=False) from torch._tensor.Tensor
| Defines how to transform ``other`` when loading it into ``self`` in :meth:`~nn.Module.load_state_dict`.
|
| Used when :func:`~torch.__future__.get_swap_module_params_on_conversion` is ``True``.
|
| It is expected that ``self`` is a parameter or buffer in an ``nn.Module`` and ``other`` is the
| value in the state dictionary with the corresponding key, this method defines
| how ``other`` is remapped before being swapped with ``self`` via
| :func:`~torch.utils.swap_tensors`` in ``module.load_state_dict()``.
|
| .. note::
| This method should always return a new object that is not ``self`` or ``other``.
| For example, the default implementation returns ``self.copy_(other).detach()``
| if ``assign`` is ``False`` or ``other.detach()`` if ``assign`` is ``True``.
|
| Args:
| other (Tensor): value in state dict with key corresponding to ``self``
| assign (bool): the assign argument passed to :meth:`nn.Module.load_state_dict`
|
| norm(self, p: Union[float, str, NoneType] = 'fro', dim=None, keepdim=False, dtype=None) from torch._tensor.Tensor
| See :func:`torch.norm`
|
| refine_names(self, *names) from torch._tensor.Tensor
| Refines the dimension names of :attr:`self` according to :attr:`names`.
|
| Refining is a special case of renaming that "lifts" unnamed dimensions.
| A ``None`` dim can be refined to have any name; a named dim can only be
| refined to have the same name.
|
| Because named tensors can coexist with unnamed tensors, refining names
| gives a nice way to write named-tensor-aware code that works with both
| named and unnamed tensors.
|
| :attr:`names` may contain up to one Ellipsis (``...``).
| The Ellipsis is expanded greedily; it is expanded in-place to fill
| :attr:`names` to the same length as ``self.dim()`` using names from the
| corresponding indices of ``self.names``.
|
| Python 2 does not support Ellipsis but one may use a string literal
| instead (``'...'``).
|
| Args:
| names (iterable of str): The desired names of the output tensor. May
| contain up to one Ellipsis.
|
| Examples::
|
| >>> imgs = torch.randn(32, 3, 128, 128)
| >>> named_imgs = imgs.refine_names('N', 'C', 'H', 'W')
| >>> named_imgs.names
| ('N', 'C', 'H', 'W')
|
| >>> tensor = torch.randn(2, 3, 5, 7, 11)
| >>> tensor = tensor.refine_names('A', ..., 'B', 'C')
| >>> tensor.names
| ('A', None, None, 'B', 'C')
|
| .. warning::
| The named tensor API is experimental and subject to change.
|
| register_hook(self, hook) from torch._tensor.Tensor
| Registers a backward hook.
|
| The hook will be called every time a gradient with respect to the
| Tensor is computed. The hook should have the following signature::
|
| hook(grad) -> Tensor or None
|
|
| The hook should not modify its argument, but it can optionally return
| a new gradient which will be used in place of :attr:`grad`.
|
| This function returns a handle with a method ``handle.remove()``
| that removes the hook from the module.
|
| .. note::
| See :ref:`backward-hooks-execution` for more information on how when this hook
| is executed, and how its execution is ordered relative to other hooks.
|
| Example::
|
| >>> v = torch.tensor([0., 0., 0.], requires_grad=True)
| >>> h = v.register_hook(lambda grad: grad * 2) # double the gradient
| >>> v.backward(torch.tensor([1., 2., 3.]))
| >>> v.grad
|
| 2
| 4
| 6
| [torch.FloatTensor of size (3,)]
|
| >>> h.remove() # removes the hook
|
| register_post_accumulate_grad_hook(self, hook) from torch._tensor.Tensor
| Registers a backward hook that runs after grad accumulation.
|
| The hook will be called after all gradients for a tensor have been accumulated,
| meaning that the .grad field has been updated on that tensor. The post
| accumulate grad hook is ONLY applicable for leaf tensors (tensors without a
| .grad_fn field). Registering this hook on a non-leaf tensor will error!
|
| The hook should have the following signature::
|
| hook(param: Tensor) -> None
|
| Note that, unlike other autograd hooks, this hook operates on the tensor
| that requires grad and not the grad itself. The hook can in-place modify
| and access its Tensor argument, including its .grad field.
|
| This function returns a handle with a method ``handle.remove()``
| that removes the hook from the module.
|
| .. note::
| See :ref:`backward-hooks-execution` for more information on how when this hook
| is executed, and how its execution is ordered relative to other hooks. Since
| this hook runs during the backward pass, it will run in no_grad mode (unless
| create_graph is True). You can use torch.enable_grad() to re-enable autograd
| within the hook if you need it.
|
| Example::
|
| >>> v = torch.tensor([0., 0., 0.], requires_grad=True)
| >>> lr = 0.01
| >>> # simulate a simple SGD update
| >>> h = v.register_post_accumulate_grad_hook(lambda p: p.add_(p.grad, alpha=-lr))
| >>> v.backward(torch.tensor([1., 2., 3.]))
| >>> v
| tensor([-0.0100, -0.0200, -0.0300], requires_grad=True)
|
| >>> h.remove() # removes the hook
|
| reinforce(self, reward) from torch._tensor.Tensor
|
| rename(self, *names, **rename_map) from torch._tensor.Tensor
| Renames dimension names of :attr:`self`.
|
| There are two main usages:
|
| ``self.rename(**rename_map)`` returns a view on tensor that has dims
| renamed as specified in the mapping :attr:`rename_map`.
|
| ``self.rename(*names)`` returns a view on tensor, renaming all
| dimensions positionally using :attr:`names`.
| Use ``self.rename(None)`` to drop names on a tensor.
|
| One cannot specify both positional args :attr:`names` and keyword args
| :attr:`rename_map`.
|
| Examples::
|
| >>> imgs = torch.rand(2, 3, 5, 7, names=('N', 'C', 'H', 'W'))
| >>> renamed_imgs = imgs.rename(N='batch', C='channels')
| >>> renamed_imgs.names
| ('batch', 'channels', 'H', 'W')
|
| >>> renamed_imgs = imgs.rename(None)
| >>> renamed_imgs.names
| (None, None, None, None)
|
| >>> renamed_imgs = imgs.rename('batch', 'channel', 'height', 'width')
| >>> renamed_imgs.names
| ('batch', 'channel', 'height', 'width')
|
| .. warning::
| The named tensor API is experimental and subject to change.
|
| rename_(self, *names, **rename_map) from torch._tensor.Tensor
| In-place version of :meth:`~Tensor.rename`.
|
| resize(self, *sizes) from torch._tensor.Tensor
|
| resize_as(self, tensor) from torch._tensor.Tensor
|
| share_memory_(self) from torch._tensor.Tensor
| Moves the underlying storage to shared memory.
|
| This is a no-op if the underlying storage is already in shared memory
| and for CUDA tensors. Tensors in shared memory cannot be resized.
|
| See :meth:`torch.UntypedStorage.share_memory_` for more details.
|
| solve(self, other) from torch._tensor.Tensor
|
| split(self, split_size, dim=0) from torch._tensor.Tensor
| See :func:`torch.split`
|
| stft(self, n_fft: int, hop_length: Optional[int] = None, win_length: Optional[int] = None, window: 'Optional[Tensor]' = None, center: bool = True, pad_mode: str = 'reflect', normalized: bool = False, onesided: Optional[bool] = None, return_complex: Optional[bool] = None) from torch._tensor.Tensor
| See :func:`torch.stft`
|
| .. warning::
| This function changed signature at version 0.4.1. Calling with
| the previous signature may cause error or return incorrect result.
|
| storage(self) from torch._tensor.Tensor
| storage() -> torch.TypedStorage
|
| Returns the underlying :class:`TypedStorage`.
|
| .. warning::
|
| :class:`TypedStorage` is deprecated. It will be removed in the future, and
| :class:`UntypedStorage` will be the only storage class. To access the
| :class:`UntypedStorage` directly, use :attr:`Tensor.untyped_storage()`.
|
| storage_type(self) from torch._tensor.Tensor
| storage_type() -> type
|
| Returns the type of the underlying storage.
|
| symeig(self, eigenvectors=False) from torch._tensor.Tensor
|
| to_sparse_coo(self) from torch._tensor.Tensor
| Convert a tensor to :ref:`coordinate format <sparse-coo-docs>`.
|
| Examples::
|
| >>> dense = torch.randn(5, 5)
| >>> sparse = dense.to_sparse_coo()
| >>> sparse._nnz()
| 25
|
| unflatten(self, dim, sizes) from torch._tensor.Tensor
| unflatten(dim, sizes) -> Tensor
|
| See :func:`torch.unflatten`.
|
| unique(self, sorted=True, return_inverse=False, return_counts=False, dim=None) from torch._tensor.Tensor
| Returns the unique elements of the input tensor.
|
| See :func:`torch.unique`
|
| unique_consecutive(self, return_inverse=False, return_counts=False, dim=None) from torch._tensor.Tensor
| Eliminates all but the first element from every consecutive group of equivalent elements.
|
| See :func:`torch.unique_consecutive`
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __torch_function__(func, types, args=(), kwargs=None) from torch._tensor.Tensor
| This __torch_function__ implementation wraps subclasses such that
| methods called on subclasses return a subclass instance instead of
| a ``torch.Tensor`` instance.
|
| One corollary to this is that you need coverage for torch.Tensor
| methods if implementing __torch_function__ for subclasses.
|
| We recommend always calling ``super().__torch_function__`` as the base
| case when doing the above.
|
| While not mandatory, we recommend making `__torch_function__` a classmethod.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __torch_dispatch__ = _disabled_torch_dispatch_impl(...)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| __cuda_array_interface__
| Array view description for cuda tensors.
|
| See:
| https://numba.pydata.org/numba-doc/latest/cuda/cuda_array_interface.html
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __array_priority__ = 1000
|
| ----------------------------------------------------------------------
| Methods inherited from torch._C.TensorBase:
|
| __add__(...)
|
| __and__(...)
|
| __bool__(...)
|
| __complex__(...)
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __div__(...)
|
| __eq__(...)
| Return self==value.
|
| __float__(...)
|
| __ge__(...)
| Return self>=value.
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(...)
| Return self>value.
|
| __iadd__(...)
|
| __iand__(...)
|
| __idiv__(...)
|
| __ifloordiv__(...)
|
| __ilshift__(...)
|
| __imod__(...)
|
| __imul__(...)
|
| __index__(...)
|
| __int__(...)
|
| __invert__(...)
|
| __ior__(...)
|
| __irshift__(...)
|
| __isub__(...)
|
| __ixor__(...)
|
| __le__(...)
| Return self<=value.
|
| __long__(...)
|
| __lshift__(...)
|
| __lt__(...)
| Return self<value.
|
| __matmul__(...)
|
| __mod__(...)
|
| __mul__(...)
|
| __ne__(...)
| Return self!=value.
|
| __nonzero__(...)
|
| __or__(...)
| Return self|value.
|
| __radd__(...)
|
| __rand__(...)
|
| __rmul__(...)
|
| __ror__(...)
| Return value|self.
|
| __rshift__(...)
|
| __rxor__(...)
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sub__(...)
|
| __truediv__(...)
|
| __xor__(...)
|
| abs(...)
| abs() -> Tensor
|
| See :func:`torch.abs`
|
| abs_(...)
| abs_() -> Tensor
|
| In-place version of :meth:`~Tensor.abs`
|
| absolute(...)
| absolute() -> Tensor
|
| Alias for :func:`abs`
|
| absolute_(...)
| absolute_() -> Tensor
|
| In-place version of :meth:`~Tensor.absolute`
| Alias for :func:`abs_`
|
| acos(...)
| acos() -> Tensor
|
| See :func:`torch.acos`
|
| acos_(...)
| acos_() -> Tensor
|
| In-place version of :meth:`~Tensor.acos`
|
| acosh(...)
| acosh() -> Tensor
|
| See :func:`torch.acosh`
|
| acosh_(...)
| acosh_() -> Tensor
|
| In-place version of :meth:`~Tensor.acosh`
|
| add(...)
| add(other, *, alpha=1) -> Tensor
|
| Add a scalar or tensor to :attr:`self` tensor. If both :attr:`alpha`
| and :attr:`other` are specified, each element of :attr:`other` is scaled by
| :attr:`alpha` before being used.
|
| When :attr:`other` is a tensor, the shape of :attr:`other` must be
| :ref:`broadcastable <broadcasting-semantics>` with the shape of the underlying
| tensor
|
| See :func:`torch.add`
|
| add_(...)
| add_(other, *, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.add`
|
| addbmm(...)
| addbmm(batch1, batch2, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.addbmm`
|
| addbmm_(...)
| addbmm_(batch1, batch2, *, beta=1, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addbmm`
|
| addcdiv(...)
| addcdiv(tensor1, tensor2, *, value=1) -> Tensor
|
| See :func:`torch.addcdiv`
|
| addcdiv_(...)
| addcdiv_(tensor1, tensor2, *, value=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addcdiv`
|
| addcmul(...)
| addcmul(tensor1, tensor2, *, value=1) -> Tensor
|
| See :func:`torch.addcmul`
|
| addcmul_(...)
| addcmul_(tensor1, tensor2, *, value=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addcmul`
|
| addmm(...)
| addmm(mat1, mat2, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.addmm`
|
| addmm_(...)
| addmm_(mat1, mat2, *, beta=1, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addmm`
|
| addmv(...)
| addmv(mat, vec, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.addmv`
|
| addmv_(...)
| addmv_(mat, vec, *, beta=1, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addmv`
|
| addr(...)
| addr(vec1, vec2, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.addr`
|
| addr_(...)
| addr_(vec1, vec2, *, beta=1, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.addr`
|
| adjoint(...)
| adjoint() -> Tensor
|
| Alias for :func:`adjoint`
|
| align_as(...)
| align_as(other) -> Tensor
|
| Permutes the dimensions of the :attr:`self` tensor to match the dimension order
| in the :attr:`other` tensor, adding size-one dims for any new names.
|
| This operation is useful for explicit broadcasting by names (see examples).
|
| All of the dims of :attr:`self` must be named in order to use this method.
| The resulting tensor is a view on the original tensor.
|
| All dimension names of :attr:`self` must be present in ``other.names``.
| :attr:`other` may contain named dimensions that are not in ``self.names``;
| the output tensor has a size-one dimension for each of those new names.
|
| To align a tensor to a specific order, use :meth:`~Tensor.align_to`.
|
| Examples::
|
| # Example 1: Applying a mask
| >>> mask = torch.randint(2, [127, 128], dtype=torch.bool).refine_names('W', 'H')
| >>> imgs = torch.randn(32, 128, 127, 3, names=('N', 'H', 'W', 'C'))
| >>> imgs.masked_fill_(mask.align_as(imgs), 0)
|
|
| # Example 2: Applying a per-channel-scale
| >>> def scale_channels(input, scale):
| >>> scale = scale.refine_names('C')
| >>> return input * scale.align_as(input)
|
| >>> num_channels = 3
| >>> scale = torch.randn(num_channels, names=('C',))
| >>> imgs = torch.rand(32, 128, 128, num_channels, names=('N', 'H', 'W', 'C'))
| >>> more_imgs = torch.rand(32, num_channels, 128, 128, names=('N', 'C', 'H', 'W'))
| >>> videos = torch.randn(3, num_channels, 128, 128, 128, names=('N', 'C', 'H', 'W', 'D'))
|
| # scale_channels is agnostic to the dimension order of the input
| >>> scale_channels(imgs, scale)
| >>> scale_channels(more_imgs, scale)
| >>> scale_channels(videos, scale)
|
| .. warning::
| The named tensor API is experimental and subject to change.
|
| all(...)
| all(dim=None, keepdim=False) -> Tensor
|
| See :func:`torch.all`
|
| allclose(...)
| allclose(other, rtol=1e-05, atol=1e-08, equal_nan=False) -> Tensor
|
| See :func:`torch.allclose`
|
| amax(...)
| amax(dim=None, keepdim=False) -> Tensor
|
| See :func:`torch.amax`
|
| amin(...)
| amin(dim=None, keepdim=False) -> Tensor
|
| See :func:`torch.amin`
|
| aminmax(...)
| aminmax(*, dim=None, keepdim=False) -> (Tensor min, Tensor max)
|
| See :func:`torch.aminmax`
|
| angle(...)
| angle() -> Tensor
|
| See :func:`torch.angle`
|
| any(...)
| any(dim=None, keepdim=False) -> Tensor
|
| See :func:`torch.any`
|
| apply_(...)
| apply_(callable) -> Tensor
|
| Applies the function :attr:`callable` to each element in the tensor, replacing
| each element with the value returned by :attr:`callable`.
|
| .. note::
|
| This function only works with CPU tensors and should not be used in code
| sections that require high performance.
|
| arccos(...)
| arccos() -> Tensor
|
| See :func:`torch.arccos`
|
| arccos_(...)
| arccos_() -> Tensor
|
| In-place version of :meth:`~Tensor.arccos`
|
| arccosh(...)
| acosh() -> Tensor
|
| See :func:`torch.arccosh`
|
| arccosh_(...)
| acosh_() -> Tensor
|
| In-place version of :meth:`~Tensor.arccosh`
|
| arcsin(...)
| arcsin() -> Tensor
|
| See :func:`torch.arcsin`
|
| arcsin_(...)
| arcsin_() -> Tensor
|
| In-place version of :meth:`~Tensor.arcsin`
|
| arcsinh(...)
| arcsinh() -> Tensor
|
| See :func:`torch.arcsinh`
|
| arcsinh_(...)
| arcsinh_() -> Tensor
|
| In-place version of :meth:`~Tensor.arcsinh`
|
| arctan(...)
| arctan() -> Tensor
|
| See :func:`torch.arctan`
|
| arctan2(...)
| arctan2(other) -> Tensor
|
| See :func:`torch.arctan2`
|
| arctan2_(...)
| atan2_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.arctan2`
|
| arctan_(...)
| arctan_() -> Tensor
|
| In-place version of :meth:`~Tensor.arctan`
|
| arctanh(...)
| arctanh() -> Tensor
|
| See :func:`torch.arctanh`
|
| arctanh_(...)
| arctanh_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.arctanh`
|
| argmax(...)
| argmax(dim=None, keepdim=False) -> LongTensor
|
| See :func:`torch.argmax`
|
| argmin(...)
| argmin(dim=None, keepdim=False) -> LongTensor
|
| See :func:`torch.argmin`
|
| argsort(...)
| argsort(dim=-1, descending=False) -> LongTensor
|
| See :func:`torch.argsort`
|
| argwhere(...)
| argwhere() -> Tensor
|
| See :func:`torch.argwhere`
|
| as_strided(...)
| as_strided(size, stride, storage_offset=None) -> Tensor
|
| See :func:`torch.as_strided`
|
| as_strided_(...)
| as_strided_(size, stride, storage_offset=None) -> Tensor
|
| In-place version of :meth:`~Tensor.as_strided`
|
| as_strided_scatter(...)
| as_strided_scatter(src, size, stride, storage_offset=None) -> Tensor
|
| See :func:`torch.as_strided_scatter`
|
| as_subclass(...)
| as_subclass(cls) -> Tensor
|
| Makes a ``cls`` instance with the same data pointer as ``self``. Changes
| in the output mirror changes in ``self``, and the output stays attached
| to the autograd graph. ``cls`` must be a subclass of ``Tensor``.
|
| asin(...)
| asin() -> Tensor
|
| See :func:`torch.asin`
|
| asin_(...)
| asin_() -> Tensor
|
| In-place version of :meth:`~Tensor.asin`
|
| asinh(...)
| asinh() -> Tensor
|
| See :func:`torch.asinh`
|
| asinh_(...)
| asinh_() -> Tensor
|
| In-place version of :meth:`~Tensor.asinh`
|
| atan(...)
| atan() -> Tensor
|
| See :func:`torch.atan`
|
| atan2(...)
| atan2(other) -> Tensor
|
| See :func:`torch.atan2`
|
| atan2_(...)
| atan2_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.atan2`
|
| atan_(...)
| atan_() -> Tensor
|
| In-place version of :meth:`~Tensor.atan`
|
| atanh(...)
| atanh() -> Tensor
|
| See :func:`torch.atanh`
|
| atanh_(...)
| atanh_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.atanh`
|
| baddbmm(...)
| baddbmm(batch1, batch2, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.baddbmm`
|
| baddbmm_(...)
| baddbmm_(batch1, batch2, *, beta=1, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.baddbmm`
|
| bernoulli(...)
| bernoulli(*, generator=None) -> Tensor
|
| Returns a result tensor where each :math:`\texttt{result[i]}` is independently
| sampled from :math:`\text{Bernoulli}(\texttt{self[i]})`. :attr:`self` must have
| floating point ``dtype``, and the result will have the same ``dtype``.
|
| See :func:`torch.bernoulli`
|
| bernoulli_(...)
| bernoulli_(p=0.5, *, generator=None) -> Tensor
|
| Fills each location of :attr:`self` with an independent sample from
| :math:`\text{Bernoulli}(\texttt{p})`. :attr:`self` can have integral
| ``dtype``.
|
| :attr:`p` should either be a scalar or tensor containing probabilities to be
| used for drawing the binary random number.
|
| If it is a tensor, the :math:`\text{i}^{th}` element of :attr:`self` tensor
| will be set to a value sampled from
| :math:`\text{Bernoulli}(\texttt{p\_tensor[i]})`. In this case `p` must have
| floating point ``dtype``.
|
| See also :meth:`~Tensor.bernoulli` and :func:`torch.bernoulli`
|
| bfloat16(...)
| bfloat16(memory_format=torch.preserve_format) -> Tensor
| ``self.bfloat16()`` is equivalent to ``self.to(torch.bfloat16)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| bincount(...)
| bincount(weights=None, minlength=0) -> Tensor
|
| See :func:`torch.bincount`
|
| bitwise_and(...)
| bitwise_and() -> Tensor
|
| See :func:`torch.bitwise_and`
|
| bitwise_and_(...)
| bitwise_and_() -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_and`
|
| bitwise_left_shift(...)
| bitwise_left_shift(other) -> Tensor
|
| See :func:`torch.bitwise_left_shift`
|
| bitwise_left_shift_(...)
| bitwise_left_shift_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_left_shift`
|
| bitwise_not(...)
| bitwise_not() -> Tensor
|
| See :func:`torch.bitwise_not`
|
| bitwise_not_(...)
| bitwise_not_() -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_not`
|
| bitwise_or(...)
| bitwise_or() -> Tensor
|
| See :func:`torch.bitwise_or`
|
| bitwise_or_(...)
| bitwise_or_() -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_or`
|
| bitwise_right_shift(...)
| bitwise_right_shift(other) -> Tensor
|
| See :func:`torch.bitwise_right_shift`
|
| bitwise_right_shift_(...)
| bitwise_right_shift_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_right_shift`
|
| bitwise_xor(...)
| bitwise_xor() -> Tensor
|
| See :func:`torch.bitwise_xor`
|
| bitwise_xor_(...)
| bitwise_xor_() -> Tensor
|
| In-place version of :meth:`~Tensor.bitwise_xor`
|
| bmm(...)
| bmm(batch2) -> Tensor
|
| See :func:`torch.bmm`
|
| bool(...)
| bool(memory_format=torch.preserve_format) -> Tensor
|
| ``self.bool()`` is equivalent to ``self.to(torch.bool)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| broadcast_to(...)
| broadcast_to(shape) -> Tensor
|
| See :func:`torch.broadcast_to`.
|
| byte(...)
| byte(memory_format=torch.preserve_format) -> Tensor
|
| ``self.byte()`` is equivalent to ``self.to(torch.uint8)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| cauchy_(...)
| cauchy_(median=0, sigma=1, *, generator=None) -> Tensor
|
| Fills the tensor with numbers drawn from the Cauchy distribution:
|
| .. math::
|
| f(x) = \dfrac{1}{\pi} \dfrac{\sigma}{(x - \text{median})^2 + \sigma^2}
|
| .. note::
| Sigma (:math:`\sigma`) is used to denote the scale parameter in Cauchy distribution.
|
| ccol_indices(...)
|
| cdouble(...)
| cdouble(memory_format=torch.preserve_format) -> Tensor
|
| ``self.cdouble()`` is equivalent to ``self.to(torch.complex128)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| ceil(...)
| ceil() -> Tensor
|
| See :func:`torch.ceil`
|
| ceil_(...)
| ceil_() -> Tensor
|
| In-place version of :meth:`~Tensor.ceil`
|
| cfloat(...)
| cfloat(memory_format=torch.preserve_format) -> Tensor
|
| ``self.cfloat()`` is equivalent to ``self.to(torch.complex64)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| chalf(...)
| chalf(memory_format=torch.preserve_format) -> Tensor
|
| ``self.chalf()`` is equivalent to ``self.to(torch.complex32)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| char(...)
| char(memory_format=torch.preserve_format) -> Tensor
|
| ``self.char()`` is equivalent to ``self.to(torch.int8)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| cholesky(...)
| cholesky(upper=False) -> Tensor
|
| See :func:`torch.cholesky`
|
| cholesky_inverse(...)
| cholesky_inverse(upper=False) -> Tensor
|
| See :func:`torch.cholesky_inverse`
|
| cholesky_solve(...)
| cholesky_solve(input2, upper=False) -> Tensor
|
| See :func:`torch.cholesky_solve`
|
| chunk(...)
| chunk(chunks, dim=0) -> List of Tensors
|
| See :func:`torch.chunk`
|
| clamp(...)
| clamp(min=None, max=None) -> Tensor
|
| See :func:`torch.clamp`
|
| clamp_(...)
| clamp_(min=None, max=None) -> Tensor
|
| In-place version of :meth:`~Tensor.clamp`
|
| clamp_max(...)
|
| clamp_max_(...)
|
| clamp_min(...)
|
| clamp_min_(...)
|
| clip(...)
| clip(min=None, max=None) -> Tensor
|
| Alias for :meth:`~Tensor.clamp`.
|
| clip_(...)
| clip_(min=None, max=None) -> Tensor
|
| Alias for :meth:`~Tensor.clamp_`.
|
| clone(...)
| clone(*, memory_format=torch.preserve_format) -> Tensor
|
| See :func:`torch.clone`
|
| coalesce(...)
| coalesce() -> Tensor
|
| Returns a coalesced copy of :attr:`self` if :attr:`self` is an
| :ref:`uncoalesced tensor <sparse-uncoalesced-coo-docs>`.
|
| Returns :attr:`self` if :attr:`self` is a coalesced tensor.
|
| .. warning::
| Throws an error if :attr:`self` is not a sparse COO tensor.
|
| col_indices(...)
| col_indices() -> IntTensor
|
| Returns the tensor containing the column indices of the :attr:`self`
| tensor when :attr:`self` is a sparse CSR tensor of layout ``sparse_csr``.
| The ``col_indices`` tensor is strictly of shape (:attr:`self`.nnz())
| and of type ``int32`` or ``int64``. When using MKL routines such as sparse
| matrix multiplication, it is necessary to use ``int32`` indexing in order
| to avoid downcasting and potentially losing information.
|
| Example::
| >>> csr = torch.eye(5,5).to_sparse_csr()
| >>> csr.col_indices()
| tensor([0, 1, 2, 3, 4], dtype=torch.int32)
|
| conj(...)
| conj() -> Tensor
|
| See :func:`torch.conj`
|
| conj_physical(...)
| conj_physical() -> Tensor
|
| See :func:`torch.conj_physical`
|
| conj_physical_(...)
| conj_physical_() -> Tensor
|
| In-place version of :meth:`~Tensor.conj_physical`
|
| contiguous(...)
| contiguous(memory_format=torch.contiguous_format) -> Tensor
|
| Returns a contiguous in memory tensor containing the same data as :attr:`self` tensor. If
| :attr:`self` tensor is already in the specified memory format, this function returns the
| :attr:`self` tensor.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.contiguous_format``.
|
| copy_(...)
| copy_(src, non_blocking=False) -> Tensor
|
| Copies the elements from :attr:`src` into :attr:`self` tensor and returns
| :attr:`self`.
|
| The :attr:`src` tensor must be :ref:`broadcastable <broadcasting-semantics>`
| with the :attr:`self` tensor. It may be of a different data type or reside on a
| different device.
|
| Args:
| src (Tensor): the source tensor to copy from
| non_blocking (bool): if ``True`` and this copy is between CPU and GPU,
| the copy may occur asynchronously with respect to the host. For other
| cases, this argument has no effect.
|
| copysign(...)
| copysign(other) -> Tensor
|
| See :func:`torch.copysign`
|
| copysign_(...)
| copysign_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.copysign`
|
| corrcoef(...)
| corrcoef() -> Tensor
|
| See :func:`torch.corrcoef`
|
| cos(...)
| cos() -> Tensor
|
| See :func:`torch.cos`
|
| cos_(...)
| cos_() -> Tensor
|
| In-place version of :meth:`~Tensor.cos`
|
| cosh(...)
| cosh() -> Tensor
|
| See :func:`torch.cosh`
|
| cosh_(...)
| cosh_() -> Tensor
|
| In-place version of :meth:`~Tensor.cosh`
|
| count_nonzero(...)
| count_nonzero(dim=None) -> Tensor
|
| See :func:`torch.count_nonzero`
|
| cov(...)
| cov(*, correction=1, fweights=None, aweights=None) -> Tensor
|
| See :func:`torch.cov`
|
| cpu(...)
| cpu(memory_format=torch.preserve_format) -> Tensor
|
| Returns a copy of this object in CPU memory.
|
| If this object is already in CPU memory and on the correct device,
| then no copy is performed and the original object is returned.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| cross(...)
| cross(other, dim=None) -> Tensor
|
| See :func:`torch.cross`
|
| crow_indices(...)
| crow_indices() -> IntTensor
|
| Returns the tensor containing the compressed row indices of the :attr:`self`
| tensor when :attr:`self` is a sparse CSR tensor of layout ``sparse_csr``.
| The ``crow_indices`` tensor is strictly of shape (:attr:`self`.size(0) + 1)
| and of type ``int32`` or ``int64``. When using MKL routines such as sparse
| matrix multiplication, it is necessary to use ``int32`` indexing in order
| to avoid downcasting and potentially losing information.
|
| Example::
| >>> csr = torch.eye(5,5).to_sparse_csr()
| >>> csr.crow_indices()
| tensor([0, 1, 2, 3, 4, 5], dtype=torch.int32)
|
| cuda(...)
| cuda(device=None, non_blocking=False, memory_format=torch.preserve_format) -> Tensor
|
| Returns a copy of this object in CUDA memory.
|
| If this object is already in CUDA memory and on the correct device,
| then no copy is performed and the original object is returned.
|
| Args:
| device (:class:`torch.device`): The destination GPU device.
| Defaults to the current CUDA device.
| non_blocking (bool): If ``True`` and the source is in pinned memory,
| the copy will be asynchronous with respect to the host.
| Otherwise, the argument has no effect. Default: ``False``.
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| cummax(...)
| cummax(dim) -> (Tensor, Tensor)
|
| See :func:`torch.cummax`
|
| cummin(...)
| cummin(dim) -> (Tensor, Tensor)
|
| See :func:`torch.cummin`
|
| cumprod(...)
| cumprod(dim, dtype=None) -> Tensor
|
| See :func:`torch.cumprod`
|
| cumprod_(...)
| cumprod_(dim, dtype=None) -> Tensor
|
| In-place version of :meth:`~Tensor.cumprod`
|
| cumsum(...)
| cumsum(dim, dtype=None) -> Tensor
|
| See :func:`torch.cumsum`
|
| cumsum_(...)
| cumsum_(dim, dtype=None) -> Tensor
|
| In-place version of :meth:`~Tensor.cumsum`
|
| data_ptr(...)
| data_ptr() -> int
|
| Returns the address of the first element of :attr:`self` tensor.
|
| deg2rad(...)
| deg2rad() -> Tensor
|
| See :func:`torch.deg2rad`
|
| deg2rad_(...)
| deg2rad_() -> Tensor
|
| In-place version of :meth:`~Tensor.deg2rad`
|
| dense_dim(...)
| dense_dim() -> int
|
| Return the number of dense dimensions in a :ref:`sparse tensor <sparse-docs>` :attr:`self`.
|
| .. note::
| Returns ``len(self.shape)`` if :attr:`self` is not a sparse tensor.
|
| See also :meth:`Tensor.sparse_dim` and :ref:`hybrid tensors <sparse-hybrid-coo-docs>`.
|
| dequantize(...)
| dequantize() -> Tensor
|
| Given a quantized Tensor, dequantize it and return the dequantized float Tensor.
|
| det(...)
| det() -> Tensor
|
| See :func:`torch.det`
|
| diag(...)
| diag(diagonal=0) -> Tensor
|
| See :func:`torch.diag`
|
| diag_embed(...)
| diag_embed(offset=0, dim1=-2, dim2=-1) -> Tensor
|
| See :func:`torch.diag_embed`
|
| diagflat(...)
| diagflat(offset=0) -> Tensor
|
| See :func:`torch.diagflat`
|
| diagonal(...)
| diagonal(offset=0, dim1=0, dim2=1) -> Tensor
|
| See :func:`torch.diagonal`
|
| diagonal_scatter(...)
| diagonal_scatter(src, offset=0, dim1=0, dim2=1) -> Tensor
|
| See :func:`torch.diagonal_scatter`
|
| diff(...)
| diff(n=1, dim=-1, prepend=None, append=None) -> Tensor
|
| See :func:`torch.diff`
|
| digamma(...)
| digamma() -> Tensor
|
| See :func:`torch.digamma`
|
| digamma_(...)
| digamma_() -> Tensor
|
| In-place version of :meth:`~Tensor.digamma`
|
| dim(...)
| dim() -> int
|
| Returns the number of dimensions of :attr:`self` tensor.
|
| dist(...)
| dist(other, p=2) -> Tensor
|
| See :func:`torch.dist`
|
| div(...)
| div(value, *, rounding_mode=None) -> Tensor
|
| See :func:`torch.div`
|
| div_(...)
| div_(value, *, rounding_mode=None) -> Tensor
|
| In-place version of :meth:`~Tensor.div`
|
| divide(...)
| divide(value, *, rounding_mode=None) -> Tensor
|
| See :func:`torch.divide`
|
| divide_(...)
| divide_(value, *, rounding_mode=None) -> Tensor
|
| In-place version of :meth:`~Tensor.divide`
|
| dot(...)
| dot(other) -> Tensor
|
| See :func:`torch.dot`
|
| double(...)
| double(memory_format=torch.preserve_format) -> Tensor
|
| ``self.double()`` is equivalent to ``self.to(torch.float64)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| dsplit(...)
| dsplit(split_size_or_sections) -> List of Tensors
|
| See :func:`torch.dsplit`
|
| element_size(...)
| element_size() -> int
|
| Returns the size in bytes of an individual element.
|
| Example::
|
| >>> torch.tensor([]).element_size()
| 4
| >>> torch.tensor([], dtype=torch.uint8).element_size()
| 1
|
| eq(...)
| eq(other) -> Tensor
|
| See :func:`torch.eq`
|
| eq_(...)
| eq_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.eq`
|
| equal(...)
| equal(other) -> bool
|
| See :func:`torch.equal`
|
| erf(...)
| erf() -> Tensor
|
| See :func:`torch.erf`
|
| erf_(...)
| erf_() -> Tensor
|
| In-place version of :meth:`~Tensor.erf`
|
| erfc(...)
| erfc() -> Tensor
|
| See :func:`torch.erfc`
|
| erfc_(...)
| erfc_() -> Tensor
|
| In-place version of :meth:`~Tensor.erfc`
|
| erfinv(...)
| erfinv() -> Tensor
|
| See :func:`torch.erfinv`
|
| erfinv_(...)
| erfinv_() -> Tensor
|
| In-place version of :meth:`~Tensor.erfinv`
|
| exp(...)
| exp() -> Tensor
|
| See :func:`torch.exp`
|
| exp2(...)
| exp2() -> Tensor
|
| See :func:`torch.exp2`
|
| exp2_(...)
| exp2_() -> Tensor
|
| In-place version of :meth:`~Tensor.exp2`
|
| exp_(...)
| exp_() -> Tensor
|
| In-place version of :meth:`~Tensor.exp`
|
| expand(...)
| expand(*sizes) -> Tensor
|
| Returns a new view of the :attr:`self` tensor with singleton dimensions expanded
| to a larger size.
|
| Passing -1 as the size for a dimension means not changing the size of
| that dimension.
|
| Tensor can be also expanded to a larger number of dimensions, and the
| new ones will be appended at the front. For the new dimensions, the
| size cannot be set to -1.
|
| Expanding a tensor does not allocate new memory, but only creates a
| new view on the existing tensor where a dimension of size one is
| expanded to a larger size by setting the ``stride`` to 0. Any dimension
| of size 1 can be expanded to an arbitrary value without allocating new
| memory.
|
| Args:
| *sizes (torch.Size or int...): the desired expanded size
|
| .. warning::
|
| More than one element of an expanded tensor may refer to a single
| memory location. As a result, in-place operations (especially ones that
| are vectorized) may result in incorrect behavior. If you need to write
| to the tensors, please clone them first.
|
| Example::
|
| >>> x = torch.tensor([[1], [2], [3]])
| >>> x.size()
| torch.Size([3, 1])
| >>> x.expand(3, 4)
| tensor([[ 1, 1, 1, 1],
| [ 2, 2, 2, 2],
| [ 3, 3, 3, 3]])
| >>> x.expand(-1, 4) # -1 means not changing the size of that dimension
| tensor([[ 1, 1, 1, 1],
| [ 2, 2, 2, 2],
| [ 3, 3, 3, 3]])
|
| expand_as(...)
| expand_as(other) -> Tensor
|
| Expand this tensor to the same size as :attr:`other`.
| ``self.expand_as(other)`` is equivalent to ``self.expand(other.size())``.
|
| Please see :meth:`~Tensor.expand` for more information about ``expand``.
|
| Args:
| other (:class:`torch.Tensor`): The result tensor has the same size
| as :attr:`other`.
|
| expm1(...)
| expm1() -> Tensor
|
| See :func:`torch.expm1`
|
| expm1_(...)
| expm1_() -> Tensor
|
| In-place version of :meth:`~Tensor.expm1`
|
| exponential_(...)
| exponential_(lambd=1, *, generator=None) -> Tensor
|
| Fills :attr:`self` tensor with elements drawn from the PDF (probability density function):
|
| .. math::
|
| f(x) = \lambda e^{-\lambda x}, x > 0
|
| .. note::
| In probability theory, exponential distribution is supported on interval [0, :math:`\inf`) (i.e., :math:`x >= 0`)
| implying that zero can be sampled from the exponential distribution.
| However, :func:`torch.Tensor.exponential_` does not sample zero,
| which means that its actual support is the interval (0, :math:`\inf`).
|
| Note that :func:`torch.distributions.exponential.Exponential` is supported on the interval [0, :math:`\inf`) and can sample zero.
|
| fill_(...)
| fill_(value) -> Tensor
|
| Fills :attr:`self` tensor with the specified value.
|
| fill_diagonal_(...)
| fill_diagonal_(fill_value, wrap=False) -> Tensor
|
| Fill the main diagonal of a tensor that has at least 2-dimensions.
| When dims>2, all dimensions of input must be of equal length.
| This function modifies the input tensor in-place, and returns the input tensor.
|
| Arguments:
| fill_value (Scalar): the fill value
| wrap (bool): the diagonal 'wrapped' after N columns for tall matrices.
|
| Example::
|
| >>> a = torch.zeros(3, 3)
| >>> a.fill_diagonal_(5)
| tensor([[5., 0., 0.],
| [0., 5., 0.],
| [0., 0., 5.]])
| >>> b = torch.zeros(7, 3)
| >>> b.fill_diagonal_(5)
| tensor([[5., 0., 0.],
| [0., 5., 0.],
| [0., 0., 5.],
| [0., 0., 0.],
| [0., 0., 0.],
| [0., 0., 0.],
| [0., 0., 0.]])
| >>> c = torch.zeros(7, 3)
| >>> c.fill_diagonal_(5, wrap=True)
| tensor([[5., 0., 0.],
| [0., 5., 0.],
| [0., 0., 5.],
| [0., 0., 0.],
| [5., 0., 0.],
| [0., 5., 0.],
| [0., 0., 5.]])
|
| fix(...)
| fix() -> Tensor
|
| See :func:`torch.fix`.
|
| fix_(...)
| fix_() -> Tensor
|
| In-place version of :meth:`~Tensor.fix`
|
| flatten(...)
| flatten(start_dim=0, end_dim=-1) -> Tensor
|
| See :func:`torch.flatten`
|
| flip(...)
| flip(dims) -> Tensor
|
| See :func:`torch.flip`
|
| fliplr(...)
| fliplr() -> Tensor
|
| See :func:`torch.fliplr`
|
| flipud(...)
| flipud() -> Tensor
|
| See :func:`torch.flipud`
|
| float(...)
| float(memory_format=torch.preserve_format) -> Tensor
|
| ``self.float()`` is equivalent to ``self.to(torch.float32)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| float_power(...)
| float_power(exponent) -> Tensor
|
| See :func:`torch.float_power`
|
| float_power_(...)
| float_power_(exponent) -> Tensor
|
| In-place version of :meth:`~Tensor.float_power`
|
| floor(...)
| floor() -> Tensor
|
| See :func:`torch.floor`
|
| floor_(...)
| floor_() -> Tensor
|
| In-place version of :meth:`~Tensor.floor`
|
| floor_divide(...)
| floor_divide(value) -> Tensor
|
| See :func:`torch.floor_divide`
|
| floor_divide_(...)
| floor_divide_(value) -> Tensor
|
| In-place version of :meth:`~Tensor.floor_divide`
|
| fmax(...)
| fmax(other) -> Tensor
|
| See :func:`torch.fmax`
|
| fmin(...)
| fmin(other) -> Tensor
|
| See :func:`torch.fmin`
|
| fmod(...)
| fmod(divisor) -> Tensor
|
| See :func:`torch.fmod`
|
| fmod_(...)
| fmod_(divisor) -> Tensor
|
| In-place version of :meth:`~Tensor.fmod`
|
| frac(...)
| frac() -> Tensor
|
| See :func:`torch.frac`
|
| frac_(...)
| frac_() -> Tensor
|
| In-place version of :meth:`~Tensor.frac`
|
| frexp(...)
| frexp(input) -> (Tensor mantissa, Tensor exponent)
|
| See :func:`torch.frexp`
|
| gather(...)
| gather(dim, index) -> Tensor
|
| See :func:`torch.gather`
|
| gcd(...)
| gcd(other) -> Tensor
|
| See :func:`torch.gcd`
|
| gcd_(...)
| gcd_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.gcd`
|
| ge(...)
| ge(other) -> Tensor
|
| See :func:`torch.ge`.
|
| ge_(...)
| ge_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.ge`.
|
| geometric_(...)
| geometric_(p, *, generator=None) -> Tensor
|
| Fills :attr:`self` tensor with elements drawn from the geometric distribution:
|
| .. math::
|
| P(X=k) = (1 - p)^{k - 1} p, k = 1, 2, ...
|
| .. note::
| :func:`torch.Tensor.geometric_` `k`-th trial is the first success hence draws samples in :math:`\{1, 2, \ldots\}`, whereas
| :func:`torch.distributions.geometric.Geometric` :math:`(k+1)`-th trial is the first success
| hence draws samples in :math:`\{0, 1, \ldots\}`.
|
| geqrf(...)
| geqrf() -> (Tensor, Tensor)
|
| See :func:`torch.geqrf`
|
| ger(...)
| ger(vec2) -> Tensor
|
| See :func:`torch.ger`
|
| get_device(...)
| get_device() -> Device ordinal (Integer)
|
| For CUDA tensors, this function returns the device ordinal of the GPU on which the tensor resides.
| For CPU tensors, this function returns `-1`.
|
| Example::
|
| >>> x = torch.randn(3, 4, 5, device='cuda:0')
| >>> x.get_device()
| 0
| >>> x.cpu().get_device()
| -1
|
| greater(...)
| greater(other) -> Tensor
|
| See :func:`torch.greater`.
|
| greater_(...)
| greater_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.greater`.
|
| greater_equal(...)
| greater_equal(other) -> Tensor
|
| See :func:`torch.greater_equal`.
|
| greater_equal_(...)
| greater_equal_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.greater_equal`.
|
| gt(...)
| gt(other) -> Tensor
|
| See :func:`torch.gt`.
|
| gt_(...)
| gt_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.gt`.
|
| half(...)
| half(memory_format=torch.preserve_format) -> Tensor
|
| ``self.half()`` is equivalent to ``self.to(torch.float16)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| hardshrink(...)
| hardshrink(lambd=0.5) -> Tensor
|
| See :func:`torch.nn.functional.hardshrink`
|
| has_names(...)
| Is ``True`` if any of this tensor's dimensions are named. Otherwise, is ``False``.
|
| heaviside(...)
| heaviside(values) -> Tensor
|
| See :func:`torch.heaviside`
|
| heaviside_(...)
| heaviside_(values) -> Tensor
|
| In-place version of :meth:`~Tensor.heaviside`
|
| histc(...)
| histc(bins=100, min=0, max=0) -> Tensor
|
| See :func:`torch.histc`
|
| histogram(...)
| histogram(input, bins, *, range=None, weight=None, density=False) -> (Tensor, Tensor)
|
| See :func:`torch.histogram`
|
| hsplit(...)
| hsplit(split_size_or_sections) -> List of Tensors
|
| See :func:`torch.hsplit`
|
| hypot(...)
| hypot(other) -> Tensor
|
| See :func:`torch.hypot`
|
| hypot_(...)
| hypot_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.hypot`
|
| i0(...)
| i0() -> Tensor
|
| See :func:`torch.i0`
|
| i0_(...)
| i0_() -> Tensor
|
| In-place version of :meth:`~Tensor.i0`
|
| igamma(...)
| igamma(other) -> Tensor
|
| See :func:`torch.igamma`
|
| igamma_(...)
| igamma_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.igamma`
|
| igammac(...)
| igammac(other) -> Tensor
| See :func:`torch.igammac`
|
| igammac_(...)
| igammac_(other) -> Tensor
| In-place version of :meth:`~Tensor.igammac`
|
| index_add(...)
| index_add(dim, index, source, *, alpha=1) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.index_add_`.
|
| index_add_(...)
| index_add_(dim, index, source, *, alpha=1) -> Tensor
|
| Accumulate the elements of :attr:`alpha` times ``source`` into the :attr:`self`
| tensor by adding to the indices in the order given in :attr:`index`. For example,
| if ``dim == 0``, ``index[i] == j``, and ``alpha=-1``, then the ``i``\ th row of
| ``source`` is subtracted from the ``j``\ th row of :attr:`self`.
|
| The :attr:`dim`\ th dimension of ``source`` must have the same size as the
| length of :attr:`index` (which must be a vector), and all other dimensions must
| match :attr:`self`, or an error will be raised.
|
| For a 3-D tensor the output is given as::
|
| self[index[i], :, :] += alpha * src[i, :, :] # if dim == 0
| self[:, index[i], :] += alpha * src[:, i, :] # if dim == 1
| self[:, :, index[i]] += alpha * src[:, :, i] # if dim == 2
|
| Note:
| This operation may behave nondeterministically when given tensors on a CUDA device. See :doc:`/notes/randomness` for more information.
|
| Args:
| dim (int): dimension along which to index
| index (Tensor): indices of ``source`` to select from,
| should have dtype either `torch.int64` or `torch.int32`
| source (Tensor): the tensor containing values to add
|
| Keyword args:
| alpha (Number): the scalar multiplier for ``source``
|
| Example::
|
| >>> x = torch.ones(5, 3)
| >>> t = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=torch.float)
| >>> index = torch.tensor([0, 4, 2])
| >>> x.index_add_(0, index, t)
| tensor([[ 2., 3., 4.],
| [ 1., 1., 1.],
| [ 8., 9., 10.],
| [ 1., 1., 1.],
| [ 5., 6., 7.]])
| >>> x.index_add_(0, index, t, alpha=-1)
| tensor([[ 1., 1., 1.],
| [ 1., 1., 1.],
| [ 1., 1., 1.],
| [ 1., 1., 1.],
| [ 1., 1., 1.]])
|
| index_copy(...)
| index_copy(dim, index, tensor2) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.index_copy_`.
|
| index_copy_(...)
| index_copy_(dim, index, tensor) -> Tensor
|
| Copies the elements of :attr:`tensor` into the :attr:`self` tensor by selecting
| the indices in the order given in :attr:`index`. For example, if ``dim == 0``
| and ``index[i] == j``, then the ``i``\ th row of :attr:`tensor` is copied to the
| ``j``\ th row of :attr:`self`.
|
| The :attr:`dim`\ th dimension of :attr:`tensor` must have the same size as the
| length of :attr:`index` (which must be a vector), and all other dimensions must
| match :attr:`self`, or an error will be raised.
|
| .. note::
| If :attr:`index` contains duplicate entries, multiple elements from
| :attr:`tensor` will be copied to the same index of :attr:`self`. The result
| is nondeterministic since it depends on which copy occurs last.
|
| Args:
| dim (int): dimension along which to index
| index (LongTensor): indices of :attr:`tensor` to select from
| tensor (Tensor): the tensor containing values to copy
|
| Example::
|
| >>> x = torch.zeros(5, 3)
| >>> t = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=torch.float)
| >>> index = torch.tensor([0, 4, 2])
| >>> x.index_copy_(0, index, t)
| tensor([[ 1., 2., 3.],
| [ 0., 0., 0.],
| [ 7., 8., 9.],
| [ 0., 0., 0.],
| [ 4., 5., 6.]])
|
| index_fill(...)
| index_fill(dim, index, value) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.index_fill_`.
|
| index_fill_(...)
| index_fill_(dim, index, value) -> Tensor
|
| Fills the elements of the :attr:`self` tensor with value :attr:`value` by
| selecting the indices in the order given in :attr:`index`.
|
| Args:
| dim (int): dimension along which to index
| index (LongTensor): indices of :attr:`self` tensor to fill in
| value (float): the value to fill with
|
| Example::
| >>> x = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=torch.float)
| >>> index = torch.tensor([0, 2])
| >>> x.index_fill_(1, index, -1)
| tensor([[-1., 2., -1.],
| [-1., 5., -1.],
| [-1., 8., -1.]])
|
| index_put(...)
| index_put(indices, values, accumulate=False) -> Tensor
|
| Out-place version of :meth:`~Tensor.index_put_`.
|
| index_put_(...)
| index_put_(indices, values, accumulate=False) -> Tensor
|
| Puts values from the tensor :attr:`values` into the tensor :attr:`self` using
| the indices specified in :attr:`indices` (which is a tuple of Tensors). The
| expression ``tensor.index_put_(indices, values)`` is equivalent to
| ``tensor[indices] = values``. Returns :attr:`self`.
|
| If :attr:`accumulate` is ``True``, the elements in :attr:`values` are added to
| :attr:`self`. If accumulate is ``False``, the behavior is undefined if indices
| contain duplicate elements.
|
| Args:
| indices (tuple of LongTensor): tensors used to index into `self`.
| values (Tensor): tensor of same dtype as `self`.
| accumulate (bool): whether to accumulate into self
|
| index_reduce(...)
|
| index_reduce_(...)
| index_reduce_(dim, index, source, reduce, *, include_self=True) -> Tensor
|
| Accumulate the elements of ``source`` into the :attr:`self`
| tensor by accumulating to the indices in the order given in :attr:`index`
| using the reduction given by the ``reduce`` argument. For example, if ``dim == 0``,
| ``index[i] == j``, ``reduce == prod`` and ``include_self == True`` then the ``i``\ th
| row of ``source`` is multiplied by the ``j``\ th row of :attr:`self`. If
| :obj:`include_self="True"`, the values in the :attr:`self` tensor are included
| in the reduction, otherwise, rows in the :attr:`self` tensor that are accumulated
| to are treated as if they were filled with the reduction identites.
|
| The :attr:`dim`\ th dimension of ``source`` must have the same size as the
| length of :attr:`index` (which must be a vector), and all other dimensions must
| match :attr:`self`, or an error will be raised.
|
| For a 3-D tensor with :obj:`reduce="prod"` and :obj:`include_self=True` the
| output is given as::
|
| self[index[i], :, :] *= src[i, :, :] # if dim == 0
| self[:, index[i], :] *= src[:, i, :] # if dim == 1
| self[:, :, index[i]] *= src[:, :, i] # if dim == 2
|
| Note:
| This operation may behave nondeterministically when given tensors on a CUDA device. See :doc:`/notes/randomness` for more information.
|
| .. note::
|
| This function only supports floating point tensors.
|
| .. warning::
|
| This function is in beta and may change in the near future.
|
| Args:
| dim (int): dimension along which to index
| index (Tensor): indices of ``source`` to select from,
| should have dtype either `torch.int64` or `torch.int32`
| source (FloatTensor): the tensor containing values to accumulate
| reduce (str): the reduction operation to apply
| (:obj:`"prod"`, :obj:`"mean"`, :obj:`"amax"`, :obj:`"amin"`)
|
| Keyword args:
| include_self (bool): whether the elements from the ``self`` tensor are
| included in the reduction
|
| Example::
|
| >>> x = torch.empty(5, 3).fill_(2)
| >>> t = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], dtype=torch.float)
| >>> index = torch.tensor([0, 4, 2, 0])
| >>> x.index_reduce_(0, index, t, 'prod')
| tensor([[20., 44., 72.],
| [ 2., 2., 2.],
| [14., 16., 18.],
| [ 2., 2., 2.],
| [ 8., 10., 12.]])
| >>> x = torch.empty(5, 3).fill_(2)
| >>> x.index_reduce_(0, index, t, 'prod', include_self=False)
| tensor([[10., 22., 36.],
| [ 2., 2., 2.],
| [ 7., 8., 9.],
| [ 2., 2., 2.],
| [ 4., 5., 6.]])
|
| index_select(...)
| index_select(dim, index) -> Tensor
|
| See :func:`torch.index_select`
|
| indices(...)
| indices() -> Tensor
|
| Return the indices tensor of a :ref:`sparse COO tensor <sparse-coo-docs>`.
|
| .. warning::
| Throws an error if :attr:`self` is not a sparse COO tensor.
|
| See also :meth:`Tensor.values`.
|
| .. note::
| This method can only be called on a coalesced sparse tensor. See
| :meth:`Tensor.coalesce` for details.
|
| inner(...)
| inner(other) -> Tensor
|
| See :func:`torch.inner`.
|
| int(...)
| int(memory_format=torch.preserve_format) -> Tensor
|
| ``self.int()`` is equivalent to ``self.to(torch.int32)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| int_repr(...)
| int_repr() -> Tensor
|
| Given a quantized Tensor,
| ``self.int_repr()`` returns a CPU Tensor with uint8_t as data type that stores the
| underlying uint8_t values of the given Tensor.
|
| inverse(...)
| inverse() -> Tensor
|
| See :func:`torch.inverse`
|
| ipu(...)
| ipu(device=None, non_blocking=False, memory_format=torch.preserve_format) -> Tensor
|
| Returns a copy of this object in IPU memory.
|
| If this object is already in IPU memory and on the correct device,
| then no copy is performed and the original object is returned.
|
| Args:
| device (:class:`torch.device`): The destination IPU device.
| Defaults to the current IPU device.
| non_blocking (bool): If ``True`` and the source is in pinned memory,
| the copy will be asynchronous with respect to the host.
| Otherwise, the argument has no effect. Default: ``False``.
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| is_coalesced(...)
| is_coalesced() -> bool
|
| Returns ``True`` if :attr:`self` is a :ref:`sparse COO tensor
| <sparse-coo-docs>` that is coalesced, ``False`` otherwise.
|
| .. warning::
| Throws an error if :attr:`self` is not a sparse COO tensor.
|
| See :meth:`coalesce` and :ref:`uncoalesced tensors <sparse-uncoalesced-coo-docs>`.
|
| is_complex(...)
| is_complex() -> bool
|
| Returns True if the data type of :attr:`self` is a complex data type.
|
| is_conj(...)
| is_conj() -> bool
|
| Returns True if the conjugate bit of :attr:`self` is set to true.
|
| is_contiguous(...)
| is_contiguous(memory_format=torch.contiguous_format) -> bool
|
| Returns True if :attr:`self` tensor is contiguous in memory in the order specified
| by memory format.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): Specifies memory allocation
| order. Default: ``torch.contiguous_format``.
|
| is_distributed(...)
|
| is_floating_point(...)
| is_floating_point() -> bool
|
| Returns True if the data type of :attr:`self` is a floating point data type.
|
| is_inference(...)
| is_inference() -> bool
|
| See :func:`torch.is_inference`
|
| is_neg(...)
| is_neg() -> bool
|
| Returns True if the negative bit of :attr:`self` is set to true.
|
| is_nonzero(...)
|
| is_pinned(...)
| Returns true if this tensor resides in pinned memory.
|
| is_same_size(...)
|
| is_set_to(...)
| is_set_to(tensor) -> bool
|
| Returns True if both tensors are pointing to the exact same memory (same
| storage, offset, size and stride).
|
| is_signed(...)
| is_signed() -> bool
|
| Returns True if the data type of :attr:`self` is a signed data type.
|
| isclose(...)
| isclose(other, rtol=1e-05, atol=1e-08, equal_nan=False) -> Tensor
|
| See :func:`torch.isclose`
|
| isfinite(...)
| isfinite() -> Tensor
|
| See :func:`torch.isfinite`
|
| isinf(...)
| isinf() -> Tensor
|
| See :func:`torch.isinf`
|
| isnan(...)
| isnan() -> Tensor
|
| See :func:`torch.isnan`
|
| isneginf(...)
| isneginf() -> Tensor
|
| See :func:`torch.isneginf`
|
| isposinf(...)
| isposinf() -> Tensor
|
| See :func:`torch.isposinf`
|
| isreal(...)
| isreal() -> Tensor
|
| See :func:`torch.isreal`
|
| item(...)
| item() -> number
|
| Returns the value of this tensor as a standard Python number. This only works
| for tensors with one element. For other cases, see :meth:`~Tensor.tolist`.
|
| This operation is not differentiable.
|
| Example::
|
| >>> x = torch.tensor([1.0])
| >>> x.item()
| 1.0
|
| kron(...)
| kron(other) -> Tensor
|
| See :func:`torch.kron`
|
| kthvalue(...)
| kthvalue(k, dim=None, keepdim=False) -> (Tensor, LongTensor)
|
| See :func:`torch.kthvalue`
|
| lcm(...)
| lcm(other) -> Tensor
|
| See :func:`torch.lcm`
|
| lcm_(...)
| lcm_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.lcm`
|
| ldexp(...)
| ldexp(other) -> Tensor
|
| See :func:`torch.ldexp`
|
| ldexp_(...)
| ldexp_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.ldexp`
|
| le(...)
| le(other) -> Tensor
|
| See :func:`torch.le`.
|
| le_(...)
| le_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.le`.
|
| lerp(...)
| lerp(end, weight) -> Tensor
|
| See :func:`torch.lerp`
|
| lerp_(...)
| lerp_(end, weight) -> Tensor
|
| In-place version of :meth:`~Tensor.lerp`
|
| less(...)
| lt(other) -> Tensor
|
| See :func:`torch.less`.
|
| less_(...)
| less_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.less`.
|
| less_equal(...)
| less_equal(other) -> Tensor
|
| See :func:`torch.less_equal`.
|
| less_equal_(...)
| less_equal_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.less_equal`.
|
| lgamma(...)
| lgamma() -> Tensor
|
| See :func:`torch.lgamma`
|
| lgamma_(...)
| lgamma_() -> Tensor
|
| In-place version of :meth:`~Tensor.lgamma`
|
| log(...)
| log() -> Tensor
|
| See :func:`torch.log`
|
| log10(...)
| log10() -> Tensor
|
| See :func:`torch.log10`
|
| log10_(...)
| log10_() -> Tensor
|
| In-place version of :meth:`~Tensor.log10`
|
| log1p(...)
| log1p() -> Tensor
|
| See :func:`torch.log1p`
|
| log1p_(...)
| log1p_() -> Tensor
|
| In-place version of :meth:`~Tensor.log1p`
|
| log2(...)
| log2() -> Tensor
|
| See :func:`torch.log2`
|
| log2_(...)
| log2_() -> Tensor
|
| In-place version of :meth:`~Tensor.log2`
|
| log_(...)
| log_() -> Tensor
|
| In-place version of :meth:`~Tensor.log`
|
| log_normal_(...)
| log_normal_(mean=1, std=2, *, generator=None)
|
| Fills :attr:`self` tensor with numbers samples from the log-normal distribution
| parameterized by the given mean :math:`\mu` and standard deviation
| :math:`\sigma`. Note that :attr:`mean` and :attr:`std` are the mean and
| standard deviation of the underlying normal distribution, and not of the
| returned distribution:
|
| .. math::
|
| f(x) = \dfrac{1}{x \sigma \sqrt{2\pi}}\ e^{-\frac{(\ln x - \mu)^2}{2\sigma^2}}
|
| log_softmax(...)
|
| logaddexp(...)
| logaddexp(other) -> Tensor
|
| See :func:`torch.logaddexp`
|
| logaddexp2(...)
| logaddexp2(other) -> Tensor
|
| See :func:`torch.logaddexp2`
|
| logcumsumexp(...)
| logcumsumexp(dim) -> Tensor
|
| See :func:`torch.logcumsumexp`
|
| logdet(...)
| logdet() -> Tensor
|
| See :func:`torch.logdet`
|
| logical_and(...)
| logical_and() -> Tensor
|
| See :func:`torch.logical_and`
|
| logical_and_(...)
| logical_and_() -> Tensor
|
| In-place version of :meth:`~Tensor.logical_and`
|
| logical_not(...)
| logical_not() -> Tensor
|
| See :func:`torch.logical_not`
|
| logical_not_(...)
| logical_not_() -> Tensor
|
| In-place version of :meth:`~Tensor.logical_not`
|
| logical_or(...)
| logical_or() -> Tensor
|
| See :func:`torch.logical_or`
|
| logical_or_(...)
| logical_or_() -> Tensor
|
| In-place version of :meth:`~Tensor.logical_or`
|
| logical_xor(...)
| logical_xor() -> Tensor
|
| See :func:`torch.logical_xor`
|
| logical_xor_(...)
| logical_xor_() -> Tensor
|
| In-place version of :meth:`~Tensor.logical_xor`
|
| logit(...)
| logit() -> Tensor
|
| See :func:`torch.logit`
|
| logit_(...)
| logit_() -> Tensor
|
| In-place version of :meth:`~Tensor.logit`
|
| logsumexp(...)
| logsumexp(dim, keepdim=False) -> Tensor
|
| See :func:`torch.logsumexp`
|
| long(...)
| long(memory_format=torch.preserve_format) -> Tensor
|
| ``self.long()`` is equivalent to ``self.to(torch.int64)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| lt(...)
| lt(other) -> Tensor
|
| See :func:`torch.lt`.
|
| lt_(...)
| lt_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.lt`.
|
| lu_solve(...)
| lu_solve(LU_data, LU_pivots) -> Tensor
|
| See :func:`torch.lu_solve`
|
| map2_(...)
|
| map_(...)
| map_(tensor, callable)
|
| Applies :attr:`callable` for each element in :attr:`self` tensor and the given
| :attr:`tensor` and stores the results in :attr:`self` tensor. :attr:`self` tensor and
| the given :attr:`tensor` must be :ref:`broadcastable <broadcasting-semantics>`.
|
| The :attr:`callable` should have the signature::
|
| def callable(a, b) -> number
|
| masked_fill(...)
| masked_fill(mask, value) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.masked_fill_`
|
| masked_fill_(...)
| masked_fill_(mask, value)
|
| Fills elements of :attr:`self` tensor with :attr:`value` where :attr:`mask` is
| True. The shape of :attr:`mask` must be
| :ref:`broadcastable <broadcasting-semantics>` with the shape of the underlying
| tensor.
|
| Args:
| mask (BoolTensor): the boolean mask
| value (float): the value to fill in with
|
| masked_scatter(...)
| masked_scatter(mask, tensor) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.masked_scatter_`
|
| .. note::
|
| The inputs :attr:`self` and :attr:`mask`
| :ref:`broadcast <broadcasting-semantics>`.
|
| Example:
|
| >>> self = torch.tensor([0, 0, 0, 0, 0])
| >>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]])
| >>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
| >>> self.masked_scatter(mask, source)
| tensor([[0, 0, 0, 0, 1],
| [2, 3, 0, 4, 5]])
|
| masked_scatter_(...)
| masked_scatter_(mask, source)
|
| Copies elements from :attr:`source` into :attr:`self` tensor at positions where
| the :attr:`mask` is True. Elements from :attr:`source` are copied into :attr:`self`
| starting at position 0 of :attr:`source` and continuing in order one-by-one for each
| occurrence of :attr:`mask` being True.
| The shape of :attr:`mask` must be :ref:`broadcastable <broadcasting-semantics>`
| with the shape of the underlying tensor. The :attr:`source` should have at least
| as many elements as the number of ones in :attr:`mask`.
|
| Args:
| mask (BoolTensor): the boolean mask
| source (Tensor): the tensor to copy from
|
| .. note::
|
| The :attr:`mask` operates on the :attr:`self` tensor, not on the given
| :attr:`source` tensor.
|
| Example:
|
| >>> self = torch.tensor([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
| >>> mask = torch.tensor([[0, 0, 0, 1, 1], [1, 1, 0, 1, 1]])
| >>> source = torch.tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
| >>> self.masked_scatter_(mask, source)
| tensor([[0, 0, 0, 0, 1],
| [2, 3, 0, 4, 5]])
|
| masked_select(...)
| masked_select(mask) -> Tensor
|
| See :func:`torch.masked_select`
|
| matmul(...)
| matmul(tensor2) -> Tensor
|
| See :func:`torch.matmul`
|
| matrix_exp(...)
| matrix_exp() -> Tensor
|
| See :func:`torch.matrix_exp`
|
| matrix_power(...)
| matrix_power(n) -> Tensor
|
| .. note:: :meth:`~Tensor.matrix_power` is deprecated, use :func:`torch.linalg.matrix_power` instead.
|
| Alias for :func:`torch.linalg.matrix_power`
|
| max(...)
| max(dim=None, keepdim=False) -> Tensor or (Tensor, Tensor)
|
| See :func:`torch.max`
|
| maximum(...)
| maximum(other) -> Tensor
|
| See :func:`torch.maximum`
|
| mean(...)
| mean(dim=None, keepdim=False, *, dtype=None) -> Tensor
|
| See :func:`torch.mean`
|
| median(...)
| median(dim=None, keepdim=False) -> (Tensor, LongTensor)
|
| See :func:`torch.median`
|
| min(...)
| min(dim=None, keepdim=False) -> Tensor or (Tensor, Tensor)
|
| See :func:`torch.min`
|
| minimum(...)
| minimum(other) -> Tensor
|
| See :func:`torch.minimum`
|
| mm(...)
| mm(mat2) -> Tensor
|
| See :func:`torch.mm`
|
| mode(...)
| mode(dim=None, keepdim=False) -> (Tensor, LongTensor)
|
| See :func:`torch.mode`
|
| moveaxis(...)
| moveaxis(source, destination) -> Tensor
|
| See :func:`torch.moveaxis`
|
| movedim(...)
| movedim(source, destination) -> Tensor
|
| See :func:`torch.movedim`
|
| msort(...)
| msort() -> Tensor
|
| See :func:`torch.msort`
|
| mul(...)
| mul(value) -> Tensor
|
| See :func:`torch.mul`.
|
| mul_(...)
| mul_(value) -> Tensor
|
| In-place version of :meth:`~Tensor.mul`.
|
| multinomial(...)
| multinomial(num_samples, replacement=False, *, generator=None) -> Tensor
|
| See :func:`torch.multinomial`
|
| multiply(...)
| multiply(value) -> Tensor
|
| See :func:`torch.multiply`.
|
| multiply_(...)
| multiply_(value) -> Tensor
|
| In-place version of :meth:`~Tensor.multiply`.
|
| mv(...)
| mv(vec) -> Tensor
|
| See :func:`torch.mv`
|
| mvlgamma(...)
| mvlgamma(p) -> Tensor
|
| See :func:`torch.mvlgamma`
|
| mvlgamma_(...)
| mvlgamma_(p) -> Tensor
|
| In-place version of :meth:`~Tensor.mvlgamma`
|
| nan_to_num(...)
| nan_to_num(nan=0.0, posinf=None, neginf=None) -> Tensor
|
| See :func:`torch.nan_to_num`.
|
| nan_to_num_(...)
| nan_to_num_(nan=0.0, posinf=None, neginf=None) -> Tensor
|
| In-place version of :meth:`~Tensor.nan_to_num`.
|
| nanmean(...)
| nanmean(dim=None, keepdim=False, *, dtype=None) -> Tensor
|
| See :func:`torch.nanmean`
|
| nanmedian(...)
| nanmedian(dim=None, keepdim=False) -> (Tensor, LongTensor)
|
| See :func:`torch.nanmedian`
|
| nanquantile(...)
| nanquantile(q, dim=None, keepdim=False, *, interpolation='linear') -> Tensor
|
| See :func:`torch.nanquantile`
|
| nansum(...)
| nansum(dim=None, keepdim=False, dtype=None) -> Tensor
|
| See :func:`torch.nansum`
|
| narrow(...)
| narrow(dimension, start, length) -> Tensor
|
| See :func:`torch.narrow`.
|
| narrow_copy(...)
| narrow_copy(dimension, start, length) -> Tensor
|
| See :func:`torch.narrow_copy`.
|
| ndimension(...)
| ndimension() -> int
|
| Alias for :meth:`~Tensor.dim()`
|
| ne(...)
| ne(other) -> Tensor
|
| See :func:`torch.ne`.
|
| ne_(...)
| ne_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.ne`.
|
| neg(...)
| neg() -> Tensor
|
| See :func:`torch.neg`
|
| neg_(...)
| neg_() -> Tensor
|
| In-place version of :meth:`~Tensor.neg`
|
| negative(...)
| negative() -> Tensor
|
| See :func:`torch.negative`
|
| negative_(...)
| negative_() -> Tensor
|
| In-place version of :meth:`~Tensor.negative`
|
| nelement(...)
| nelement() -> int
|
| Alias for :meth:`~Tensor.numel`
|
| new(...)
|
| new_empty(...)
| new_empty(size, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a Tensor of size :attr:`size` filled with uninitialized data.
| By default, the returned Tensor has the same :class:`torch.dtype` and
| :class:`torch.device` as this tensor.
|
| Args:
| size (int...): a list, tuple, or :class:`torch.Size` of integers defining the
| shape of the output tensor.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.ones(())
| >>> tensor.new_empty((2, 3))
| tensor([[ 5.8182e-18, 4.5765e-41, -1.0545e+30],
| [ 3.0949e-41, 4.4842e-44, 0.0000e+00]])
|
| new_empty_strided(...)
| new_empty_strided(size, stride, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a Tensor of size :attr:`size` and strides :attr:`stride` filled with
| uninitialized data. By default, the returned Tensor has the same
| :class:`torch.dtype` and :class:`torch.device` as this tensor.
|
| Args:
| size (int...): a list, tuple, or :class:`torch.Size` of integers defining the
| shape of the output tensor.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.ones(())
| >>> tensor.new_empty_strided((2, 3), (3, 1))
| tensor([[ 5.8182e-18, 4.5765e-41, -1.0545e+30],
| [ 3.0949e-41, 4.4842e-44, 0.0000e+00]])
|
| new_full(...)
| new_full(size, fill_value, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a Tensor of size :attr:`size` filled with :attr:`fill_value`.
| By default, the returned Tensor has the same :class:`torch.dtype` and
| :class:`torch.device` as this tensor.
|
| Args:
| fill_value (scalar): the number to fill the output tensor with.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.ones((2,), dtype=torch.float64)
| >>> tensor.new_full((3, 4), 3.141592)
| tensor([[ 3.1416, 3.1416, 3.1416, 3.1416],
| [ 3.1416, 3.1416, 3.1416, 3.1416],
| [ 3.1416, 3.1416, 3.1416, 3.1416]], dtype=torch.float64)
|
| new_ones(...)
| new_ones(size, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a Tensor of size :attr:`size` filled with ``1``.
| By default, the returned Tensor has the same :class:`torch.dtype` and
| :class:`torch.device` as this tensor.
|
| Args:
| size (int...): a list, tuple, or :class:`torch.Size` of integers defining the
| shape of the output tensor.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.tensor((), dtype=torch.int32)
| >>> tensor.new_ones((2, 3))
| tensor([[ 1, 1, 1],
| [ 1, 1, 1]], dtype=torch.int32)
|
| new_tensor(...)
| new_tensor(data, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a new Tensor with :attr:`data` as the tensor data.
| By default, the returned Tensor has the same :class:`torch.dtype` and
| :class:`torch.device` as this tensor.
|
| .. warning::
|
| :func:`new_tensor` always copies :attr:`data`. If you have a Tensor
| ``data`` and want to avoid a copy, use :func:`torch.Tensor.requires_grad_`
| or :func:`torch.Tensor.detach`.
| If you have a numpy array and want to avoid a copy, use
| :func:`torch.from_numpy`.
|
| .. warning::
|
| When data is a tensor `x`, :func:`new_tensor()` reads out 'the data' from whatever it is passed,
| and constructs a leaf variable. Therefore ``tensor.new_tensor(x)`` is equivalent to ``x.clone().detach()``
| and ``tensor.new_tensor(x, requires_grad=True)`` is equivalent to ``x.clone().detach().requires_grad_(True)``.
| The equivalents using ``clone()`` and ``detach()`` are recommended.
|
| Args:
| data (array_like): The returned Tensor copies :attr:`data`.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.ones((2,), dtype=torch.int8)
| >>> data = [[0, 1], [2, 3]]
| >>> tensor.new_tensor(data)
| tensor([[ 0, 1],
| [ 2, 3]], dtype=torch.int8)
|
| new_zeros(...)
| new_zeros(size, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) -> Tensor
|
|
| Returns a Tensor of size :attr:`size` filled with ``0``.
| By default, the returned Tensor has the same :class:`torch.dtype` and
| :class:`torch.device` as this tensor.
|
| Args:
| size (int...): a list, tuple, or :class:`torch.Size` of integers defining the
| shape of the output tensor.
|
| Keyword args:
| dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.
| Default: if None, same :class:`torch.dtype` as this tensor.
| device (:class:`torch.device`, optional): the desired device of returned tensor.
| Default: if None, same :class:`torch.device` as this tensor.
| requires_grad (bool, optional): If autograd should record operations on the
| returned tensor. Default: ``False``.
| layout (:class:`torch.layout`, optional): the desired layout of returned Tensor.
| Default: ``torch.strided``.
| pin_memory (bool, optional): If set, returned tensor would be allocated in
| the pinned memory. Works only for CPU tensors. Default: ``False``.
|
| Example::
|
| >>> tensor = torch.tensor((), dtype=torch.float64)
| >>> tensor.new_zeros((2, 3))
| tensor([[ 0., 0., 0.],
| [ 0., 0., 0.]], dtype=torch.float64)
|
| nextafter(...)
| nextafter(other) -> Tensor
| See :func:`torch.nextafter`
|
| nextafter_(...)
| nextafter_(other) -> Tensor
| In-place version of :meth:`~Tensor.nextafter`
|
| nonzero(...)
| nonzero() -> LongTensor
|
| See :func:`torch.nonzero`
|
| nonzero_static(...)
| nonzero_static(input, *, size, fill_value=-1) -> Tensor
|
| Returns a 2-D tensor where each row is the index for a non-zero value.
| The returned Tensor has the same `torch.dtype` as `torch.nonzero()`.
|
| Args:
| input (Tensor): the input tensor to count non-zero elements.
|
| Keyword args:
| size (int): the size of non-zero elements expected to be included in the out
| tensor. Pad the out tensor with `fill_value` if the `size` is larger
| than total number of non-zero elements, truncate out tensor if `size`
| is smaller. The size must be a non-negative integer.
| fill_value (int): the value to fill the output tensor with when `size` is larger
| than the total number of non-zero elements. Default is `-1` to represent
| invalid index.
|
| Example:
|
| # Example 1: Padding
| >>> input_tensor = torch.tensor([[1, 0], [3, 2]])
| >>> static_size = 4
| >>> t = torch.nonzero_static(input_tensor, size = static_size)
| tensor([[ 0, 0],
| [ 1, 0],
| [ 1, 1],
| [ -1, -1]], dtype=torch.int64)
|
| # Example 2: Truncating
| >>> input_tensor = torch.tensor([[1, 0], [3, 2]])
| >>> static_size = 2
| >>> t = torch.nonzero_static(input_tensor, size = static_size)
| tensor([[ 0, 0],
| [ 1, 0]], dtype=torch.int64)
|
| # Example 3: 0 size
| >>> input_tensor = torch.tensor([10])
| >>> static_size = 0
| >>> t = torch.nonzero_static(input_tensor, size = static_size)
| tensor([], size=(0, 1), dtype=torch.int64)
|
| # Example 4: 0 rank input
| >>> input_tensor = torch.tensor(10)
| >>> static_size = 2
| >>> t = torch.nonzero_static(input_tensor, size = static_size)
| tensor([], size=(2, 0), dtype=torch.int64)
|
| normal_(...)
| normal_(mean=0, std=1, *, generator=None) -> Tensor
|
| Fills :attr:`self` tensor with elements samples from the normal distribution
| parameterized by :attr:`mean` and :attr:`std`.
|
| not_equal(...)
| not_equal(other) -> Tensor
|
| See :func:`torch.not_equal`.
|
| not_equal_(...)
| not_equal_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.not_equal`.
|
| numel(...)
| numel() -> int
|
| See :func:`torch.numel`
|
| numpy(...)
| numpy(*, force=False) -> numpy.ndarray
|
| Returns the tensor as a NumPy :class:`ndarray`.
|
| If :attr:`force` is ``False`` (the default), the conversion
| is performed only if the tensor is on the CPU, does not require grad,
| does not have its conjugate bit set, and is a dtype and layout that
| NumPy supports. The returned ndarray and the tensor will share their
| storage, so changes to the tensor will be reflected in the ndarray
| and vice versa.
|
| If :attr:`force` is ``True`` this is equivalent to
| calling ``t.detach().cpu().resolve_conj().resolve_neg().numpy()``.
| If the tensor isn't on the CPU or the conjugate or negative bit is set,
| the tensor won't share its storage with the returned ndarray.
| Setting :attr:`force` to ``True`` can be a useful shorthand.
|
| Args:
| force (bool): if ``True``, the ndarray may be a copy of the tensor
| instead of always sharing memory, defaults to ``False``.
|
| orgqr(...)
| orgqr(input2) -> Tensor
|
| See :func:`torch.orgqr`
|
| ormqr(...)
| ormqr(input2, input3, left=True, transpose=False) -> Tensor
|
| See :func:`torch.ormqr`
|
| outer(...)
| outer(vec2) -> Tensor
|
| See :func:`torch.outer`.
|
| permute(...)
| permute(*dims) -> Tensor
|
| See :func:`torch.permute`
|
| pin_memory(...)
| pin_memory() -> Tensor
|
| Copies the tensor to pinned memory, if it's not already pinned.
|
| pinverse(...)
| pinverse() -> Tensor
|
| See :func:`torch.pinverse`
|
| polygamma(...)
| polygamma(n) -> Tensor
|
| See :func:`torch.polygamma`
|
| polygamma_(...)
| polygamma_(n) -> Tensor
|
| In-place version of :meth:`~Tensor.polygamma`
|
| positive(...)
| positive() -> Tensor
|
| See :func:`torch.positive`
|
| pow(...)
| pow(exponent) -> Tensor
|
| See :func:`torch.pow`
|
| pow_(...)
| pow_(exponent) -> Tensor
|
| In-place version of :meth:`~Tensor.pow`
|
| prelu(...)
|
| prod(...)
| prod(dim=None, keepdim=False, dtype=None) -> Tensor
|
| See :func:`torch.prod`
|
| put(...)
| put(input, index, source, accumulate=False) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.put_`.
| `input` corresponds to `self` in :meth:`torch.Tensor.put_`.
|
| put_(...)
| put_(index, source, accumulate=False) -> Tensor
|
| Copies the elements from :attr:`source` into the positions specified by
| :attr:`index`. For the purpose of indexing, the :attr:`self` tensor is treated as if
| it were a 1-D tensor.
|
| :attr:`index` and :attr:`source` need to have the same number of elements, but not necessarily
| the same shape.
|
| If :attr:`accumulate` is ``True``, the elements in :attr:`source` are added to
| :attr:`self`. If accumulate is ``False``, the behavior is undefined if :attr:`index`
| contain duplicate elements.
|
| Args:
| index (LongTensor): the indices into self
| source (Tensor): the tensor containing values to copy from
| accumulate (bool): whether to accumulate into self
|
| Example::
|
| >>> src = torch.tensor([[4, 3, 5],
| ... [6, 7, 8]])
| >>> src.put_(torch.tensor([1, 3]), torch.tensor([9, 10]))
| tensor([[ 4, 9, 5],
| [ 10, 7, 8]])
|
| q_per_channel_axis(...)
| q_per_channel_axis() -> int
|
| Given a Tensor quantized by linear (affine) per-channel quantization,
| returns the index of dimension on which per-channel quantization is applied.
|
| q_per_channel_scales(...)
| q_per_channel_scales() -> Tensor
|
| Given a Tensor quantized by linear (affine) per-channel quantization,
| returns a Tensor of scales of the underlying quantizer. It has the number of
| elements that matches the corresponding dimensions (from q_per_channel_axis) of
| the tensor.
|
| q_per_channel_zero_points(...)
| q_per_channel_zero_points() -> Tensor
|
| Given a Tensor quantized by linear (affine) per-channel quantization,
| returns a tensor of zero_points of the underlying quantizer. It has the number of
| elements that matches the corresponding dimensions (from q_per_channel_axis) of
| the tensor.
|
| q_scale(...)
| q_scale() -> float
|
| Given a Tensor quantized by linear(affine) quantization,
| returns the scale of the underlying quantizer().
|
| q_zero_point(...)
| q_zero_point() -> int
|
| Given a Tensor quantized by linear(affine) quantization,
| returns the zero_point of the underlying quantizer().
|
| qr(...)
| qr(some=True) -> (Tensor, Tensor)
|
| See :func:`torch.qr`
|
| qscheme(...)
| qscheme() -> torch.qscheme
|
| Returns the quantization scheme of a given QTensor.
|
| quantile(...)
| quantile(q, dim=None, keepdim=False, *, interpolation='linear') -> Tensor
|
| See :func:`torch.quantile`
|
| rad2deg(...)
| rad2deg() -> Tensor
|
| See :func:`torch.rad2deg`
|
| rad2deg_(...)
| rad2deg_() -> Tensor
|
| In-place version of :meth:`~Tensor.rad2deg`
|
| random_(...)
| random_(from=0, to=None, *, generator=None) -> Tensor
|
| Fills :attr:`self` tensor with numbers sampled from the discrete uniform
| distribution over ``[from, to - 1]``. If not specified, the values are usually
| only bounded by :attr:`self` tensor's data type. However, for floating point
| types, if unspecified, range will be ``[0, 2^mantissa]`` to ensure that every
| value is representable. For example, `torch.tensor(1, dtype=torch.double).random_()`
| will be uniform in ``[0, 2^53]``.
|
| ravel(...)
| ravel() -> Tensor
|
| see :func:`torch.ravel`
|
| reciprocal(...)
| reciprocal() -> Tensor
|
| See :func:`torch.reciprocal`
|
| reciprocal_(...)
| reciprocal_() -> Tensor
|
| In-place version of :meth:`~Tensor.reciprocal`
|
| record_stream(...)
| record_stream(stream)
|
| Marks the tensor as having been used by this stream. When the tensor
| is deallocated, ensure the tensor memory is not reused for another tensor
| until all work queued on :attr:`stream` at the time of deallocation is
| complete.
|
| .. note::
|
| The caching allocator is aware of only the stream where a tensor was
| allocated. Due to the awareness, it already correctly manages the life
| cycle of tensors on only one stream. But if a tensor is used on a stream
| different from the stream of origin, the allocator might reuse the memory
| unexpectedly. Calling this method lets the allocator know which streams
| have used the tensor.
|
| .. warning::
|
| This method is most suitable for use cases where you are providing a
| function that created a tensor on a side stream, and want users to be able
| to make use of the tensor without having to think carefully about stream
| safety when making use of them. These safety guarantees come at some
| performance and predictability cost (analogous to the tradeoff between GC
| and manual memory management), so if you are in a situation where
| you manage the full lifetime of your tensors, you may consider instead
| manually managing CUDA events so that calling this method is not necessary.
| In particular, when you call this method, on later allocations the
| allocator will poll the recorded stream to see if all operations have
| completed yet; you can potentially race with side stream computation and
| non-deterministically reuse or fail to reuse memory for an allocation.
|
| You can safely use tensors allocated on side streams without
| :meth:`~Tensor.record_stream`; you must manually ensure that
| any non-creation stream uses of a tensor are synced back to the creation
| stream before you deallocate the tensor. As the CUDA caching allocator
| guarantees that the memory will only be reused with the same creation stream,
| this is sufficient to ensure that writes to future reallocations of the
| memory will be delayed until non-creation stream uses are done.
| (Counterintuitively, you may observe that on the CPU side we have already
| reallocated the tensor, even though CUDA kernels on the old tensor are
| still in progress. This is fine, because CUDA operations on the new
| tensor will appropriately wait for the old operations to complete, as they
| are all on the same stream.)
|
| Concretely, this looks like this::
|
| with torch.cuda.stream(s0):
| x = torch.zeros(N)
|
| s1.wait_stream(s0)
| with torch.cuda.stream(s1):
| y = some_comm_op(x)
|
| ... some compute on s0 ...
|
| # synchronize creation stream s0 to side stream s1
| # before deallocating x
| s0.wait_stream(s1)
| del x
|
| Note that some discretion is required when deciding when to perform
| ``s0.wait_stream(s1)``. In particular, if we were to wait immediately
| after ``some_comm_op``, there wouldn't be any point in having the side
| stream; it would be equivalent to have run ``some_comm_op`` on ``s0``.
| Instead, the synchronization must be placed at some appropriate, later
| point in time where you expect the side stream ``s1`` to have finished
| work. This location is typically identified via profiling, e.g., using
| Chrome traces produced
| :meth:`torch.autograd.profiler.profile.export_chrome_trace`. If you
| place the wait too early, work on s0 will block until ``s1`` has finished,
| preventing further overlapping of communication and computation. If you
| place the wait too late, you will use more memory than is strictly
| necessary (as you are keeping ``x`` live for longer.) For a concrete
| example of how this guidance can be applied in practice, see this post:
| `FSDP and CUDACachingAllocator
| <https://dev-discuss.pytorch.org/t/fsdp-cudacachingallocator-an-outsider-newb-perspective/1486>`_.
|
| relu(...)
|
| relu_(...)
|
| remainder(...)
| remainder(divisor) -> Tensor
|
| See :func:`torch.remainder`
|
| remainder_(...)
| remainder_(divisor) -> Tensor
|
| In-place version of :meth:`~Tensor.remainder`
|
| renorm(...)
| renorm(p, dim, maxnorm) -> Tensor
|
| See :func:`torch.renorm`
|
| renorm_(...)
| renorm_(p, dim, maxnorm) -> Tensor
|
| In-place version of :meth:`~Tensor.renorm`
|
| repeat(...)
| repeat(*sizes) -> Tensor
|
| Repeats this tensor along the specified dimensions.
|
| Unlike :meth:`~Tensor.expand`, this function copies the tensor's data.
|
| .. warning::
|
| :meth:`~Tensor.repeat` behaves differently from
| `numpy.repeat <https://docs.scipy.org/doc/numpy/reference/generated/numpy.repeat.html>`_,
| but is more similar to
| `numpy.tile <https://docs.scipy.org/doc/numpy/reference/generated/numpy.tile.html>`_.
| For the operator similar to `numpy.repeat`, see :func:`torch.repeat_interleave`.
|
| Args:
| sizes (torch.Size or int...): The number of times to repeat this tensor along each
| dimension
|
| Example::
|
| >>> x = torch.tensor([1, 2, 3])
| >>> x.repeat(4, 2)
| tensor([[ 1, 2, 3, 1, 2, 3],
| [ 1, 2, 3, 1, 2, 3],
| [ 1, 2, 3, 1, 2, 3],
| [ 1, 2, 3, 1, 2, 3]])
| >>> x.repeat(4, 2, 1).size()
| torch.Size([4, 2, 3])
|
| repeat_interleave(...)
| repeat_interleave(repeats, dim=None, *, output_size=None) -> Tensor
|
| See :func:`torch.repeat_interleave`.
|
| requires_grad_(...)
| requires_grad_(requires_grad=True) -> Tensor
|
| Change if autograd should record operations on this tensor: sets this tensor's
| :attr:`requires_grad` attribute in-place. Returns this tensor.
|
| :func:`requires_grad_`'s main use case is to tell autograd to begin recording
| operations on a Tensor ``tensor``. If ``tensor`` has ``requires_grad=False``
| (because it was obtained through a DataLoader, or required preprocessing or
| initialization), ``tensor.requires_grad_()`` makes it so that autograd will
| begin to record operations on ``tensor``.
|
| Args:
| requires_grad (bool): If autograd should record operations on this tensor.
| Default: ``True``.
|
| Example::
|
| >>> # Let's say we want to preprocess some saved weights and use
| >>> # the result as new weights.
| >>> saved_weights = [0.1, 0.2, 0.3, 0.25]
| >>> loaded_weights = torch.tensor(saved_weights)
| >>> weights = preprocess(loaded_weights) # some function
| >>> weights
| tensor([-0.5503, 0.4926, -2.1158, -0.8303])
|
| >>> # Now, start to record operations done to weights
| >>> weights.requires_grad_()
| >>> out = weights.pow(2).sum()
| >>> out.backward()
| >>> weights.grad
| tensor([-1.1007, 0.9853, -4.2316, -1.6606])
|
| reshape(...)
| reshape(*shape) -> Tensor
|
| Returns a tensor with the same data and number of elements as :attr:`self`
| but with the specified shape. This method returns a view if :attr:`shape` is
| compatible with the current shape. See :meth:`torch.Tensor.view` on when it is
| possible to return a view.
|
| See :func:`torch.reshape`
|
| Args:
| shape (tuple of ints or int...): the desired shape
|
| reshape_as(...)
| reshape_as(other) -> Tensor
|
| Returns this tensor as the same shape as :attr:`other`.
| ``self.reshape_as(other)`` is equivalent to ``self.reshape(other.sizes())``.
| This method returns a view if ``other.sizes()`` is compatible with the current
| shape. See :meth:`torch.Tensor.view` on when it is possible to return a view.
|
| Please see :meth:`reshape` for more information about ``reshape``.
|
| Args:
| other (:class:`torch.Tensor`): The result tensor has the same shape
| as :attr:`other`.
|
| resize_(...)
| resize_(*sizes, memory_format=torch.contiguous_format) -> Tensor
|
| Resizes :attr:`self` tensor to the specified size. If the number of elements is
| larger than the current storage size, then the underlying storage is resized
| to fit the new number of elements. If the number of elements is smaller, the
| underlying storage is not changed. Existing elements are preserved but any new
| memory is uninitialized.
|
| .. warning::
|
| This is a low-level method. The storage is reinterpreted as C-contiguous,
| ignoring the current strides (unless the target size equals the current
| size, in which case the tensor is left unchanged). For most purposes, you
| will instead want to use :meth:`~Tensor.view()`, which checks for
| contiguity, or :meth:`~Tensor.reshape()`, which copies data if needed. To
| change the size in-place with custom strides, see :meth:`~Tensor.set_()`.
|
| .. note::
|
| If :func:`torch.use_deterministic_algorithms()` and
| :attr:`torch.utils.deterministic.fill_uninitialized_memory` are both set to
| ``True``, new elements are initialized to prevent nondeterministic behavior
| from using the result as an input to an operation. Floating point and
| complex values are set to NaN, and integer values are set to the maximum
| value.
|
| Args:
| sizes (torch.Size or int...): the desired size
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| Tensor. Default: ``torch.contiguous_format``. Note that memory format of
| :attr:`self` is going to be unaffected if ``self.size()`` matches ``sizes``.
|
| Example::
|
| >>> x = torch.tensor([[1, 2], [3, 4], [5, 6]])
| >>> x.resize_(2, 2)
| tensor([[ 1, 2],
| [ 3, 4]])
|
| resize_as_(...)
| resize_as_(tensor, memory_format=torch.contiguous_format) -> Tensor
|
| Resizes the :attr:`self` tensor to be the same size as the specified
| :attr:`tensor`. This is equivalent to ``self.resize_(tensor.size())``.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| Tensor. Default: ``torch.contiguous_format``. Note that memory format of
| :attr:`self` is going to be unaffected if ``self.size()`` matches ``tensor.size()``.
|
| resize_as_sparse_(...)
|
| resolve_conj(...)
| resolve_conj() -> Tensor
|
| See :func:`torch.resolve_conj`
|
| resolve_neg(...)
| resolve_neg() -> Tensor
|
| See :func:`torch.resolve_neg`
|
| retain_grad(...)
| retain_grad() -> None
|
| Enables this Tensor to have their :attr:`grad` populated during
| :func:`backward`. This is a no-op for leaf tensors.
|
| roll(...)
| roll(shifts, dims) -> Tensor
|
| See :func:`torch.roll`
|
| rot90(...)
| rot90(k, dims) -> Tensor
|
| See :func:`torch.rot90`
|
| round(...)
| round(decimals=0) -> Tensor
|
| See :func:`torch.round`
|
| round_(...)
| round_(decimals=0) -> Tensor
|
| In-place version of :meth:`~Tensor.round`
|
| row_indices(...)
|
| rsqrt(...)
| rsqrt() -> Tensor
|
| See :func:`torch.rsqrt`
|
| rsqrt_(...)
| rsqrt_() -> Tensor
|
| In-place version of :meth:`~Tensor.rsqrt`
|
| scatter(...)
| scatter(dim, index, src) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.scatter_`
|
| scatter_(...)
| scatter_(dim, index, src, *, reduce=None) -> Tensor
|
| Writes all values from the tensor :attr:`src` into :attr:`self` at the indices
| specified in the :attr:`index` tensor. For each value in :attr:`src`, its output
| index is specified by its index in :attr:`src` for ``dimension != dim`` and by
| the corresponding value in :attr:`index` for ``dimension = dim``.
|
| For a 3-D tensor, :attr:`self` is updated as::
|
| self[index[i][j][k]][j][k] = src[i][j][k] # if dim == 0
| self[i][index[i][j][k]][k] = src[i][j][k] # if dim == 1
| self[i][j][index[i][j][k]] = src[i][j][k] # if dim == 2
|
| This is the reverse operation of the manner described in :meth:`~Tensor.gather`.
|
| :attr:`self`, :attr:`index` and :attr:`src` (if it is a Tensor) should all have
| the same number of dimensions. It is also required that
| ``index.size(d) <= src.size(d)`` for all dimensions ``d``, and that
| ``index.size(d) <= self.size(d)`` for all dimensions ``d != dim``.
| Note that ``index`` and ``src`` do not broadcast.
|
| Moreover, as for :meth:`~Tensor.gather`, the values of :attr:`index` must be
| between ``0`` and ``self.size(dim) - 1`` inclusive.
|
| .. warning::
|
| When indices are not unique, the behavior is non-deterministic (one of the
| values from ``src`` will be picked arbitrarily) and the gradient will be
| incorrect (it will be propagated to all locations in the source that
| correspond to the same index)!
|
| .. note::
|
| The backward pass is implemented only for ``src.shape == index.shape``.
|
| Additionally accepts an optional :attr:`reduce` argument that allows
| specification of an optional reduction operation, which is applied to all
| values in the tensor :attr:`src` into :attr:`self` at the indices
| specified in the :attr:`index`. For each value in :attr:`src`, the reduction
| operation is applied to an index in :attr:`self` which is specified by
| its index in :attr:`src` for ``dimension != dim`` and by the corresponding
| value in :attr:`index` for ``dimension = dim``.
|
| Given a 3-D tensor and reduction using the multiplication operation, :attr:`self`
| is updated as::
|
| self[index[i][j][k]][j][k] *= src[i][j][k] # if dim == 0
| self[i][index[i][j][k]][k] *= src[i][j][k] # if dim == 1
| self[i][j][index[i][j][k]] *= src[i][j][k] # if dim == 2
|
| Reducing with the addition operation is the same as using
| :meth:`~torch.Tensor.scatter_add_`.
|
| .. warning::
| The reduce argument with Tensor ``src`` is deprecated and will be removed in
| a future PyTorch release. Please use :meth:`~torch.Tensor.scatter_reduce_`
| instead for more reduction options.
|
| Args:
| dim (int): the axis along which to index
| index (LongTensor): the indices of elements to scatter, can be either empty
| or of the same dimensionality as ``src``. When empty, the operation
| returns ``self`` unchanged.
| src (Tensor): the source element(s) to scatter.
|
| Keyword args:
| reduce (str, optional): reduction operation to apply, can be either
| ``'add'`` or ``'multiply'``.
|
| Example::
|
| >>> src = torch.arange(1, 11).reshape((2, 5))
| >>> src
| tensor([[ 1, 2, 3, 4, 5],
| [ 6, 7, 8, 9, 10]])
| >>> index = torch.tensor([[0, 1, 2, 0]])
| >>> torch.zeros(3, 5, dtype=src.dtype).scatter_(0, index, src)
| tensor([[1, 0, 0, 4, 0],
| [0, 2, 0, 0, 0],
| [0, 0, 3, 0, 0]])
| >>> index = torch.tensor([[0, 1, 2], [0, 1, 4]])
| >>> torch.zeros(3, 5, dtype=src.dtype).scatter_(1, index, src)
| tensor([[1, 2, 3, 0, 0],
| [6, 7, 0, 0, 8],
| [0, 0, 0, 0, 0]])
|
| >>> torch.full((2, 4), 2.).scatter_(1, torch.tensor([[2], [3]]),
| ... 1.23, reduce='multiply')
| tensor([[2.0000, 2.0000, 2.4600, 2.0000],
| [2.0000, 2.0000, 2.0000, 2.4600]])
| >>> torch.full((2, 4), 2.).scatter_(1, torch.tensor([[2], [3]]),
| ... 1.23, reduce='add')
| tensor([[2.0000, 2.0000, 3.2300, 2.0000],
| [2.0000, 2.0000, 2.0000, 3.2300]])
|
| .. function:: scatter_(dim, index, value, *, reduce=None) -> Tensor:
| :noindex:
|
| Writes the value from :attr:`value` into :attr:`self` at the indices
| specified in the :attr:`index` tensor. This operation is equivalent to the previous version,
| with the :attr:`src` tensor filled entirely with :attr:`value`.
|
| Args:
| dim (int): the axis along which to index
| index (LongTensor): the indices of elements to scatter, can be either empty
| or of the same dimensionality as ``src``. When empty, the operation
| returns ``self`` unchanged.
| value (Scalar): the value to scatter.
|
| Keyword args:
| reduce (str, optional): reduction operation to apply, can be either
| ``'add'`` or ``'multiply'``.
|
| Example::
|
| >>> index = torch.tensor([[0, 1]])
| >>> value = 2
| >>> torch.zeros(3, 5).scatter_(0, index, value)
| tensor([[2., 0., 0., 0., 0.],
| [0., 2., 0., 0., 0.],
| [0., 0., 0., 0., 0.]])
|
| scatter_add(...)
| scatter_add(dim, index, src) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.scatter_add_`
|
| scatter_add_(...)
| scatter_add_(dim, index, src) -> Tensor
|
| Adds all values from the tensor :attr:`src` into :attr:`self` at the indices
| specified in the :attr:`index` tensor in a similar fashion as
| :meth:`~torch.Tensor.scatter_`. For each value in :attr:`src`, it is added to
| an index in :attr:`self` which is specified by its index in :attr:`src`
| for ``dimension != dim`` and by the corresponding value in :attr:`index` for
| ``dimension = dim``.
|
| For a 3-D tensor, :attr:`self` is updated as::
|
| self[index[i][j][k]][j][k] += src[i][j][k] # if dim == 0
| self[i][index[i][j][k]][k] += src[i][j][k] # if dim == 1
| self[i][j][index[i][j][k]] += src[i][j][k] # if dim == 2
|
| :attr:`self`, :attr:`index` and :attr:`src` should have same number of
| dimensions. It is also required that ``index.size(d) <= src.size(d)`` for all
| dimensions ``d``, and that ``index.size(d) <= self.size(d)`` for all dimensions
| ``d != dim``. Note that ``index`` and ``src`` do not broadcast.
|
| Note:
| This operation may behave nondeterministically when given tensors on a CUDA device. See :doc:`/notes/randomness` for more information.
|
| .. note::
|
| The backward pass is implemented only for ``src.shape == index.shape``.
|
| Args:
| dim (int): the axis along which to index
| index (LongTensor): the indices of elements to scatter and add, can be
| either empty or of the same dimensionality as ``src``. When empty, the
| operation returns ``self`` unchanged.
| src (Tensor): the source elements to scatter and add
|
| Example::
|
| >>> src = torch.ones((2, 5))
| >>> index = torch.tensor([[0, 1, 2, 0, 0]])
| >>> torch.zeros(3, 5, dtype=src.dtype).scatter_add_(0, index, src)
| tensor([[1., 0., 0., 1., 1.],
| [0., 1., 0., 0., 0.],
| [0., 0., 1., 0., 0.]])
| >>> index = torch.tensor([[0, 1, 2, 0, 0], [0, 1, 2, 2, 2]])
| >>> torch.zeros(3, 5, dtype=src.dtype).scatter_add_(0, index, src)
| tensor([[2., 0., 0., 1., 1.],
| [0., 2., 0., 0., 0.],
| [0., 0., 2., 1., 1.]])
|
| scatter_reduce(...)
| scatter_reduce(dim, index, src, reduce, *, include_self=True) -> Tensor
|
| Out-of-place version of :meth:`torch.Tensor.scatter_reduce_`
|
| scatter_reduce_(...)
| scatter_reduce_(dim, index, src, reduce, *, include_self=True) -> Tensor
|
| Reduces all values from the :attr:`src` tensor to the indices specified in
| the :attr:`index` tensor in the :attr:`self` tensor using the applied reduction
| defined via the :attr:`reduce` argument (:obj:`"sum"`, :obj:`"prod"`, :obj:`"mean"`,
| :obj:`"amax"`, :obj:`"amin"`). For each value in :attr:`src`, it is reduced to an
| index in :attr:`self` which is specified by its index in :attr:`src` for
| ``dimension != dim`` and by the corresponding value in :attr:`index` for
| ``dimension = dim``. If :obj:`include_self="True"`, the values in the :attr:`self`
| tensor are included in the reduction.
|
| :attr:`self`, :attr:`index` and :attr:`src` should all have
| the same number of dimensions. It is also required that
| ``index.size(d) <= src.size(d)`` for all dimensions ``d``, and that
| ``index.size(d) <= self.size(d)`` for all dimensions ``d != dim``.
| Note that ``index`` and ``src`` do not broadcast.
|
| For a 3-D tensor with :obj:`reduce="sum"` and :obj:`include_self=True` the
| output is given as::
|
| self[index[i][j][k]][j][k] += src[i][j][k] # if dim == 0
| self[i][index[i][j][k]][k] += src[i][j][k] # if dim == 1
| self[i][j][index[i][j][k]] += src[i][j][k] # if dim == 2
|
| Note:
| This operation may behave nondeterministically when given tensors on a CUDA device. See :doc:`/notes/randomness` for more information.
|
| .. note::
|
| The backward pass is implemented only for ``src.shape == index.shape``.
|
| .. warning::
|
| This function is in beta and may change in the near future.
|
| Args:
| dim (int): the axis along which to index
| index (LongTensor): the indices of elements to scatter and reduce.
| src (Tensor): the source elements to scatter and reduce
| reduce (str): the reduction operation to apply for non-unique indices
| (:obj:`"sum"`, :obj:`"prod"`, :obj:`"mean"`, :obj:`"amax"`, :obj:`"amin"`)
| include_self (bool): whether elements from the :attr:`self` tensor are
| included in the reduction
|
| Example::
|
| >>> src = torch.tensor([1., 2., 3., 4., 5., 6.])
| >>> index = torch.tensor([0, 1, 0, 1, 2, 1])
| >>> input = torch.tensor([1., 2., 3., 4.])
| >>> input.scatter_reduce(0, index, src, reduce="sum")
| tensor([5., 14., 8., 4.])
| >>> input.scatter_reduce(0, index, src, reduce="sum", include_self=False)
| tensor([4., 12., 5., 4.])
| >>> input2 = torch.tensor([5., 4., 3., 2.])
| >>> input2.scatter_reduce(0, index, src, reduce="amax")
| tensor([5., 6., 5., 2.])
| >>> input2.scatter_reduce(0, index, src, reduce="amax", include_self=False)
| tensor([3., 6., 5., 2.])
|
| select(...)
| select(dim, index) -> Tensor
|
| See :func:`torch.select`
|
| select_scatter(...)
| select_scatter(src, dim, index) -> Tensor
|
| See :func:`torch.select_scatter`
|
| set_(...)
| set_(source=None, storage_offset=0, size=None, stride=None) -> Tensor
|
| Sets the underlying storage, size, and strides. If :attr:`source` is a tensor,
| :attr:`self` tensor will share the same storage and have the same size and
| strides as :attr:`source`. Changes to elements in one tensor will be reflected
| in the other.
|
| If :attr:`source` is a :class:`~torch.Storage`, the method sets the underlying
| storage, offset, size, and stride.
|
| Args:
| source (Tensor or Storage): the tensor or storage to use
| storage_offset (int, optional): the offset in the storage
| size (torch.Size, optional): the desired size. Defaults to the size of the source.
| stride (tuple, optional): the desired stride. Defaults to C-contiguous strides.
|
| sgn(...)
| sgn() -> Tensor
|
| See :func:`torch.sgn`
|
| sgn_(...)
| sgn_() -> Tensor
|
| In-place version of :meth:`~Tensor.sgn`
|
| short(...)
| short(memory_format=torch.preserve_format) -> Tensor
|
| ``self.short()`` is equivalent to ``self.to(torch.int16)``. See :func:`to`.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| sigmoid(...)
| sigmoid() -> Tensor
|
| See :func:`torch.sigmoid`
|
| sigmoid_(...)
| sigmoid_() -> Tensor
|
| In-place version of :meth:`~Tensor.sigmoid`
|
| sign(...)
| sign() -> Tensor
|
| See :func:`torch.sign`
|
| sign_(...)
| sign_() -> Tensor
|
| In-place version of :meth:`~Tensor.sign`
|
| signbit(...)
| signbit() -> Tensor
|
| See :func:`torch.signbit`
|
| sin(...)
| sin() -> Tensor
|
| See :func:`torch.sin`
|
| sin_(...)
| sin_() -> Tensor
|
| In-place version of :meth:`~Tensor.sin`
|
| sinc(...)
| sinc() -> Tensor
|
| See :func:`torch.sinc`
|
| sinc_(...)
| sinc_() -> Tensor
|
| In-place version of :meth:`~Tensor.sinc`
|
| sinh(...)
| sinh() -> Tensor
|
| See :func:`torch.sinh`
|
| sinh_(...)
| sinh_() -> Tensor
|
| In-place version of :meth:`~Tensor.sinh`
|
| size(...)
| size(dim=None) -> torch.Size or int
|
| Returns the size of the :attr:`self` tensor. If ``dim`` is not specified,
| the returned value is a :class:`torch.Size`, a subclass of :class:`tuple`.
| If ``dim`` is specified, returns an int holding the size of that dimension.
|
| Args:
| dim (int, optional): The dimension for which to retrieve the size.
|
| Example::
|
| >>> t = torch.empty(3, 4, 5)
| >>> t.size()
| torch.Size([3, 4, 5])
| >>> t.size(dim=1)
| 4
|
| slice_inverse(...)
|
| slice_scatter(...)
| slice_scatter(src, dim=0, start=None, end=None, step=1) -> Tensor
|
| See :func:`torch.slice_scatter`
|
| slogdet(...)
| slogdet() -> (Tensor, Tensor)
|
| See :func:`torch.slogdet`
|
| smm(...)
| smm(mat) -> Tensor
|
| See :func:`torch.smm`
|
| softmax(...)
| softmax(dim) -> Tensor
|
| Alias for :func:`torch.nn.functional.softmax`.
|
| sort(...)
| sort(dim=-1, descending=False) -> (Tensor, LongTensor)
|
| See :func:`torch.sort`
|
| sparse_dim(...)
| sparse_dim() -> int
|
| Return the number of sparse dimensions in a :ref:`sparse tensor <sparse-docs>` :attr:`self`.
|
| .. note::
| Returns ``0`` if :attr:`self` is not a sparse tensor.
|
| See also :meth:`Tensor.dense_dim` and :ref:`hybrid tensors <sparse-hybrid-coo-docs>`.
|
| sparse_mask(...)
| sparse_mask(mask) -> Tensor
|
| Returns a new :ref:`sparse tensor <sparse-docs>` with values from a
| strided tensor :attr:`self` filtered by the indices of the sparse
| tensor :attr:`mask`. The values of :attr:`mask` sparse tensor are
| ignored. :attr:`self` and :attr:`mask` tensors must have the same
| shape.
|
| .. note::
|
| The returned sparse tensor might contain duplicate values if :attr:`mask`
| is not coalesced. It is therefore advisable to pass ``mask.coalesce()``
| if such behavior is not desired.
|
| .. note::
|
| The returned sparse tensor has the same indices as the sparse tensor
| :attr:`mask`, even when the corresponding values in :attr:`self` are
| zeros.
|
| Args:
| mask (Tensor): a sparse tensor whose indices are used as a filter
|
| Example::
|
| >>> nse = 5
| >>> dims = (5, 5, 2, 2)
| >>> I = torch.cat([torch.randint(0, dims[0], size=(nse,)),
| ... torch.randint(0, dims[1], size=(nse,))], 0).reshape(2, nse)
| >>> V = torch.randn(nse, dims[2], dims[3])
| >>> S = torch.sparse_coo_tensor(I, V, dims).coalesce()
| >>> D = torch.randn(dims)
| >>> D.sparse_mask(S)
| tensor(indices=tensor([[0, 0, 0, 2],
| [0, 1, 4, 3]]),
| values=tensor([[[ 1.6550, 0.2397],
| [-0.1611, -0.0779]],
|
| [[ 0.2326, -1.0558],
| [ 1.4711, 1.9678]],
|
| [[-0.5138, -0.0411],
| [ 1.9417, 0.5158]],
|
| [[ 0.0793, 0.0036],
| [-0.2569, -0.1055]]]),
| size=(5, 5, 2, 2), nnz=4, layout=torch.sparse_coo)
|
| sparse_resize_(...)
| sparse_resize_(size, sparse_dim, dense_dim) -> Tensor
|
| Resizes :attr:`self` :ref:`sparse tensor <sparse-docs>` to the desired
| size and the number of sparse and dense dimensions.
|
| .. note::
| If the number of specified elements in :attr:`self` is zero, then
| :attr:`size`, :attr:`sparse_dim`, and :attr:`dense_dim` can be any
| size and positive integers such that ``len(size) == sparse_dim +
| dense_dim``.
|
| If :attr:`self` specifies one or more elements, however, then each
| dimension in :attr:`size` must not be smaller than the corresponding
| dimension of :attr:`self`, :attr:`sparse_dim` must equal the number
| of sparse dimensions in :attr:`self`, and :attr:`dense_dim` must
| equal the number of dense dimensions in :attr:`self`.
|
| .. warning::
| Throws an error if :attr:`self` is not a sparse tensor.
|
| Args:
| size (torch.Size): the desired size. If :attr:`self` is non-empty
| sparse tensor, the desired size cannot be smaller than the
| original size.
| sparse_dim (int): the number of sparse dimensions
| dense_dim (int): the number of dense dimensions
|
| sparse_resize_and_clear_(...)
| sparse_resize_and_clear_(size, sparse_dim, dense_dim) -> Tensor
|
| Removes all specified elements from a :ref:`sparse tensor
| <sparse-docs>` :attr:`self` and resizes :attr:`self` to the desired
| size and the number of sparse and dense dimensions.
|
| .. warning:
| Throws an error if :attr:`self` is not a sparse tensor.
|
| Args:
| size (torch.Size): the desired size.
| sparse_dim (int): the number of sparse dimensions
| dense_dim (int): the number of dense dimensions
|
| split_with_sizes(...)
|
| sqrt(...)
| sqrt() -> Tensor
|
| See :func:`torch.sqrt`
|
| sqrt_(...)
| sqrt_() -> Tensor
|
| In-place version of :meth:`~Tensor.sqrt`
|
| square(...)
| square() -> Tensor
|
| See :func:`torch.square`
|
| square_(...)
| square_() -> Tensor
|
| In-place version of :meth:`~Tensor.square`
|
| squeeze(...)
| squeeze(dim=None) -> Tensor
|
| See :func:`torch.squeeze`
|
| squeeze_(...)
| squeeze_(dim=None) -> Tensor
|
| In-place version of :meth:`~Tensor.squeeze`
|
| sspaddmm(...)
| sspaddmm(mat1, mat2, *, beta=1, alpha=1) -> Tensor
|
| See :func:`torch.sspaddmm`
|
| std(...)
| std(dim=None, *, correction=1, keepdim=False) -> Tensor
|
| See :func:`torch.std`
|
| storage_offset(...)
| storage_offset() -> int
|
| Returns :attr:`self` tensor's offset in the underlying storage in terms of
| number of storage elements (not bytes).
|
| Example::
|
| >>> x = torch.tensor([1, 2, 3, 4, 5])
| >>> x.storage_offset()
| 0
| >>> x[3:].storage_offset()
| 3
|
| stride(...)
| stride(dim) -> tuple or int
|
| Returns the stride of :attr:`self` tensor.
|
| Stride is the jump necessary to go from one element to the next one in the
| specified dimension :attr:`dim`. A tuple of all strides is returned when no
| argument is passed in. Otherwise, an integer value is returned as the stride in
| the particular dimension :attr:`dim`.
|
| Args:
| dim (int, optional): the desired dimension in which stride is required
|
| Example::
|
| >>> x = torch.tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
| >>> x.stride()
| (5, 1)
| >>> x.stride(0)
| 5
| >>> x.stride(-1)
| 1
|
| sub(...)
| sub(other, *, alpha=1) -> Tensor
|
| See :func:`torch.sub`.
|
| sub_(...)
| sub_(other, *, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.sub`
|
| subtract(...)
| subtract(other, *, alpha=1) -> Tensor
|
| See :func:`torch.subtract`.
|
| subtract_(...)
| subtract_(other, *, alpha=1) -> Tensor
|
| In-place version of :meth:`~Tensor.subtract`.
|
| sum(...)
| sum(dim=None, keepdim=False, dtype=None) -> Tensor
|
| See :func:`torch.sum`
|
| sum_to_size(...)
| sum_to_size(*size) -> Tensor
|
| Sum ``this`` tensor to :attr:`size`.
| :attr:`size` must be broadcastable to ``this`` tensor size.
|
| Args:
| size (int...): a sequence of integers defining the shape of the output tensor.
|
| svd(...)
| svd(some=True, compute_uv=True) -> (Tensor, Tensor, Tensor)
|
| See :func:`torch.svd`
|
| swapaxes(...)
| swapaxes(axis0, axis1) -> Tensor
|
| See :func:`torch.swapaxes`
|
| swapaxes_(...)
| swapaxes_(axis0, axis1) -> Tensor
|
| In-place version of :meth:`~Tensor.swapaxes`
|
| swapdims(...)
| swapdims(dim0, dim1) -> Tensor
|
| See :func:`torch.swapdims`
|
| swapdims_(...)
| swapdims_(dim0, dim1) -> Tensor
|
| In-place version of :meth:`~Tensor.swapdims`
|
| t(...)
| t() -> Tensor
|
| See :func:`torch.t`
|
| t_(...)
| t_() -> Tensor
|
| In-place version of :meth:`~Tensor.t`
|
| take(...)
| take(indices) -> Tensor
|
| See :func:`torch.take`
|
| take_along_dim(...)
| take_along_dim(indices, dim) -> Tensor
|
| See :func:`torch.take_along_dim`
|
| tan(...)
| tan() -> Tensor
|
| See :func:`torch.tan`
|
| tan_(...)
| tan_() -> Tensor
|
| In-place version of :meth:`~Tensor.tan`
|
| tanh(...)
| tanh() -> Tensor
|
| See :func:`torch.tanh`
|
| tanh_(...)
| tanh_() -> Tensor
|
| In-place version of :meth:`~Tensor.tanh`
|
| tensor_split(...)
| tensor_split(indices_or_sections, dim=0) -> List of Tensors
|
| See :func:`torch.tensor_split`
|
| tile(...)
| tile(dims) -> Tensor
|
| See :func:`torch.tile`
|
| to(...)
| to(*args, **kwargs) -> Tensor
|
| Performs Tensor dtype and/or device conversion. A :class:`torch.dtype` and :class:`torch.device` are
| inferred from the arguments of ``self.to(*args, **kwargs)``.
|
| .. note::
|
| If the ``self`` Tensor already
| has the correct :class:`torch.dtype` and :class:`torch.device`, then ``self`` is returned.
| Otherwise, the returned tensor is a copy of ``self`` with the desired
| :class:`torch.dtype` and :class:`torch.device`.
|
| Here are the ways to call ``to``:
|
| .. method:: to(dtype, non_blocking=False, copy=False, memory_format=torch.preserve_format) -> Tensor
| :noindex:
|
| Returns a Tensor with the specified :attr:`dtype`
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| .. method:: to(device=None, dtype=None, non_blocking=False, copy=False, memory_format=torch.preserve_format) -> Tensor
| :noindex:
|
| Returns a Tensor with the specified :attr:`device` and (optional)
| :attr:`dtype`. If :attr:`dtype` is ``None`` it is inferred to be ``self.dtype``.
| When :attr:`non_blocking`, tries to convert asynchronously with respect to
| the host if possible, e.g., converting a CPU Tensor with pinned memory to a
| CUDA Tensor.
| When :attr:`copy` is set, a new Tensor is created even when the Tensor
| already matches the desired conversion.
|
| Args:
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| .. method:: to(other, non_blocking=False, copy=False) -> Tensor
| :noindex:
|
| Returns a Tensor with same :class:`torch.dtype` and :class:`torch.device` as
| the Tensor :attr:`other`. When :attr:`non_blocking`, tries to convert
| asynchronously with respect to the host if possible, e.g., converting a CPU
| Tensor with pinned memory to a CUDA Tensor.
| When :attr:`copy` is set, a new Tensor is created even when the Tensor
| already matches the desired conversion.
|
| Example::
|
| >>> tensor = torch.randn(2, 2) # Initially dtype=float32, device=cpu
| >>> tensor.to(torch.float64)
| tensor([[-0.5044, 0.0005],
| [ 0.3310, -0.0584]], dtype=torch.float64)
|
| >>> cuda0 = torch.device('cuda:0')
| >>> tensor.to(cuda0)
| tensor([[-0.5044, 0.0005],
| [ 0.3310, -0.0584]], device='cuda:0')
|
| >>> tensor.to(cuda0, dtype=torch.float64)
| tensor([[-0.5044, 0.0005],
| [ 0.3310, -0.0584]], dtype=torch.float64, device='cuda:0')
|
| >>> other = torch.randn((), dtype=torch.float64, device=cuda0)
| >>> tensor.to(other, non_blocking=True)
| tensor([[-0.5044, 0.0005],
| [ 0.3310, -0.0584]], dtype=torch.float64, device='cuda:0')
|
| to_dense(...)
| to_dense(dtype=None, *, masked_grad=True) -> Tensor
|
| Creates a strided copy of :attr:`self` if :attr:`self` is not a strided tensor, otherwise returns :attr:`self`.
|
| Keyword args:
| {dtype}
| masked_grad (bool, optional): If set to ``True`` (default) and
| :attr:`self` has a sparse layout then the backward of
| :meth:`to_dense` returns ``grad.sparse_mask(self)``.
|
| Example::
|
| >>> s = torch.sparse_coo_tensor(
| ... torch.tensor([[1, 1],
| ... [0, 2]]),
| ... torch.tensor([9, 10]),
| ... size=(3, 3))
| >>> s.to_dense()
| tensor([[ 0, 0, 0],
| [ 9, 0, 10],
| [ 0, 0, 0]])
|
| to_mkldnn(...)
| to_mkldnn() -> Tensor
| Returns a copy of the tensor in ``torch.mkldnn`` layout.
|
| to_padded_tensor(...)
| to_padded_tensor(padding, output_size=None) -> Tensor
| See :func:`to_padded_tensor`
|
| to_sparse(...)
| to_sparse(sparseDims) -> Tensor
|
| Returns a sparse copy of the tensor. PyTorch supports sparse tensors in
| :ref:`coordinate format <sparse-coo-docs>`.
|
| Args:
| sparseDims (int, optional): the number of sparse dimensions to include in the new sparse tensor
|
| Example::
|
| >>> d = torch.tensor([[0, 0, 0], [9, 0, 10], [0, 0, 0]])
| >>> d
| tensor([[ 0, 0, 0],
| [ 9, 0, 10],
| [ 0, 0, 0]])
| >>> d.to_sparse()
| tensor(indices=tensor([[1, 1],
| [0, 2]]),
| values=tensor([ 9, 10]),
| size=(3, 3), nnz=2, layout=torch.sparse_coo)
| >>> d.to_sparse(1)
| tensor(indices=tensor([[1]]),
| values=tensor([[ 9, 0, 10]]),
| size=(3, 3), nnz=1, layout=torch.sparse_coo)
|
| .. method:: to_sparse(*, layout=None, blocksize=None, dense_dim=None) -> Tensor
| :noindex:
|
| Returns a sparse tensor with the specified layout and blocksize. If
| the :attr:`self` is strided, the number of dense dimensions could be
| specified, and a hybrid sparse tensor will be created, with
| `dense_dim` dense dimensions and `self.dim() - 2 - dense_dim` batch
| dimension.
|
| .. note:: If the :attr:`self` layout and blocksize parameters match
| with the specified layout and blocksize, return
| :attr:`self`. Otherwise, return a sparse tensor copy of
| :attr:`self`.
|
| Args:
|
| layout (:class:`torch.layout`, optional): The desired sparse
| layout. One of ``torch.sparse_coo``, ``torch.sparse_csr``,
| ``torch.sparse_csc``, ``torch.sparse_bsr``, or
| ``torch.sparse_bsc``. Default: if ``None``,
| ``torch.sparse_coo``.
|
| blocksize (list, tuple, :class:`torch.Size`, optional): Block size
| of the resulting BSR or BSC tensor. For other layouts,
| specifying the block size that is not ``None`` will result in a
| RuntimeError exception. A block size must be a tuple of length
| two such that its items evenly divide the two sparse dimensions.
|
| dense_dim (int, optional): Number of dense dimensions of the
| resulting CSR, CSC, BSR or BSC tensor. This argument should be
| used only if :attr:`self` is a strided tensor, and must be a
| value between 0 and dimension of :attr:`self` tensor minus two.
|
| Example::
|
| >>> x = torch.tensor([[1, 0], [0, 0], [2, 3]])
| >>> x.to_sparse(layout=torch.sparse_coo)
| tensor(indices=tensor([[0, 2, 2],
| [0, 0, 1]]),
| values=tensor([1, 2, 3]),
| size=(3, 2), nnz=3, layout=torch.sparse_coo)
| >>> x.to_sparse(layout=torch.sparse_bsr, blocksize=(1, 2))
| tensor(crow_indices=tensor([0, 1, 1, 2]),
| col_indices=tensor([0, 0]),
| values=tensor([[[1, 0]],
| [[2, 3]]]), size=(3, 2), nnz=2, layout=torch.sparse_bsr)
| >>> x.to_sparse(layout=torch.sparse_bsr, blocksize=(2, 1))
| RuntimeError: Tensor size(-2) 3 needs to be divisible by blocksize[0] 2
| >>> x.to_sparse(layout=torch.sparse_csr, blocksize=(3, 1))
| RuntimeError: to_sparse for Strided to SparseCsr conversion does not use specified blocksize
|
| >>> x = torch.tensor([[[1], [0]], [[0], [0]], [[2], [3]]])
| >>> x.to_sparse(layout=torch.sparse_csr, dense_dim=1)
| tensor(crow_indices=tensor([0, 1, 1, 3]),
| col_indices=tensor([0, 0, 1]),
| values=tensor([[1],
| [2],
| [3]]), size=(3, 2, 1), nnz=3, layout=torch.sparse_csr)
|
| to_sparse_bsc(...)
| to_sparse_bsc(blocksize, dense_dim) -> Tensor
|
| Convert a tensor to a block sparse column (BSC) storage format of
| given blocksize. If the :attr:`self` is strided, then the number of
| dense dimensions could be specified, and a hybrid BSC tensor will be
| created, with `dense_dim` dense dimensions and `self.dim() - 2 -
| dense_dim` batch dimension.
|
| Args:
|
| blocksize (list, tuple, :class:`torch.Size`, optional): Block size
| of the resulting BSC tensor. A block size must be a tuple of
| length two such that its items evenly divide the two sparse
| dimensions.
|
| dense_dim (int, optional): Number of dense dimensions of the
| resulting BSC tensor. This argument should be used only if
| :attr:`self` is a strided tensor, and must be a value between 0
| and dimension of :attr:`self` tensor minus two.
|
| Example::
|
| >>> dense = torch.randn(10, 10)
| >>> sparse = dense.to_sparse_csr()
| >>> sparse_bsc = sparse.to_sparse_bsc((5, 5))
| >>> sparse_bsc.row_indices()
| tensor([0, 1, 0, 1])
|
| >>> dense = torch.zeros(4, 3, 1)
| >>> dense[0:2, 0] = dense[0:2, 2] = dense[2:4, 1] = 1
| >>> dense.to_sparse_bsc((2, 1), 1)
| tensor(ccol_indices=tensor([0, 1, 2, 3]),
| row_indices=tensor([0, 1, 0]),
| values=tensor([[[[1.]],
|
| [[1.]]],
|
|
| [[[1.]],
|
| [[1.]]],
|
|
| [[[1.]],
|
| [[1.]]]]), size=(4, 3, 1), nnz=3,
| layout=torch.sparse_bsc)
|
| to_sparse_bsr(...)
| to_sparse_bsr(blocksize, dense_dim) -> Tensor
|
| Convert a tensor to a block sparse row (BSR) storage format of given
| blocksize. If the :attr:`self` is strided, then the number of dense
| dimensions could be specified, and a hybrid BSR tensor will be
| created, with `dense_dim` dense dimensions and `self.dim() - 2 -
| dense_dim` batch dimension.
|
| Args:
|
| blocksize (list, tuple, :class:`torch.Size`, optional): Block size
| of the resulting BSR tensor. A block size must be a tuple of
| length two such that its items evenly divide the two sparse
| dimensions.
|
| dense_dim (int, optional): Number of dense dimensions of the
| resulting BSR tensor. This argument should be used only if
| :attr:`self` is a strided tensor, and must be a value between 0
| and dimension of :attr:`self` tensor minus two.
|
| Example::
|
| >>> dense = torch.randn(10, 10)
| >>> sparse = dense.to_sparse_csr()
| >>> sparse_bsr = sparse.to_sparse_bsr((5, 5))
| >>> sparse_bsr.col_indices()
| tensor([0, 1, 0, 1])
|
| >>> dense = torch.zeros(4, 3, 1)
| >>> dense[0:2, 0] = dense[0:2, 2] = dense[2:4, 1] = 1
| >>> dense.to_sparse_bsr((2, 1), 1)
| tensor(crow_indices=tensor([0, 2, 3]),
| col_indices=tensor([0, 2, 1]),
| values=tensor([[[[1.]],
|
| [[1.]]],
|
|
| [[[1.]],
|
| [[1.]]],
|
|
| [[[1.]],
|
| [[1.]]]]), size=(4, 3, 1), nnz=3,
| layout=torch.sparse_bsr)
|
| to_sparse_csc(...)
| to_sparse_csc() -> Tensor
|
| Convert a tensor to compressed column storage (CSC) format. Except
| for strided tensors, only works with 2D tensors. If the :attr:`self`
| is strided, then the number of dense dimensions could be specified,
| and a hybrid CSC tensor will be created, with `dense_dim` dense
| dimensions and `self.dim() - 2 - dense_dim` batch dimension.
|
| Args:
|
| dense_dim (int, optional): Number of dense dimensions of the
| resulting CSC tensor. This argument should be used only if
| :attr:`self` is a strided tensor, and must be a value between 0
| and dimension of :attr:`self` tensor minus two.
|
| Example::
|
| >>> dense = torch.randn(5, 5)
| >>> sparse = dense.to_sparse_csc()
| >>> sparse._nnz()
| 25
|
| >>> dense = torch.zeros(3, 3, 1, 1)
| >>> dense[0, 0] = dense[1, 2] = dense[2, 1] = 1
| >>> dense.to_sparse_csc(dense_dim=2)
| tensor(ccol_indices=tensor([0, 1, 2, 3]),
| row_indices=tensor([0, 2, 1]),
| values=tensor([[[1.]],
|
| [[1.]],
|
| [[1.]]]), size=(3, 3, 1, 1), nnz=3,
| layout=torch.sparse_csc)
|
| to_sparse_csr(...)
| to_sparse_csr(dense_dim=None) -> Tensor
|
| Convert a tensor to compressed row storage format (CSR). Except for
| strided tensors, only works with 2D tensors. If the :attr:`self` is
| strided, then the number of dense dimensions could be specified, and a
| hybrid CSR tensor will be created, with `dense_dim` dense dimensions
| and `self.dim() - 2 - dense_dim` batch dimension.
|
| Args:
|
| dense_dim (int, optional): Number of dense dimensions of the
| resulting CSR tensor. This argument should be used only if
| :attr:`self` is a strided tensor, and must be a value between 0
| and dimension of :attr:`self` tensor minus two.
|
| Example::
|
| >>> dense = torch.randn(5, 5)
| >>> sparse = dense.to_sparse_csr()
| >>> sparse._nnz()
| 25
|
| >>> dense = torch.zeros(3, 3, 1, 1)
| >>> dense[0, 0] = dense[1, 2] = dense[2, 1] = 1
| >>> dense.to_sparse_csr(dense_dim=2)
| tensor(crow_indices=tensor([0, 1, 2, 3]),
| col_indices=tensor([0, 2, 1]),
| values=tensor([[[1.]],
|
| [[1.]],
|
| [[1.]]]), size=(3, 3, 1, 1), nnz=3,
| layout=torch.sparse_csr)
|
| tolist(...)
| tolist() -> list or number
|
| Returns the tensor as a (nested) list. For scalars, a standard
| Python number is returned, just like with :meth:`~Tensor.item`.
| Tensors are automatically moved to the CPU first if necessary.
|
| This operation is not differentiable.
|
| Examples::
|
| >>> a = torch.randn(2, 2)
| >>> a.tolist()
| [[0.012766935862600803, 0.5415473580360413],
| [-0.08909505605697632, 0.7729271650314331]]
| >>> a[0,0].tolist()
| 0.012766935862600803
|
| topk(...)
| topk(k, dim=None, largest=True, sorted=True) -> (Tensor, LongTensor)
|
| See :func:`torch.topk`
|
| trace(...)
| trace() -> Tensor
|
| See :func:`torch.trace`
|
| transpose(...)
| transpose(dim0, dim1) -> Tensor
|
| See :func:`torch.transpose`
|
| transpose_(...)
| transpose_(dim0, dim1) -> Tensor
|
| In-place version of :meth:`~Tensor.transpose`
|
| triangular_solve(...)
| triangular_solve(A, upper=True, transpose=False, unitriangular=False) -> (Tensor, Tensor)
|
| See :func:`torch.triangular_solve`
|
| tril(...)
| tril(diagonal=0) -> Tensor
|
| See :func:`torch.tril`
|
| tril_(...)
| tril_(diagonal=0) -> Tensor
|
| In-place version of :meth:`~Tensor.tril`
|
| triu(...)
| triu(diagonal=0) -> Tensor
|
| See :func:`torch.triu`
|
| triu_(...)
| triu_(diagonal=0) -> Tensor
|
| In-place version of :meth:`~Tensor.triu`
|
| true_divide(...)
| true_divide(value) -> Tensor
|
| See :func:`torch.true_divide`
|
| true_divide_(...)
| true_divide_(value) -> Tensor
|
| In-place version of :meth:`~Tensor.true_divide_`
|
| trunc(...)
| trunc() -> Tensor
|
| See :func:`torch.trunc`
|
| trunc_(...)
| trunc_() -> Tensor
|
| In-place version of :meth:`~Tensor.trunc`
|
| type(...)
| type(dtype=None, non_blocking=False, **kwargs) -> str or Tensor
| Returns the type if `dtype` is not provided, else casts this object to
| the specified type.
|
| If this is already of the correct type, no copy is performed and the
| original object is returned.
|
| Args:
| dtype (dtype or string): The desired type
| non_blocking (bool): If ``True``, and the source is in pinned memory
| and destination is on the GPU or vice versa, the copy is performed
| asynchronously with respect to the host. Otherwise, the argument
| has no effect.
| **kwargs: For compatibility, may contain the key ``async`` in place of
| the ``non_blocking`` argument. The ``async`` arg is deprecated.
|
| type_as(...)
| type_as(tensor) -> Tensor
|
| Returns this tensor cast to the type of the given tensor.
|
| This is a no-op if the tensor is already of the correct type. This is
| equivalent to ``self.type(tensor.type())``
|
| Args:
| tensor (Tensor): the tensor which has the desired type
|
| unbind(...)
| unbind(dim=0) -> seq
|
| See :func:`torch.unbind`
|
| unfold(...)
| unfold(dimension, size, step) -> Tensor
|
| Returns a view of the original tensor which contains all slices of size :attr:`size` from
| :attr:`self` tensor in the dimension :attr:`dimension`.
|
| Step between two slices is given by :attr:`step`.
|
| If `sizedim` is the size of dimension :attr:`dimension` for :attr:`self`, the size of
| dimension :attr:`dimension` in the returned tensor will be
| `(sizedim - size) / step + 1`.
|
| An additional dimension of size :attr:`size` is appended in the returned tensor.
|
| Args:
| dimension (int): dimension in which unfolding happens
| size (int): the size of each slice that is unfolded
| step (int): the step between each slice
|
| Example::
|
| >>> x = torch.arange(1., 8)
| >>> x
| tensor([ 1., 2., 3., 4., 5., 6., 7.])
| >>> x.unfold(0, 2, 1)
| tensor([[ 1., 2.],
| [ 2., 3.],
| [ 3., 4.],
| [ 4., 5.],
| [ 5., 6.],
| [ 6., 7.]])
| >>> x.unfold(0, 2, 2)
| tensor([[ 1., 2.],
| [ 3., 4.],
| [ 5., 6.]])
|
| uniform_(...)
| uniform_(from=0, to=1, *, generator=None) -> Tensor
|
| Fills :attr:`self` tensor with numbers sampled from the continuous uniform
| distribution:
|
| .. math::
| f(x) = \dfrac{1}{\text{to} - \text{from}}
|
| unsafe_chunk(...)
| unsafe_chunk(chunks, dim=0) -> List of Tensors
|
| See :func:`torch.unsafe_chunk`
|
| unsafe_split(...)
| unsafe_split(split_size, dim=0) -> List of Tensors
|
| See :func:`torch.unsafe_split`
|
| unsafe_split_with_sizes(...)
|
| unsqueeze(...)
| unsqueeze(dim) -> Tensor
|
| See :func:`torch.unsqueeze`
|
| unsqueeze_(...)
| unsqueeze_(dim) -> Tensor
|
| In-place version of :meth:`~Tensor.unsqueeze`
|
| untyped_storage(...)
| untyped_storage() -> torch.UntypedStorage
|
| Returns the underlying :class:`UntypedStorage`.
|
| values(...)
| values() -> Tensor
|
| Return the values tensor of a :ref:`sparse COO tensor <sparse-coo-docs>`.
|
| .. warning::
| Throws an error if :attr:`self` is not a sparse COO tensor.
|
| See also :meth:`Tensor.indices`.
|
| .. note::
| This method can only be called on a coalesced sparse tensor. See
| :meth:`Tensor.coalesce` for details.
|
| var(...)
| var(dim=None, *, correction=1, keepdim=False) -> Tensor
|
| See :func:`torch.var`
|
| vdot(...)
| vdot(other) -> Tensor
|
| See :func:`torch.vdot`
|
| view(...)
| view(*shape) -> Tensor
|
| Returns a new tensor with the same data as the :attr:`self` tensor but of a
| different :attr:`shape`.
|
| The returned tensor shares the same data and must have the same number
| of elements, but may have a different size. For a tensor to be viewed, the new
| view size must be compatible with its original size and stride, i.e., each new
| view dimension must either be a subspace of an original dimension, or only span
| across original dimensions :math:`d, d+1, \dots, d+k` that satisfy the following
| contiguity-like condition that :math:`\forall i = d, \dots, d+k-1`,
|
| .. math::
|
| \text{stride}[i] = \text{stride}[i+1] \times \text{size}[i+1]
|
| Otherwise, it will not be possible to view :attr:`self` tensor as :attr:`shape`
| without copying it (e.g., via :meth:`contiguous`). When it is unclear whether a
| :meth:`view` can be performed, it is advisable to use :meth:`reshape`, which
| returns a view if the shapes are compatible, and copies (equivalent to calling
| :meth:`contiguous`) otherwise.
|
| Args:
| shape (torch.Size or int...): the desired size
|
| Example::
|
| >>> x = torch.randn(4, 4)
| >>> x.size()
| torch.Size([4, 4])
| >>> y = x.view(16)
| >>> y.size()
| torch.Size([16])
| >>> z = x.view(-1, 8) # the size -1 is inferred from other dimensions
| >>> z.size()
| torch.Size([2, 8])
|
| >>> a = torch.randn(1, 2, 3, 4)
| >>> a.size()
| torch.Size([1, 2, 3, 4])
| >>> b = a.transpose(1, 2) # Swaps 2nd and 3rd dimension
| >>> b.size()
| torch.Size([1, 3, 2, 4])
| >>> c = a.view(1, 3, 2, 4) # Does not change tensor layout in memory
| >>> c.size()
| torch.Size([1, 3, 2, 4])
| >>> torch.equal(b, c)
| False
|
|
| .. method:: view(dtype) -> Tensor
| :noindex:
|
| Returns a new tensor with the same data as the :attr:`self` tensor but of a
| different :attr:`dtype`.
|
| If the element size of :attr:`dtype` is different than that of ``self.dtype``,
| then the size of the last dimension of the output will be scaled
| proportionally. For instance, if :attr:`dtype` element size is twice that of
| ``self.dtype``, then each pair of elements in the last dimension of
| :attr:`self` will be combined, and the size of the last dimension of the output
| will be half that of :attr:`self`. If :attr:`dtype` element size is half that
| of ``self.dtype``, then each element in the last dimension of :attr:`self` will
| be split in two, and the size of the last dimension of the output will be
| double that of :attr:`self`. For this to be possible, the following conditions
| must be true:
|
| * ``self.dim()`` must be greater than 0.
| * ``self.stride(-1)`` must be 1.
|
| Additionally, if the element size of :attr:`dtype` is greater than that of
| ``self.dtype``, the following conditions must be true as well:
|
| * ``self.size(-1)`` must be divisible by the ratio between the element
| sizes of the dtypes.
| * ``self.storage_offset()`` must be divisible by the ratio between the
| element sizes of the dtypes.
| * The strides of all dimensions, except the last dimension, must be
| divisible by the ratio between the element sizes of the dtypes.
|
| If any of the above conditions are not met, an error is thrown.
|
| .. warning::
|
| This overload is not supported by TorchScript, and using it in a Torchscript
| program will cause undefined behavior.
|
|
| Args:
| dtype (:class:`torch.dtype`): the desired dtype
|
| Example::
|
| >>> x = torch.randn(4, 4)
| >>> x
| tensor([[ 0.9482, -0.0310, 1.4999, -0.5316],
| [-0.1520, 0.7472, 0.5617, -0.8649],
| [-2.4724, -0.0334, -0.2976, -0.8499],
| [-0.2109, 1.9913, -0.9607, -0.6123]])
| >>> x.dtype
| torch.float32
|
| >>> y = x.view(torch.int32)
| >>> y
| tensor([[ 1064483442, -1124191867, 1069546515, -1089989247],
| [-1105482831, 1061112040, 1057999968, -1084397505],
| [-1071760287, -1123489973, -1097310419, -1084649136],
| [-1101533110, 1073668768, -1082790149, -1088634448]],
| dtype=torch.int32)
| >>> y[0, 0] = 1000000000
| >>> x
| tensor([[ 0.0047, -0.0310, 1.4999, -0.5316],
| [-0.1520, 0.7472, 0.5617, -0.8649],
| [-2.4724, -0.0334, -0.2976, -0.8499],
| [-0.2109, 1.9913, -0.9607, -0.6123]])
|
| >>> x.view(torch.cfloat)
| tensor([[ 0.0047-0.0310j, 1.4999-0.5316j],
| [-0.1520+0.7472j, 0.5617-0.8649j],
| [-2.4724-0.0334j, -0.2976-0.8499j],
| [-0.2109+1.9913j, -0.9607-0.6123j]])
| >>> x.view(torch.cfloat).size()
| torch.Size([4, 2])
|
| >>> x.view(torch.uint8)
| tensor([[ 0, 202, 154, 59, 182, 243, 253, 188, 185, 252, 191, 63, 240, 22,
| 8, 191],
| [227, 165, 27, 190, 128, 72, 63, 63, 146, 203, 15, 63, 22, 106,
| 93, 191],
| [205, 59, 30, 192, 112, 206, 8, 189, 7, 95, 152, 190, 12, 147,
| 89, 191],
| [ 43, 246, 87, 190, 235, 226, 254, 63, 111, 240, 117, 191, 177, 191,
| 28, 191]], dtype=torch.uint8)
| >>> x.view(torch.uint8).size()
| torch.Size([4, 16])
|
| view_as(...)
| view_as(other) -> Tensor
|
| View this tensor as the same size as :attr:`other`.
| ``self.view_as(other)`` is equivalent to ``self.view(other.size())``.
|
| Please see :meth:`~Tensor.view` for more information about ``view``.
|
| Args:
| other (:class:`torch.Tensor`): The result tensor has the same size
| as :attr:`other`.
|
| vsplit(...)
| vsplit(split_size_or_sections) -> List of Tensors
|
| See :func:`torch.vsplit`
|
| where(...)
| where(condition, y) -> Tensor
|
| ``self.where(condition, y)`` is equivalent to ``torch.where(condition, self, y)``.
| See :func:`torch.where`
|
| xlogy(...)
| xlogy(other) -> Tensor
|
| See :func:`torch.xlogy`
|
| xlogy_(...)
| xlogy_(other) -> Tensor
|
| In-place version of :meth:`~Tensor.xlogy`
|
| xpu(...)
| xpu(device=None, non_blocking=False, memory_format=torch.preserve_format) -> Tensor
|
| Returns a copy of this object in XPU memory.
|
| If this object is already in XPU memory and on the correct device,
| then no copy is performed and the original object is returned.
|
| Args:
| device (:class:`torch.device`): The destination XPU device.
| Defaults to the current XPU device.
| non_blocking (bool): If ``True`` and the source is in pinned memory,
| the copy will be asynchronous with respect to the host.
| Otherwise, the argument has no effect. Default: ``False``.
| memory_format (:class:`torch.memory_format`, optional): the desired memory format of
| returned Tensor. Default: ``torch.preserve_format``.
|
| zero_(...)
| zero_() -> Tensor
|
| Fills :attr:`self` tensor with zeros.
|
| ----------------------------------------------------------------------
| Static methods inherited from torch._C.TensorBase:
|
| __new__(*args, **kwargs) class method of torch._C.TensorBase
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from torch._C.TensorBase:
|
| H
| Returns a view of a matrix (2-D tensor) conjugated and transposed.
|
| ``x.H`` is equivalent to ``x.transpose(0, 1).conj()`` for complex matrices and
| ``x.transpose(0, 1)`` for real matrices.
|
| .. seealso::
|
| :attr:`~.Tensor.mH`: An attribute that also works on batches of matrices.
|
| T
| Returns a view of this tensor with its dimensions reversed.
|
| If ``n`` is the number of dimensions in ``x``,
| ``x.T`` is equivalent to ``x.permute(n-1, n-2, ..., 0)``.
|
| .. warning::
| The use of :func:`Tensor.T` on tensors of dimension other than 2 to reverse their shape
| is deprecated and it will throw an error in a future release. Consider :attr:`~.Tensor.mT`
| to transpose batches of matrices or `x.permute(*torch.arange(x.ndim - 1, -1, -1))` to reverse
| the dimensions of a tensor.
|
| data
|
| device
| Is the :class:`torch.device` where this Tensor is.
|
| dtype
|
| grad
| This attribute is ``None`` by default and becomes a Tensor the first time a call to
| :func:`backward` computes gradients for ``self``.
| The attribute will then contain the gradients computed and future calls to
| :func:`backward` will accumulate (add) gradients into it.
|
| grad_fn
|
| imag
| Returns a new tensor containing imaginary values of the :attr:`self` tensor.
| The returned tensor and :attr:`self` share the same underlying storage.
|
| .. warning::
| :func:`imag` is only supported for tensors with complex dtypes.
|
| Example::
| >>> x=torch.randn(4, dtype=torch.cfloat)
| >>> x
| tensor([(0.3100+0.3553j), (-0.5445-0.7896j), (-1.6492-0.0633j), (-0.0638-0.8119j)])
| >>> x.imag
| tensor([ 0.3553, -0.7896, -0.0633, -0.8119])
|
| is_cpu
| Is ``True`` if the Tensor is stored on the CPU, ``False`` otherwise.
|
| is_cuda
| Is ``True`` if the Tensor is stored on the GPU, ``False`` otherwise.
|
| is_ipu
| Is ``True`` if the Tensor is stored on the IPU, ``False`` otherwise.
|
| is_leaf
| All Tensors that have :attr:`requires_grad` which is ``False`` will be leaf Tensors by convention.
|
| For Tensors that have :attr:`requires_grad` which is ``True``, they will be leaf Tensors if they were
| created by the user. This means that they are not the result of an operation and so
| :attr:`grad_fn` is None.
|
| Only leaf Tensors will have their :attr:`grad` populated during a call to :func:`backward`.
| To get :attr:`grad` populated for non-leaf Tensors, you can use :func:`retain_grad`.
|
| Example::
|
| >>> a = torch.rand(10, requires_grad=True)
| >>> a.is_leaf
| True
| >>> b = torch.rand(10, requires_grad=True).cuda()
| >>> b.is_leaf
| False
| # b was created by the operation that cast a cpu Tensor into a cuda Tensor
| >>> c = torch.rand(10, requires_grad=True) + 2
| >>> c.is_leaf
| False
| # c was created by the addition operation
| >>> d = torch.rand(10).cuda()
| >>> d.is_leaf
| True
| # d does not require gradients and so has no operation creating it (that is tracked by the autograd engine)
| >>> e = torch.rand(10).cuda().requires_grad_()
| >>> e.is_leaf
| True
| # e requires gradients and has no operations creating it
| >>> f = torch.rand(10, requires_grad=True, device="cuda")
| >>> f.is_leaf
| True
| # f requires grad, has no operation creating it
|
| is_meta
| Is ``True`` if the Tensor is a meta tensor, ``False`` otherwise. Meta tensors
| are like normal tensors, but they carry no data.
|
| is_mkldnn
|
| is_mps
| Is ``True`` if the Tensor is stored on the MPS device, ``False`` otherwise.
|
| is_mtia
|
| is_nested
|
| is_ort
|
| is_quantized
| Is ``True`` if the Tensor is quantized, ``False`` otherwise.
|
| is_sparse
| Is ``True`` if the Tensor uses sparse COO storage layout, ``False`` otherwise.
|
| is_sparse_csr
| Is ``True`` if the Tensor uses sparse CSR storage layout, ``False`` otherwise.
|
| is_vulkan
|
| is_xla
| Is ``True`` if the Tensor is stored on an XLA device, ``False`` otherwise.
|
| is_xpu
| Is ``True`` if the Tensor is stored on the XPU, ``False`` otherwise.
|
| itemsize
| Alias for :meth:`~Tensor.element_size()`
|
| layout
|
| mH
| Accessing this property is equivalent to calling :func:`adjoint`.
|
| mT
| Returns a view of this tensor with the last two dimensions transposed.
|
| ``x.mT`` is equivalent to ``x.transpose(-2, -1)``.
|
| name
|
| names
| Stores names for each of this tensor's dimensions.
|
| ``names[idx]`` corresponds to the name of tensor dimension ``idx``.
| Names are either a string if the dimension is named or ``None`` if the
| dimension is unnamed.
|
| Dimension names may contain characters or underscore. Furthermore, a dimension
| name must be a valid Python variable name (i.e., does not start with underscore).
|
| Tensors may not have two named dimensions with the same name.
|
| .. warning::
| The named tensor API is experimental and subject to change.
|
| nbytes
| Returns the number of bytes consumed by the "view" of elements of the Tensor
| if the Tensor does not use sparse storage layout.
| Defined to be :meth:`~Tensor.numel()` * :meth:`~Tensor.element_size()`
|
| ndim
| Alias for :meth:`~Tensor.dim()`
|
| output_nr
|
| real
| Returns a new tensor containing real values of the :attr:`self` tensor for a complex-valued input tensor.
| The returned tensor and :attr:`self` share the same underlying storage.
|
| Returns :attr:`self` if :attr:`self` is a real-valued tensor tensor.
|
| Example::
| >>> x=torch.randn(4, dtype=torch.cfloat)
| >>> x
| tensor([(0.3100+0.3553j), (-0.5445-0.7896j), (-1.6492-0.0633j), (-0.0638-0.8119j)])
| >>> x.real
| tensor([ 0.3100, -0.5445, -1.6492, -0.0638])
|
| requires_grad
| Is ``True`` if gradients need to be computed for this Tensor, ``False`` otherwise.
|
| .. note::
|
| The fact that gradients need to be computed for a Tensor do not mean that the :attr:`grad`
| attribute will be populated, see :attr:`is_leaf` for more details.
|
| retains_grad
| Is ``True`` if this Tensor is non-leaf and its :attr:`grad` is enabled to be
| populated during :func:`backward`, ``False`` otherwise.
|
| shape
| shape() -> torch.Size
|
| Returns the size of the :attr:`self` tensor. Alias for :attr:`size`.
|
| See also :meth:`Tensor.size`.
|
| Example::
|
| >>> t = torch.empty(3, 4, 5)
| >>> t.size()
| torch.Size([3, 4, 5])
| >>> t.shape
| torch.Size([3, 4, 5])
|
| volatile
|