|
2 | 2 |
|
3 | 3 | import torch
|
4 | 4 | from torch._C import _add_docstr, _fft # type: ignore[attr-defined]
|
5 |
| -from torch._torch_docs import factory_common_args |
| 5 | +from torch._torch_docs import factory_common_args, common_args |
6 | 6 |
|
7 | 7 | __all__ = ['fft', 'ifft', 'fft2', 'ifft2', 'fftn', 'ifftn',
|
8 | 8 | 'rfft', 'irfft', 'rfft2', 'irfft2', 'rfftn', 'irfftn',
|
|
15 | 15 | # connects the torch.fft Python namespace to the torch._C._fft builtins.
|
16 | 16 |
|
17 | 17 | fft = _add_docstr(_fft.fft_fft, r"""
|
18 |
| -fft(input, n=None, dim=-1, norm=None) -> Tensor |
| 18 | +fft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
19 | 19 |
|
20 | 20 | Computes the one dimensional discrete Fourier transform of :attr:`input`.
|
21 | 21 |
|
|
47 | 47 |
|
48 | 48 | Default is ``"backward"`` (no normalization).
|
49 | 49 |
|
| 50 | +Keyword args: |
| 51 | + {out} |
| 52 | +
|
50 | 53 | Example:
|
51 | 54 |
|
52 | 55 | >>> t = torch.arange(4)
|
|
58 | 61 | >>> t = tensor([0.+1.j, 2.+3.j, 4.+5.j, 6.+7.j])
|
59 | 62 | >>> torch.fft.fft(t)
|
60 | 63 | tensor([12.+16.j, -8.+0.j, -4.-4.j, 0.-8.j])
|
61 |
| -""") |
| 64 | +""".format(**common_args)) |
62 | 65 |
|
63 | 66 | ifft = _add_docstr(_fft.fft_ifft, r"""
|
64 |
| -ifft(input, n=None, dim=-1, norm=None) -> Tensor |
| 67 | +ifft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
65 | 68 |
|
66 | 69 | Computes the one dimensional inverse discrete Fourier transform of :attr:`input`.
|
67 | 70 |
|
|
84 | 87 |
|
85 | 88 | Default is ``"backward"`` (normalize by ``1/n``).
|
86 | 89 |
|
| 90 | +Keyword args: |
| 91 | + {out} |
| 92 | +
|
87 | 93 | Example:
|
88 | 94 |
|
89 | 95 | >>> t = torch.tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
|
90 | 96 | >>> torch.fft.ifft(t)
|
91 | 97 | tensor([0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j])
|
92 |
| -""") |
| 98 | +""".format(**common_args)) |
93 | 99 |
|
94 | 100 | fft2 = _add_docstr(_fft.fft_fft2, r"""
|
95 |
| -fft2(input, s=None, dim=(-2, -1), norm=None) -> Tensor |
| 101 | +fft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) -> Tensor |
96 | 102 |
|
97 | 103 | Computes the 2 dimensional discrete Fourier transform of :attr:`input`.
|
98 | 104 | Equivalent to :func:`~torch.fft.fftn` but FFTs only the last two dimensions by default.
|
|
129 | 135 |
|
130 | 136 | Default is ``"backward"`` (no normalization).
|
131 | 137 |
|
| 138 | +Keyword args: |
| 139 | + {out} |
| 140 | +
|
132 | 141 | Example:
|
133 | 142 |
|
134 | 143 | >>> x = torch.rand(10, 10, dtype=torch.complex64)
|
|
140 | 149 | >>> two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
|
141 | 150 | >>> torch.allclose(fft2, two_ffts)
|
142 | 151 |
|
143 |
| -""") |
| 152 | +""".format(**common_args)) |
144 | 153 |
|
145 | 154 | ifft2 = _add_docstr(_fft.fft_ifft2, r"""
|
146 |
| -ifft2(input, s=None, dim=(-2, -1), norm=None) -> Tensor |
| 155 | +ifft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) -> Tensor |
147 | 156 |
|
148 | 157 | Computes the 2 dimensional inverse discrete Fourier transform of :attr:`input`.
|
149 | 158 | Equivalent to :func:`~torch.fft.ifftn` but IFFTs only the last two dimensions by default.
|
|
172 | 181 |
|
173 | 182 | Default is ``"backward"`` (normalize by ``1/n``).
|
174 | 183 |
|
| 184 | +Keyword args: |
| 185 | + {out} |
| 186 | +
|
175 | 187 | Example:
|
176 | 188 |
|
177 | 189 | >>> x = torch.rand(10, 10, dtype=torch.complex64)
|
|
183 | 195 | >>> two_iffts = torch.fft.ifft(torch.fft.ifft(x, dim=0), dim=1)
|
184 | 196 | >>> torch.allclose(ifft2, two_iffts)
|
185 | 197 |
|
186 |
| -""") |
| 198 | +""".format(**common_args)) |
187 | 199 |
|
188 | 200 | fftn = _add_docstr(_fft.fft_fftn, r"""
|
189 |
| -fftn(input, s=None, dim=None, norm=None) -> Tensor |
| 201 | +fftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor |
190 | 202 |
|
191 | 203 | Computes the N dimensional discrete Fourier transform of :attr:`input`.
|
192 | 204 |
|
|
223 | 235 |
|
224 | 236 | Default is ``"backward"`` (no normalization).
|
225 | 237 |
|
| 238 | +Keyword args: |
| 239 | + {out} |
| 240 | +
|
226 | 241 | Example:
|
227 | 242 |
|
228 | 243 | >>> x = torch.rand(10, 10, dtype=torch.complex64)
|
|
234 | 249 | >>> two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
|
235 | 250 | >>> torch.allclose(fftn, two_ffts)
|
236 | 251 |
|
237 |
| -""") |
| 252 | +""".format(**common_args)) |
238 | 253 |
|
239 | 254 | ifftn = _add_docstr(_fft.fft_ifftn, r"""
|
240 |
| -ifftn(input, s=None, dim=None, norm=None) -> Tensor |
| 255 | +ifftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor |
241 | 256 |
|
242 | 257 | Computes the N dimensional inverse discrete Fourier transform of :attr:`input`.
|
243 | 258 |
|
|
265 | 280 |
|
266 | 281 | Default is ``"backward"`` (normalize by ``1/n``).
|
267 | 282 |
|
| 283 | +Keyword args: |
| 284 | + {out} |
| 285 | +
|
268 | 286 | Example:
|
269 | 287 |
|
270 | 288 | >>> x = torch.rand(10, 10, dtype=torch.complex64)
|
|
276 | 294 | >>> two_iffts = torch.fft.ifft(torch.fft.ifft(x, dim=0), dim=1)
|
277 | 295 | >>> torch.allclose(ifftn, two_iffts)
|
278 | 296 |
|
279 |
| -""") |
| 297 | +""".format(**common_args)) |
280 | 298 |
|
281 | 299 | rfft = _add_docstr(_fft.fft_rfft, r"""
|
282 |
| -rfft(input, n=None, dim=-1, norm=None) -> Tensor |
| 300 | +rfft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
283 | 301 |
|
284 | 302 | Computes the one dimensional Fourier transform of real-valued :attr:`input`.
|
285 | 303 |
|
|
306 | 324 |
|
307 | 325 | Default is ``"backward"`` (no normalization).
|
308 | 326 |
|
| 327 | +Keyword args: |
| 328 | + {out} |
| 329 | +
|
309 | 330 | Example:
|
310 | 331 |
|
311 | 332 | >>> t = torch.arange(4)
|
|
322 | 343 | Notice that the symmetric element ``T[-1] == T[1].conj()`` is omitted.
|
323 | 344 | At the Nyquist frequency ``T[-2] == T[2]`` is it's own symmetric pair,
|
324 | 345 | and therefore must always be real-valued.
|
325 |
| -""") |
| 346 | +""".format(**common_args)) |
326 | 347 |
|
327 | 348 | irfft = _add_docstr(_fft.fft_irfft, r"""
|
328 |
| -irfft(input, n=None, dim=-1, norm=None) -> Tensor |
| 349 | +irfft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
329 | 350 |
|
330 | 351 | Computes the inverse of :func:`~torch.fft.rfft`.
|
331 | 352 |
|
|
367 | 388 |
|
368 | 389 | Default is ``"backward"`` (normalize by ``1/n``).
|
369 | 390 |
|
| 391 | +Keyword args: |
| 392 | + {out} |
| 393 | +
|
370 | 394 | Example:
|
371 | 395 |
|
372 | 396 | >>> t = torch.arange(5)
|
|
386 | 410 |
|
387 | 411 | >>> torch.fft.irfft(T, t.numel())
|
388 | 412 | tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000])
|
389 |
| -""") |
| 413 | +""".format(**common_args)) |
390 | 414 |
|
391 | 415 | rfft2 = _add_docstr(_fft.fft_rfft2, r"""
|
392 |
| -rfft2(input, s=None, dim=(-2, -1), norm=None) -> Tensor |
| 416 | +rfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) -> Tensor |
393 | 417 |
|
394 | 418 | Computes the 2-dimensional discrete Fourier transform of real :attr:`input`.
|
395 | 419 | Equivalent to :func:`~torch.fft.rfftn` but FFTs only the last two dimensions by default.
|
|
423 | 447 |
|
424 | 448 | Default is ``"backward"`` (no normalization).
|
425 | 449 |
|
| 450 | +Keyword args: |
| 451 | + {out} |
| 452 | +
|
426 | 453 | Example:
|
427 | 454 |
|
428 | 455 | >>> t = torch.rand(10, 10)
|
|
444 | 471 | >>> two_ffts = torch.fft.fft(torch.fft.rfft(x, dim=1), dim=0)
|
445 | 472 | >>> torch.allclose(rfft2, two_ffts)
|
446 | 473 |
|
447 |
| -""") |
| 474 | +""".format(**common_args)) |
448 | 475 |
|
449 | 476 | irfft2 = _add_docstr(_fft.fft_irfft2, r"""
|
450 |
| -irfft2(input, s=None, dim=(-2, -1), norm=None) -> Tensor |
| 477 | +irfft2(input, s=None, dim=(-2, -1), norm=None, *, out=None) -> Tensor |
451 | 478 |
|
452 | 479 | Computes the inverse of :func:`~torch.fft.rfft2`.
|
453 | 480 | Equivalent to :func:`~torch.fft.irfftn` but IFFTs only the last two dimensions by default.
|
|
495 | 522 |
|
496 | 523 | Default is ``"backward"`` (normalize by ``1/n``).
|
497 | 524 |
|
| 525 | +Keyword args: |
| 526 | + {out} |
| 527 | +
|
498 | 528 | Example:
|
499 | 529 |
|
500 | 530 | >>> t = torch.rand(10, 9)
|
|
515 | 545 | >>> torch.allclose(roundtrip, t)
|
516 | 546 | True
|
517 | 547 |
|
518 |
| -""") |
| 548 | +""".format(**common_args)) |
519 | 549 |
|
520 | 550 | rfftn = _add_docstr(_fft.fft_rfftn, r"""
|
521 |
| -rfftn(input, s=None, dim=None, norm=None) -> Tensor |
| 551 | +rfftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor |
522 | 552 |
|
523 | 553 | Computes the N-dimensional discrete Fourier transform of real :attr:`input`.
|
524 | 554 |
|
|
552 | 582 |
|
553 | 583 | Default is ``"backward"`` (no normalization).
|
554 | 584 |
|
| 585 | +Keyword args: |
| 586 | + {out} |
| 587 | +
|
555 | 588 | Example:
|
556 | 589 |
|
557 | 590 | >>> t = torch.rand(10, 10)
|
|
573 | 606 | >>> two_ffts = torch.fft.fft(torch.fft.rfft(x, dim=1), dim=0)
|
574 | 607 | >>> torch.allclose(rfftn, two_ffts)
|
575 | 608 |
|
576 |
| -""") |
| 609 | +""".format(**common_args)) |
577 | 610 |
|
578 | 611 | irfftn = _add_docstr(_fft.fft_irfftn, r"""
|
579 |
| -irfftn(input, s=None, dim=None, norm=None) -> Tensor |
| 612 | +irfftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor |
580 | 613 |
|
581 | 614 | Computes the inverse of :func:`~torch.fft.rfftn`.
|
582 | 615 |
|
|
623 | 656 |
|
624 | 657 | Default is ``"backward"`` (normalize by ``1/n``).
|
625 | 658 |
|
| 659 | +Keyword args: |
| 660 | + {out} |
| 661 | +
|
626 | 662 | Example:
|
627 | 663 |
|
628 | 664 | >>> t = torch.rand(10, 9)
|
|
643 | 679 | >>> torch.allclose(roundtrip, t)
|
644 | 680 | True
|
645 | 681 |
|
646 |
| -""") |
| 682 | +""".format(**common_args)) |
647 | 683 |
|
648 | 684 | hfft = _add_docstr(_fft.fft_hfft, r"""
|
649 |
| -hfft(input, n=None, dim=-1, norm=None) -> Tensor |
| 685 | +hfft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
650 | 686 |
|
651 | 687 | Computes the one dimensional discrete Fourier transform of a Hermitian
|
652 | 688 | symmetric :attr:`input` signal.
|
|
697 | 733 |
|
698 | 734 | Default is ``"backward"`` (no normalization).
|
699 | 735 |
|
| 736 | +Keyword args: |
| 737 | + {out} |
| 738 | +
|
700 | 739 | Example:
|
701 | 740 |
|
702 | 741 | Taking a real-valued frequency signal and bringing it into the time domain
|
|
722 | 761 |
|
723 | 762 | >>> torch.fft.hfft(T[:3])
|
724 | 763 | tensor([0.5000, 1.1236, 2.5000, 3.8764])
|
725 |
| -""") |
| 764 | +""".format(**common_args)) |
726 | 765 |
|
727 | 766 | ihfft = _add_docstr(_fft.fft_ihfft, r"""
|
728 |
| -ihfft(input, n=None, dim=-1, norm=None) -> Tensor |
| 767 | +ihfft(input, n=None, dim=-1, norm=None, *, out=None) -> Tensor |
729 | 768 |
|
730 | 769 | Computes the inverse of :func:`~torch.fft.hfft`.
|
731 | 770 |
|
|
754 | 793 |
|
755 | 794 | Default is ``"backward"`` (normalize by ``1/n``).
|
756 | 795 |
|
| 796 | +Keyword args: |
| 797 | + {out} |
| 798 | +
|
757 | 799 | Example:
|
758 | 800 |
|
759 | 801 | >>> t = torch.arange(5)
|
|
767 | 809 | >>> torch.fft.ifft(t)
|
768 | 810 | tensor([ 2.0000+-0.0000j, -0.5000-0.6882j, -0.5000-0.1625j, -0.5000+0.1625j,
|
769 | 811 | -0.5000+0.6882j])
|
770 |
| -""") |
| 812 | +""".format(**common_args)) |
771 | 813 |
|
772 | 814 | fftfreq = _add_docstr(_fft.fft_fftfreq, r"""
|
773 |
| -fftfreq(n, d=1.0, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor |
| 815 | +fftfreq(n, d=1.0, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor |
774 | 816 |
|
775 | 817 | Computes the discrete Fourier Transform sample frequencies for a signal of size :attr:`n`.
|
776 | 818 |
|
|
796 | 838 | spacing gives the result in physical frequency units.
|
797 | 839 |
|
798 | 840 | Keyword Args:
|
| 841 | + {out} |
799 | 842 | {dtype}
|
800 | 843 | {layout}
|
801 | 844 | {device}
|
|
815 | 858 | """.format(**factory_common_args))
|
816 | 859 |
|
817 | 860 | rfftfreq = _add_docstr(_fft.fft_rfftfreq, r"""
|
818 |
| -rfftfreq(n, d=1.0, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor |
| 861 | +rfftfreq(n, d=1.0, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor |
819 | 862 |
|
820 | 863 | Computes the sample frequencies for :func:`~torch.fft.rfft` with a signal of size :attr:`n`.
|
821 | 864 |
|
|
839 | 882 | spacing gives the result in physical frequency units.
|
840 | 883 |
|
841 | 884 | Keyword Args:
|
| 885 | + {out} |
842 | 886 | {dtype}
|
843 | 887 | {layout}
|
844 | 888 | {device}
|
|
0 commit comments