Skip to content

Commit 710288e

Browse files
peterbell10facebook-github-bot
authored andcommitted
torch.fft: Document out argument (pytorch#56732)
Summary: An oversight from pytorch#49335, the documentation was never updated to include `out` arguments. Pull Request resolved: pytorch#56732 Reviewed By: ezyang Differential Revision: D27960478 Pulled By: mruberry fbshipit-source-id: a342a4f590369d6d2e17bed014fa64e49ee72936
1 parent 6e5ce56 commit 710288e

File tree

1 file changed

+75
-31
lines changed

1 file changed

+75
-31
lines changed

torch/fft/__init__.py

Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import torch
44
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
66

77
__all__ = ['fft', 'ifft', 'fft2', 'ifft2', 'fftn', 'ifftn',
88
'rfft', 'irfft', 'rfft2', 'irfft2', 'rfftn', 'irfftn',
@@ -15,7 +15,7 @@
1515
# connects the torch.fft Python namespace to the torch._C._fft builtins.
1616

1717
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
1919
2020
Computes the one dimensional discrete Fourier transform of :attr:`input`.
2121
@@ -47,6 +47,9 @@
4747
4848
Default is ``"backward"`` (no normalization).
4949
50+
Keyword args:
51+
{out}
52+
5053
Example:
5154
5255
>>> t = torch.arange(4)
@@ -58,10 +61,10 @@
5861
>>> t = tensor([0.+1.j, 2.+3.j, 4.+5.j, 6.+7.j])
5962
>>> torch.fft.fft(t)
6063
tensor([12.+16.j, -8.+0.j, -4.-4.j, 0.-8.j])
61-
""")
64+
""".format(**common_args))
6265

6366
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
6568
6669
Computes the one dimensional inverse discrete Fourier transform of :attr:`input`.
6770
@@ -84,15 +87,18 @@
8487
8588
Default is ``"backward"`` (normalize by ``1/n``).
8689
90+
Keyword args:
91+
{out}
92+
8793
Example:
8894
8995
>>> t = torch.tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
9096
>>> torch.fft.ifft(t)
9197
tensor([0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j])
92-
""")
98+
""".format(**common_args))
9399

94100
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
96102
97103
Computes the 2 dimensional discrete Fourier transform of :attr:`input`.
98104
Equivalent to :func:`~torch.fft.fftn` but FFTs only the last two dimensions by default.
@@ -129,6 +135,9 @@
129135
130136
Default is ``"backward"`` (no normalization).
131137
138+
Keyword args:
139+
{out}
140+
132141
Example:
133142
134143
>>> x = torch.rand(10, 10, dtype=torch.complex64)
@@ -140,10 +149,10 @@
140149
>>> two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
141150
>>> torch.allclose(fft2, two_ffts)
142151
143-
""")
152+
""".format(**common_args))
144153

145154
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
147156
148157
Computes the 2 dimensional inverse discrete Fourier transform of :attr:`input`.
149158
Equivalent to :func:`~torch.fft.ifftn` but IFFTs only the last two dimensions by default.
@@ -172,6 +181,9 @@
172181
173182
Default is ``"backward"`` (normalize by ``1/n``).
174183
184+
Keyword args:
185+
{out}
186+
175187
Example:
176188
177189
>>> x = torch.rand(10, 10, dtype=torch.complex64)
@@ -183,10 +195,10 @@
183195
>>> two_iffts = torch.fft.ifft(torch.fft.ifft(x, dim=0), dim=1)
184196
>>> torch.allclose(ifft2, two_iffts)
185197
186-
""")
198+
""".format(**common_args))
187199

188200
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
190202
191203
Computes the N dimensional discrete Fourier transform of :attr:`input`.
192204
@@ -223,6 +235,9 @@
223235
224236
Default is ``"backward"`` (no normalization).
225237
238+
Keyword args:
239+
{out}
240+
226241
Example:
227242
228243
>>> x = torch.rand(10, 10, dtype=torch.complex64)
@@ -234,10 +249,10 @@
234249
>>> two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
235250
>>> torch.allclose(fftn, two_ffts)
236251
237-
""")
252+
""".format(**common_args))
238253

239254
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
241256
242257
Computes the N dimensional inverse discrete Fourier transform of :attr:`input`.
243258
@@ -265,6 +280,9 @@
265280
266281
Default is ``"backward"`` (normalize by ``1/n``).
267282
283+
Keyword args:
284+
{out}
285+
268286
Example:
269287
270288
>>> x = torch.rand(10, 10, dtype=torch.complex64)
@@ -276,10 +294,10 @@
276294
>>> two_iffts = torch.fft.ifft(torch.fft.ifft(x, dim=0), dim=1)
277295
>>> torch.allclose(ifftn, two_iffts)
278296
279-
""")
297+
""".format(**common_args))
280298

281299
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
283301
284302
Computes the one dimensional Fourier transform of real-valued :attr:`input`.
285303
@@ -306,6 +324,9 @@
306324
307325
Default is ``"backward"`` (no normalization).
308326
327+
Keyword args:
328+
{out}
329+
309330
Example:
310331
311332
>>> t = torch.arange(4)
@@ -322,10 +343,10 @@
322343
Notice that the symmetric element ``T[-1] == T[1].conj()`` is omitted.
323344
At the Nyquist frequency ``T[-2] == T[2]`` is it's own symmetric pair,
324345
and therefore must always be real-valued.
325-
""")
346+
""".format(**common_args))
326347

327348
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
329350
330351
Computes the inverse of :func:`~torch.fft.rfft`.
331352
@@ -367,6 +388,9 @@
367388
368389
Default is ``"backward"`` (normalize by ``1/n``).
369390
391+
Keyword args:
392+
{out}
393+
370394
Example:
371395
372396
>>> t = torch.arange(5)
@@ -386,10 +410,10 @@
386410
387411
>>> torch.fft.irfft(T, t.numel())
388412
tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000])
389-
""")
413+
""".format(**common_args))
390414

391415
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
393417
394418
Computes the 2-dimensional discrete Fourier transform of real :attr:`input`.
395419
Equivalent to :func:`~torch.fft.rfftn` but FFTs only the last two dimensions by default.
@@ -423,6 +447,9 @@
423447
424448
Default is ``"backward"`` (no normalization).
425449
450+
Keyword args:
451+
{out}
452+
426453
Example:
427454
428455
>>> t = torch.rand(10, 10)
@@ -444,10 +471,10 @@
444471
>>> two_ffts = torch.fft.fft(torch.fft.rfft(x, dim=1), dim=0)
445472
>>> torch.allclose(rfft2, two_ffts)
446473
447-
""")
474+
""".format(**common_args))
448475

449476
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
451478
452479
Computes the inverse of :func:`~torch.fft.rfft2`.
453480
Equivalent to :func:`~torch.fft.irfftn` but IFFTs only the last two dimensions by default.
@@ -495,6 +522,9 @@
495522
496523
Default is ``"backward"`` (normalize by ``1/n``).
497524
525+
Keyword args:
526+
{out}
527+
498528
Example:
499529
500530
>>> t = torch.rand(10, 9)
@@ -515,10 +545,10 @@
515545
>>> torch.allclose(roundtrip, t)
516546
True
517547
518-
""")
548+
""".format(**common_args))
519549

520550
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
522552
523553
Computes the N-dimensional discrete Fourier transform of real :attr:`input`.
524554
@@ -552,6 +582,9 @@
552582
553583
Default is ``"backward"`` (no normalization).
554584
585+
Keyword args:
586+
{out}
587+
555588
Example:
556589
557590
>>> t = torch.rand(10, 10)
@@ -573,10 +606,10 @@
573606
>>> two_ffts = torch.fft.fft(torch.fft.rfft(x, dim=1), dim=0)
574607
>>> torch.allclose(rfftn, two_ffts)
575608
576-
""")
609+
""".format(**common_args))
577610

578611
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
580613
581614
Computes the inverse of :func:`~torch.fft.rfftn`.
582615
@@ -623,6 +656,9 @@
623656
624657
Default is ``"backward"`` (normalize by ``1/n``).
625658
659+
Keyword args:
660+
{out}
661+
626662
Example:
627663
628664
>>> t = torch.rand(10, 9)
@@ -643,10 +679,10 @@
643679
>>> torch.allclose(roundtrip, t)
644680
True
645681
646-
""")
682+
""".format(**common_args))
647683

648684
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
650686
651687
Computes the one dimensional discrete Fourier transform of a Hermitian
652688
symmetric :attr:`input` signal.
@@ -697,6 +733,9 @@
697733
698734
Default is ``"backward"`` (no normalization).
699735
736+
Keyword args:
737+
{out}
738+
700739
Example:
701740
702741
Taking a real-valued frequency signal and bringing it into the time domain
@@ -722,10 +761,10 @@
722761
723762
>>> torch.fft.hfft(T[:3])
724763
tensor([0.5000, 1.1236, 2.5000, 3.8764])
725-
""")
764+
""".format(**common_args))
726765

727766
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
729768
730769
Computes the inverse of :func:`~torch.fft.hfft`.
731770
@@ -754,6 +793,9 @@
754793
755794
Default is ``"backward"`` (normalize by ``1/n``).
756795
796+
Keyword args:
797+
{out}
798+
757799
Example:
758800
759801
>>> t = torch.arange(5)
@@ -767,10 +809,10 @@
767809
>>> torch.fft.ifft(t)
768810
tensor([ 2.0000+-0.0000j, -0.5000-0.6882j, -0.5000-0.1625j, -0.5000+0.1625j,
769811
-0.5000+0.6882j])
770-
""")
812+
""".format(**common_args))
771813

772814
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
774816
775817
Computes the discrete Fourier Transform sample frequencies for a signal of size :attr:`n`.
776818
@@ -796,6 +838,7 @@
796838
spacing gives the result in physical frequency units.
797839
798840
Keyword Args:
841+
{out}
799842
{dtype}
800843
{layout}
801844
{device}
@@ -815,7 +858,7 @@
815858
""".format(**factory_common_args))
816859

817860
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
819862
820863
Computes the sample frequencies for :func:`~torch.fft.rfft` with a signal of size :attr:`n`.
821864
@@ -839,6 +882,7 @@
839882
spacing gives the result in physical frequency units.
840883
841884
Keyword Args:
885+
{out}
842886
{dtype}
843887
{layout}
844888
{device}

0 commit comments

Comments
 (0)