forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_tensor_docs.py
3565 lines (2616 loc) · 82 KB
/
_tensor_docs.py
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
"""Adds docstrings to Tensor functions"""
import torch._C
from torch._C import _add_docstr as add_docstr
from ._torch_docs import parse_kwargs
def add_docstr_all(method, docstr):
add_docstr(getattr(torch._C._TensorBase, method), docstr)
new_common_args = parse_kwargs("""
size (int...): a list, tuple, or :class:`torch.Size` of integers defining the
shape of the output tensor.
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``.
pin_memory (bool, optional): If set, returned tensor would be allocated in
the pinned memory. Works only for CPU tensors. Default: ``False``.
""")
add_docstr_all('new_tensor',
r"""
new_tensor(data, dtype=None, device=None, requires_grad=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`.
{dtype}
{device}
{requires_grad}
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)
""".format(**new_common_args))
add_docstr_all('new_full',
r"""
new_full(size, fill_value, dtype=None, device=None, requires_grad=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.
{dtype}
{device}
{requires_grad}
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)
""".format(**new_common_args))
add_docstr_all('new_empty',
r"""
new_empty(size, dtype=None, device=None, requires_grad=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:
{dtype}
{device}
{requires_grad}
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]])
""".format(**new_common_args))
add_docstr_all('new_ones',
r"""
new_ones(size, dtype=None, device=None, requires_grad=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.
{dtype}
{device}
{requires_grad}
Example::
>>> tensor = torch.tensor((), dtype=torch.int32)
>>> tensor.new_ones((2, 3))
tensor([[ 1, 1, 1],
[ 1, 1, 1]], dtype=torch.int32)
""".format(**new_common_args))
add_docstr_all('new_zeros',
r"""
new_zeros(size, dtype=None, device=None, requires_grad=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.
{dtype}
{device}
{requires_grad}
Example::
>>> tensor = torch.tensor((), dtype=torch.float64)
>>> tensor.new_zeros((2, 3))
tensor([[ 0., 0., 0.],
[ 0., 0., 0.]], dtype=torch.float64)
""".format(**new_common_args))
add_docstr_all('abs',
r"""
abs() -> Tensor
See :func:`torch.abs`
""")
add_docstr_all('abs_',
r"""
abs_() -> Tensor
In-place version of :meth:`~Tensor.abs`
""")
add_docstr_all('acos',
r"""
acos() -> Tensor
See :func:`torch.acos`
""")
add_docstr_all('acos_',
r"""
acos_() -> Tensor
In-place version of :meth:`~Tensor.acos`
""")
add_docstr_all('add',
r"""
add(value) -> Tensor
add(other, *, value=1) -> Tensor
See :func:`torch.add`
""")
add_docstr_all('add_',
r"""
add_(value) -> Tensor
add_(other, *, value=1) -> Tensor
In-place version of :meth:`~Tensor.add`
""")
add_docstr_all('addbmm',
r"""
addbmm(batch1, batch2, *, beta=1, alpha=1) -> Tensor
See :func:`torch.addbmm`
""")
add_docstr_all('addbmm_',
r"""
addbmm_(batch1, batch2, *, beta=1, alpha=1) -> Tensor
In-place version of :meth:`~Tensor.addbmm`
""")
add_docstr_all('addcdiv',
r"""
addcdiv(tensor1, tensor2, *, value=1) -> Tensor
See :func:`torch.addcdiv`
""")
add_docstr_all('addcdiv_',
r"""
addcdiv_(tensor1, tensor2, *, value=1) -> Tensor
In-place version of :meth:`~Tensor.addcdiv`
""")
add_docstr_all('addcmul',
r"""
addcmul(tensor1, tensor2, *, value=1) -> Tensor
See :func:`torch.addcmul`
""")
add_docstr_all('addcmul_',
r"""
addcmul_(tensor1, tensor2, *, value=1) -> Tensor
In-place version of :meth:`~Tensor.addcmul`
""")
add_docstr_all('addmm',
r"""
addmm(mat1, mat2, *, beta=1, alpha=1) -> Tensor
See :func:`torch.addmm`
""")
add_docstr_all('addmm_',
r"""
addmm_(mat1, mat2, *, beta=1, alpha=1) -> Tensor
In-place version of :meth:`~Tensor.addmm`
""")
add_docstr_all('addmv',
r"""
addmv(mat, vec, *, beta=1, alpha=1) -> Tensor
See :func:`torch.addmv`
""")
add_docstr_all('addmv_',
r"""
addmv_(mat, vec, *, beta=1, alpha=1) -> Tensor
In-place version of :meth:`~Tensor.addmv`
""")
add_docstr_all('addr',
r"""
addr(vec1, vec2, *, beta=1, alpha=1) -> Tensor
See :func:`torch.addr`
""")
add_docstr_all('addr_',
r"""
addr_(vec1, vec2, *, beta=1, alpha=1) -> Tensor
In-place version of :meth:`~Tensor.addr`
""")
add_docstr_all('align_as',
r"""
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.
""")
add_docstr_all('all',
r"""
.. function:: all() -> bool
Returns True if all elements in the tensor are True, False otherwise.
Example::
>>> a = torch.rand(1, 2).bool()
>>> a
tensor([[False, True]], dtype=torch.bool)
>>> a.all()
tensor(False, dtype=torch.bool)
.. function:: all(dim, keepdim=False, out=None) -> Tensor
Returns True if all elements in each row of the tensor in the given
dimension :attr:`dim` are True, False otherwise.
If :attr:`keepdim` is ``True``, the output tensor is of the same size as
:attr:`input` except in the dimension :attr:`dim` where it is of size 1.
Otherwise, :attr:`dim` is squeezed (see :func:`torch.squeeze`), resulting
in the output tensor having 1 fewer dimension than :attr:`input`.
Args:
dim (int): the dimension to reduce
keepdim (bool): whether the output tensor has :attr:`dim` retained or not
out (Tensor, optional): the output tensor
Example::
>>> a = torch.rand(4, 2).bool()
>>> a
tensor([[True, True],
[True, False],
[True, True],
[True, True]], dtype=torch.bool)
>>> a.all(dim=1)
tensor([ True, False, True, True], dtype=torch.bool)
>>> a.all(dim=0)
tensor([ True, False], dtype=torch.bool)
""")
add_docstr_all('allclose',
r"""
allclose(other, rtol=1e-05, atol=1e-08, equal_nan=False) -> Tensor
See :func:`torch.allclose`
""")
add_docstr_all('angle',
r"""
angle() -> Tensor
See :func:`torch.angle`
""")
add_docstr_all('any',
r"""
.. function:: any() -> bool
Returns True if any elements in the tensor are True, False otherwise.
Example::
>>> a = torch.rand(1, 2).bool()
>>> a
tensor([[False, True]], dtype=torch.bool)
>>> a.any()
tensor(True, dtype=torch.bool)
.. function:: any(dim, keepdim=False, out=None) -> Tensor
Returns True if any elements in each row of the tensor in the given
dimension :attr:`dim` are True, False otherwise.
If :attr:`keepdim` is ``True``, the output tensor is of the same size as
:attr:`input` except in the dimension :attr:`dim` where it is of size 1.
Otherwise, :attr:`dim` is squeezed (see :func:`torch.squeeze`), resulting
in the output tensor having 1 fewer dimension than :attr:`input`.
Args:
dim (int): the dimension to reduce
keepdim (bool): whether the output tensor has :attr:`dim` retained or not
out (Tensor, optional): the output tensor
Example::
>>> a = torch.randn(4, 2) < 0
>>> a
tensor([[ True, True],
[False, True],
[ True, True],
[False, False]])
>>> a.any(1)
tensor([ True, True, True, False])
>>> a.any(0)
tensor([True, True])
""")
add_docstr_all('apply_',
r"""
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.
""")
add_docstr_all('asin', r"""
asin() -> Tensor
See :func:`torch.asin`
""")
add_docstr_all('asin_',
r"""
asin_() -> Tensor
In-place version of :meth:`~Tensor.asin`
""")
add_docstr_all('as_strided', r"""
as_strided(size, stride, storage_offset=0) -> Tensor
See :func:`torch.as_strided`
""")
add_docstr_all('atan',
r"""
atan() -> Tensor
See :func:`torch.atan`
""")
add_docstr_all('atan2',
r"""
atan2(other) -> Tensor
See :func:`torch.atan2`
""")
add_docstr_all('atan2_',
r"""
atan2_(other) -> Tensor
In-place version of :meth:`~Tensor.atan2`
""")
add_docstr_all('atan_',
r"""
atan_() -> Tensor
In-place version of :meth:`~Tensor.atan`
""")
add_docstr_all('baddbmm',
r"""
baddbmm(batch1, batch2, *, beta=1, alpha=1) -> Tensor
See :func:`torch.baddbmm`
""")
add_docstr_all('baddbmm_',
r"""
baddbmm_(batch1, batch2, *, beta=1, alpha=1) -> Tensor
In-place version of :meth:`~Tensor.baddbmm`
""")
add_docstr_all('bernoulli',
r"""
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`
""")
add_docstr_all('bernoulli_',
r"""
.. function:: 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``.
.. function:: bernoulli_(p_tensor, *, generator=None) -> Tensor
:attr:`p_tensor` should be a tensor containing probabilities to be used for
drawing the binary random number.
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]})`.
:attr:`self` can have integral ``dtype``, but :attr:`p_tensor` must have
floating point ``dtype``.
See also :meth:`~Tensor.bernoulli` and :func:`torch.bernoulli`
""")
add_docstr_all('bincount',
r"""
bincount(weights=None, minlength=0) -> Tensor
See :func:`torch.bincount`
""")
add_docstr_all('bitwise_not',
r"""
bitwise_not() -> Tensor
See :func:`torch.bitwise_not`
""")
add_docstr_all('bitwise_not_',
r"""
bitwise_not_() -> Tensor
In-place version of :meth:`~Tensor.bitwise_not`
""")
add_docstr_all('bitwise_and',
r"""
bitwise_and() -> Tensor
See :func:`torch.bitwise_and`
""")
add_docstr_all('bitwise_and_',
r"""
bitwise_and_() -> Tensor
In-place version of :meth:`~Tensor.bitwise_and`
""")
add_docstr_all('bitwise_or',
r"""
bitwise_or() -> Tensor
See :func:`torch.bitwise_or`
""")
add_docstr_all('bitwise_or_',
r"""
bitwise_or_() -> Tensor
In-place version of :meth:`~Tensor.bitwise_or`
""")
add_docstr_all('bitwise_xor',
r"""
bitwise_xor() -> Tensor
See :func:`torch.bitwise_xor`
""")
add_docstr_all('bitwise_xor_',
r"""
bitwise_xor_() -> Tensor
In-place version of :meth:`~Tensor.bitwise_xor`
""")
add_docstr_all('logical_and',
r"""
logical_and() -> Tensor
See :func:`torch.logical_and`
""")
add_docstr_all('logical_and_',
r"""
logical_and_() -> Tensor
In-place version of :meth:`~Tensor.logical_and`
""")
add_docstr_all('logical_not',
r"""
logical_not() -> Tensor
See :func:`torch.logical_not`
""")
add_docstr_all('logical_not_',
r"""
logical_not_() -> Tensor
In-place version of :meth:`~Tensor.logical_not`
""")
add_docstr_all('logical_or',
r"""
logical_or() -> Tensor
See :func:`torch.logical_or`
""")
add_docstr_all('logical_or_',
r"""
logical_or_() -> Tensor
In-place version of :meth:`~Tensor.logical_or`
""")
add_docstr_all('logical_xor',
r"""
logical_xor() -> Tensor
See :func:`torch.logical_xor`
""")
add_docstr_all('logical_xor_',
r"""
logical_xor_() -> Tensor
In-place version of :meth:`~Tensor.logical_xor`
""")
add_docstr_all('bmm',
r"""
bmm(batch2) -> Tensor
See :func:`torch.bmm`
""")
add_docstr_all('cauchy_',
r"""
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}
""")
add_docstr_all('ceil',
r"""
ceil() -> Tensor
See :func:`torch.ceil`
""")
add_docstr_all('ceil_',
r"""
ceil_() -> Tensor
In-place version of :meth:`~Tensor.ceil`
""")
add_docstr_all('cholesky',
r"""
cholesky(upper=False) -> Tensor
See :func:`torch.cholesky`
""")
add_docstr_all('cholesky_solve',
r"""
cholesky_solve(input2, upper=False) -> Tensor
See :func:`torch.cholesky_solve`
""")
add_docstr_all('cholesky_inverse',
r"""
cholesky_inverse(upper=False) -> Tensor
See :func:`torch.cholesky_inverse`
""")
add_docstr_all('clamp',
r"""
clamp(min, max) -> Tensor
See :func:`torch.clamp`
""")
add_docstr_all('clamp_',
r"""
clamp_(min, max) -> Tensor
In-place version of :meth:`~Tensor.clamp`
""")
add_docstr_all('clone',
r"""
clone() -> Tensor
Returns a copy of the :attr:`self` tensor. The copy has the same size and data
type as :attr:`self`.
.. note::
Unlike `copy_()`, this function is recorded in the computation graph. Gradients
propagating to the cloned tensor will propagate to the original tensor.
""")
add_docstr_all('contiguous',
r"""
contiguous() -> Tensor
Returns a contiguous tensor containing the same data as :attr:`self` tensor. If
:attr:`self` tensor is contiguous, this function returns the :attr:`self`
tensor.
""")
add_docstr_all('copy_',
r"""
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.
""")
add_docstr_all('conj',
r"""
conj() -> Tensor
See :func:`torch.conj`
""")
add_docstr_all('cos',
r"""
cos() -> Tensor
See :func:`torch.cos`
""")
add_docstr_all('cos_',
r"""
cos_() -> Tensor
In-place version of :meth:`~Tensor.cos`
""")
add_docstr_all('cosh',
r"""
cosh() -> Tensor
See :func:`torch.cosh`
""")
add_docstr_all('cosh_',
r"""
cosh_() -> Tensor
In-place version of :meth:`~Tensor.cosh`
""")
add_docstr_all('cpu',
r"""
cpu() -> 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.
""")
add_docstr_all('cross',
r"""
cross(other, dim=-1) -> Tensor
See :func:`torch.cross`
""")
add_docstr_all('cuda',
r"""
cuda(device=None, non_blocking=False) -> 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``.
""")
add_docstr_all('cummax',
r"""
cummax(dim) -> (Tensor, Tensor)
See :func:`torch.cummax`
""")
add_docstr_all('cummin',
r"""
cummin(dim) -> (Tensor, Tensor)
See :func:`torch.cummin`
""")
add_docstr_all('cumprod',
r"""
cumprod(dim, dtype=None) -> Tensor
See :func:`torch.cumprod`
""")
add_docstr_all('cumsum',
r"""
cumsum(dim, dtype=None) -> Tensor
See :func:`torch.cumsum`
""")
add_docstr_all('data_ptr',
r"""
data_ptr() -> int
Returns the address of the first element of :attr:`self` tensor.
""")
add_docstr_all('dequantize',
r"""
dequantize() -> Tensor
Given a quantized Tensor, dequantize it and return the dequantized float Tensor.
""")
add_docstr_all('dense_dim',
r"""
dense_dim() -> int
If :attr:`self` is a sparse COO tensor (i.e., with ``torch.sparse_coo`` layout),
this returns the number of dense dimensions. Otherwise, this throws an error.
See also :meth:`Tensor.sparse_dim`.
""")
add_docstr_all('diag',
r"""
diag(diagonal=0) -> Tensor
See :func:`torch.diag`
""")
add_docstr_all('diag_embed',
r"""
diag_embed(offset=0, dim1=-2, dim2=-1) -> Tensor
See :func:`torch.diag_embed`
""")
add_docstr_all('diagflat',
r"""
diagflat(offset=0) -> Tensor
See :func:`torch.diagflat`
""")
add_docstr_all('diagonal',
r"""
diagonal(offset=0, dim1=0, dim2=1) -> Tensor
See :func:`torch.diagonal`
""")
add_docstr_all('fill_diagonal_',
r"""
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.]])
""")
add_docstr_all('digamma',
r"""
digamma() -> Tensor
See :func:`torch.digamma`
""")
add_docstr_all('digamma_',
r"""
digamma_() -> Tensor
In-place version of :meth:`~Tensor.digamma`
""")
add_docstr_all('dim',
r"""
dim() -> int
Returns the number of dimensions of :attr:`self` tensor.
""")
add_docstr_all('dist',
r"""
dist(other, p=2) -> Tensor
See :func:`torch.dist`
""")
add_docstr_all('div',
r"""
div(value) -> Tensor
See :func:`torch.div`
""")
add_docstr_all('div_',
r"""
div_(value) -> Tensor
In-place version of :meth:`~Tensor.div`
""")
add_docstr_all('dot',
r"""
dot(tensor2) -> Tensor
See :func:`torch.dot`