Commit Graph

1031 Commits

Author SHA1 Message Date
bb72bfe2ac Add code example for torch.stack() (#120304)
Fixes #120303

Pull Request resolved: https://github.com/pytorch/pytorch/pull/120304
Approved by: https://github.com/albanD
2024-02-22 18:30:30 +00:00
d336be2942 Update torch.mean() description about dtype restriction. (#120208)
Fixes #120173

Co-authored-by: Jeffrey Wan <soulitzer@gmail.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/120208
Approved by: https://github.com/soulitzer
2024-02-21 18:04:11 +00:00
2d4aa91a10 Fix searchsorted function signature in docs (#120086)
Side should be optional string, to match definition in native_functions: fbe8e0f92d/aten/src/ATen/native/native_functions.yaml (L11246)

Fixes https://github.com/pytorch/pytorch/issues/119999

Test plan: https://docs-preview.pytorch.org/pytorch/pytorch/120086/generated/torch.searchsorted.html#torch-searchsorted

Pull Request resolved: https://github.com/pytorch/pytorch/pull/120086
Approved by: https://github.com/lezcano
2024-02-16 20:00:04 +00:00
0fd371c868 fix torch.cumsum docs (#117944)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117944
Approved by: https://github.com/zou3519
2024-02-13 15:29:06 +00:00
28c30f29be Update documentation for set_flush_denormal support on ARM (#119354)
**Documentation update for set_flush_denormal():**
-> set_flush_denormal() is now supported on ARM CPU's.
-> **PR:** https://github.com/pytorch/pytorch/pull/115184  (Already merged)

**Reference page:** https://pytorch.org/docs/stable/generated/torch.set_flush_denormal.html

Pull Request resolved: https://github.com/pytorch/pytorch/pull/119354
Approved by: https://github.com/drisspg
2024-02-12 20:53:22 +00:00
31f00b0160 Clarify that legacy cat behavior only applies for 1-D tensor (#119684)
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/119684
Approved by: https://github.com/albanD
2024-02-12 18:13:04 +00:00
5f2ad407a9 Fix typo on torch.frombuffer() documentation (#119214)
Fixes #114345

Pull Request resolved: https://github.com/pytorch/pytorch/pull/119214
Approved by: https://github.com/albanD
2024-02-07 00:41:51 +00:00
7bbd9befed Improve example for `torch.mode()` (#115308)
Fixes #89820 and improves the documentation.

Co-authored-by: Sam Gross <colesbury@gmail.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/115308
Approved by: https://github.com/colesbury
2024-02-03 00:13:26 +00:00
8ff55c7e68 Clarified sampling process of torch.randn for complex dtypes. (#118315)
Fixes #118269.

Clarified the docs of `torch.randn` and `torch.randn_like`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/118315
Approved by: https://github.com/lezcano
2024-01-26 13:05:19 +00:00
75818adcf7 Pyi doc inclusion + fix (#117267)
Reland of https://github.com/pytorch/pytorch/pull/114705 with extra fix to smoothly handle when the modules we're trying to load are not available (and thus the pyi won't contain the docs in this case).

Tested locally that it works properly in fbcode.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117267
Approved by: https://github.com/ezyang
2024-01-15 13:06:53 +00:00
767e1b6349 Revert "Bring docstring to .pyi file (#114705)"
This reverts commit 0dd5deecedd136852c7ccc81630eaefbebe5be29.

Reverted https://github.com/pytorch/pytorch/pull/114705 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/114705#issuecomment-1887165326))
2024-01-11 13:30:44 +00:00
0dd5deeced Bring docstring to .pyi file (#114705)
Fixes #37762

Since the original issue hasn't been making progress for more than 3 years, I am attempting to make this PR to at least make some progress forward.

This PR attempts to add docstring to the `.pyi` files. The docstrings are read from [`_torch_docs`](https://github.com/pytorch/pytorch/blob/main/torch/_torch_docs.py) by mocking [`_add_docstr`](9f073ae304/torch/csrc/Module.cpp (L329)), which is the only function used to add docstring.

Luckily, `_torch_docs` has no dependencies for other components of PyTorch, and can be imported without compiling `torch._C` with `_add_docstr` mocked.

The generated `.pyi` file looks something like the following:

[_VariableFunctions.pyi.txt](https://github.com/pytorch/pytorch/files/13494263/_VariableFunctions.pyi.txt)

<img width="787" alt="image" src="https://github.com/pytorch/pytorch/assets/6421097/73c2e884-f06b-4529-8301-0ca0b9de173c">

And the docstring can be picked up by VSCode:

<img width="839" alt="image" src="https://github.com/pytorch/pytorch/assets/6421097/1999dc89-a591-4c7a-80ac-aa3456672af4">

<img width="908" alt="image" src="https://github.com/pytorch/pytorch/assets/6421097/ecf3fa92-9822-4a3d-9263-d224d87ac288">

Pull Request resolved: https://github.com/pytorch/pytorch/pull/114705
Approved by: https://github.com/albanD
2024-01-09 18:37:16 +00:00
43f42bf3cb Updated docs for deprecated torch.set_default_tensor_type (#115041)
Added deprecation note for torch.set_default_tensor_type. Updated docs that referenced this method.

Fixes #113646.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/115041
Approved by: https://github.com/janeyx99
2023-12-07 16:17:36 +00:00
c678c5ef38 [doc] caution torch.multinomial usage (#112892)
Fixes #107406

Pull Request resolved: https://github.com/pytorch/pytorch/pull/112892
Approved by: https://github.com/albanD
2023-11-15 18:20:48 +00:00
fd209543d5 Add torch.utils.deterministic.fill_uninitialized_memory flag (#111377)
Part of #109802

Pull Request resolved: https://github.com/pytorch/pytorch/pull/111377
Approved by: https://github.com/albanD, https://github.com/aaronenyeshi
2023-11-01 16:10:09 +00:00
ace2713d1e Revert "Add torch.utils.deterministic.fill_uninitialized_memory flag (#111377)"
This reverts commit f1785373c08b9e8383b7eec3391d57053209b525.

Reverted https://github.com/pytorch/pytorch/pull/111377 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/111377#issuecomment-1784179040))
2023-10-29 17:41:55 +00:00
f1785373c0 Add torch.utils.deterministic.fill_uninitialized_memory flag (#111377)
Part of #109802

Pull Request resolved: https://github.com/pytorch/pytorch/pull/111377
Approved by: https://github.com/albanD
2023-10-26 02:39:06 +00:00
b54ab57522 Document torch.from_file and fix UntypedStorage.from_file docs (#111688)
Fixes https://github.com/pytorch/pytorch/issues/37439

Also threads through filename so it is accessible via `t.storage().filename`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/111688
Approved by: https://github.com/albanD
2023-10-25 19:28:11 +00:00
46e80ce58a [ATen] Support multi dim any and all reductions (#110310)
This adds a new overload to `all` and `any` with support for multiple reduction dims.
```
all.dims(Tensor self, int[1]? dim=None, bool keepdim=False) -> Tensor
any.dims(Tensor self, int[1]? dim=None, bool keepdim=False) -> Tensor
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110310
Approved by: https://github.com/lezcano, https://github.com/albanD, https://github.com/justinchuby
2023-10-24 21:33:53 +00:00
93e5065ba0 [CODEMOD][caffe2] replace numpy.bool with bool (#111432)
Test Plan:
numpy.bool is long deprecated and removed starting numpy-1.20.0 [1]. This replaces all references with equivalent `bool` type using the following oneliner:
```
rg -l 'np\.bool' caffe2 | grep '\.py$' | xargs perl -pi -e 's,\bnp\.bool\b,bool,'
```
1. https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Differential Revision: D50372711

Pull Request resolved: https://github.com/pytorch/pytorch/pull/111432
Approved by: https://github.com/Skylion007
2023-10-18 18:56:40 +00:00
d8de45d22c Update arg{min,max} tests and docs (#110845)
The `argmin` docs had been updated in
https://github.com/pytorch/pytorch/issues/78791 but left a minor typo.

`argmax` had a similar issue but was not noticed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110845
Approved by: https://github.com/eellison
2023-10-13 21:40:29 +00:00
9f0601df6d Fix a typo in cholesky_inverse documentation (#110364)
Very small PR to fix a typo in [https://pytorch.org/docs/stable/generated/torch.cholesky_inverse.html](cholesky_inverse) doc.

According to the current doc, the function expects $A$, the symmetric positive-definite matrix, as input. But the examples given (and more important, the code) is using $u$ the cholesky decomposition of this matrix (like cholesky_solve).

Also, it provides a correct example of batch usage of this function.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/110364
Approved by: https://github.com/lezcano
2023-10-04 12:30:11 +00:00
7b53303d3c Improved the docs for torch.std, torch.var, torch.std_mean, torch.var_mean and torch.cov (#109326)
Fixes #109186.

This PR updates the docs for
- `torch.var`
- `torch.var_mean`
- `torch.std`
- `torch.std_mean`
- `torch.cov`

to reflect the actual implementation behavior when `correction >= N`. The math for `torch.cov` should probably be double checked before merging.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109326
Approved by: https://github.com/albanD
2023-09-19 20:47:24 +00:00
2f53bca0fc [Docs] Fix typo in torch.unflatten (#109588)
Fixes https://github.com/pytorch/pytorch/issues/109559

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109588
Approved by: https://github.com/lezcano
2023-09-19 10:37:45 +00:00
a6d34c60a1 Fixing searchsorted doc (#109364)
Removing ambiguous description

Fixes #109298

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109364
Approved by: https://github.com/colesbury
2023-09-18 23:12:53 +00:00
c382ad47dd Deprecate torch.cross default behaviour (#108760)
Long overdue this one. We may be able to change it in a few years :hopeful:.

**BC-breaking note**

This PR deprecates `torch.cross`'s default dim in favor of
`torch.linalg.cross`.
A upgrade guide is added to the documentation for `torch.cross`.

Note this PR DOES NOT remove `torch.cross`.

Fixes https://github.com/pytorch/pytorch/issues/108664

Pull Request resolved: https://github.com/pytorch/pytorch/pull/108760
Approved by: https://github.com/albanD
2023-09-14 19:36:29 +00:00
61f0578787 Update take_along_dim docs to include dim=None case (#109120)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/109120
Approved by: https://github.com/lezcano
ghstack dependencies: #108879, #108880
2023-09-13 23:13:09 +00:00
b2cba439b4 Introduce Tensor overload to linspace and logspace (#104889)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/104889
Approved by: https://github.com/zou3519
ghstack dependencies: #107958
2023-09-11 23:30:40 +00:00
03fd3544a2 fixed lgamma documentation error (#108719)
Fixes #108527

Pull Request resolved: https://github.com/pytorch/pytorch/pull/108719
Approved by: https://github.com/zou3519
2023-09-11 22:29:06 +00:00
a7f5abeade Revert "Introduce Tensor overload to linspace and logspace (#104889)"
This reverts commit 57e52393213b6b4fba3b334654b96396a2904087.

Reverted https://github.com/pytorch/pytorch/pull/104889 on behalf of https://github.com/clee2000 due to sorry have to revert this to revert https://github.com/pytorch/pytorch/pull/107958 ([comment](https://github.com/pytorch/pytorch/pull/104889#issuecomment-1714305768))
2023-09-11 17:33:48 +00:00
57e5239321 Introduce Tensor overload to linspace and logspace (#104889)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/104889
Approved by: https://github.com/zou3519
ghstack dependencies: #107958
2023-09-11 15:29:39 +00:00
e5e653a660 Revert "docs: Match open bracket with close bracket in unsqueeze (#95215)"
This reverts commit 9d04d376d81be2f01e5ea6b68943390346f2494c.

Reverted https://github.com/pytorch/pytorch/pull/95215 on behalf of https://github.com/kit1980 due to Incorrect assumptions ([comment](https://github.com/pytorch/pytorch/pull/95215#issuecomment-1708852420))
2023-09-06 18:04:10 +00:00
fe3309b4b8 Add optional is_coalesced argument to sparse coo tensor factory function. (#107638)
Resolves https://github.com/pytorch/pytorch/issues/107097

After this PR, instead of
```python
torch.sparse_coo_tensor(indices, values, size)._coalesced_(is_coalesced)
```
(that does not work in the autograd context, see #107097), use
```python
torch.sparse_coo_tensor(indices, values, size, is_coalesced=is_coalesced)
```

All sparse coo factory functions that take indices as input support the `is_coalesced` argument.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/107638
Approved by: https://github.com/cpuhrsch
2023-08-26 07:24:29 +00:00
e00bd83124 Fix the example of torch.slice_scatter (#107849)
Fixes #107681
fix the example of torch.slice_scatter
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107849
Approved by: https://github.com/drisspg
2023-08-25 04:19:49 +00:00
8a7a6867b9 [PyTorch][Tensor] Introduce tensor.dim_order (#106835)
Summary:
This is a stride based attribute for a tensor available in Python.

This can help inspect tensors generated using `torch.empty_permuted(.., physical_layout, ...)`, where physical_layout should match the dim_order returned here. `empty_permuted` will be renamed to use dim_order as the param name in the future. And also help Executorch export pipeline with implementing dim_order based tensors.

Differential Revision: D48134476

Pull Request resolved: https://github.com/pytorch/pytorch/pull/106835
Approved by: https://github.com/ezyang
2023-08-25 00:06:03 +00:00
e9af315e02 Fix torch.bucketize docs for "right" (#104474)
The docs correctly (i.e matching actual op behavior) state that

`right = False` means `boundaries[i-1] < input[m][n]...[l][x] <= boundaries[i]`.

However they previously stated that
`If 'right' is False (default), then the left boundary is closed.`

which contradicts the `boundaries[i-1] < input[m][n]...[l][x] <= boundaries[i]` statement.

This modifies the docs to say `... then the left boundary is OPEN.` and also clarifies that this is the opposite behavior of numpy.digitize.

Fixes #91580
Pull Request resolved: https://github.com/pytorch/pytorch/pull/104474
Approved by: https://github.com/aakhundov, https://github.com/svekars
2023-08-17 03:08:07 +00:00
a5d841ef01 asarray: take the default device into consideration. (#106779)
Fix: #106773

This PR makes it so `asarray` takes the default device into consideration when called with
a Python sequence as the data.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/106779
Approved by: https://github.com/rgommers, https://github.com/lezcano
2023-08-11 13:16:42 +00:00
f725e6374d doc: fix fake quantize per channel doc (#105955)
another doc bug for fake_quantize_per_channel

function doc now matches e7142700ed/aten/src/ATen/native/quantized/FakeQuantPerChannelAffine.cpp (L32)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105955
Approved by: https://github.com/kit1980
2023-07-26 19:17:41 +00:00
6d43c89f37 [BE]: Update Ruff to 0.0.280 (#105724)
Removes unusued loop values in python dictionary iteration. Automated fix from Ruff master

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105724
Approved by: https://github.com/ezyang, https://github.com/janeyx99
2023-07-22 23:03:34 +00:00
7b211ff8dd doc: fix fake_quantize_per_channel_affine (#105241)
Fixes #105085

Fix in formula

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105241
Approved by: https://github.com/jcaip
2023-07-22 00:49:28 +00:00
79c5e33349 [BE] Enable ruff's UP rules and autoformat nn/ mps/ and torch/ (#105436)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105436
Approved by: https://github.com/malfet, https://github.com/albanD
2023-07-21 07:38:46 +00:00
64c39ece65 Fix a docstring of resolve_neg (#104151)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/104151
Approved by: https://github.com/malfet
2023-07-19 03:55:20 +00:00
b88b742db8 fixed torch.manual_seed note (#105175)
Fixes https://github.com/pytorch/pytorch/issues/87509

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105175
Approved by: https://github.com/ezyang
2023-07-13 23:43:44 +00:00
f987d11fa7 Reland: Make torch.empty* deterministic by filling with NaN or max int (#104995)
Relands #101849 after #104302 reverted it.

torchrec PR https://github.com/pytorch/torchrec/pull/1269 fixes the torchrec failure that caused #101849 to be reverted

Part of #82004

Pull Request resolved: https://github.com/pytorch/pytorch/pull/104995
Approved by: https://github.com/albanD
2023-07-13 22:18:03 +00:00
3ff111a4b4 doc: fix fake_quantize_per_tensor_affine docs (#104453)
Fixes #82800

Fixes wrong `fake_quantize_per_tensor_affine` example and wrong `fake_quantize_per_tensor_affine` formula

Pull Request resolved: https://github.com/pytorch/pytorch/pull/104453
Approved by: https://github.com/kit1980
2023-06-30 22:59:00 +00:00
a78bddac01 Revert D46920584: Multisect successfully blamed D46920584 for test or build failures (#104269) (#104302)
Summary:

This diff is reverting D46920584
D46920584: Make `torch.empty*` deterministic by filling with NaN or max int value (#101849) by generatedunixname499836121 has been identified to be causing the following test or build failures:

Tests affected:
- [torchrec/distributed/composable/tests:test_fsdp - torchrec.distributed.composable.tests.test_fsdp.FullyShardTest: test_composable_checkpoint](https://www.internalfb.com/intern/test/281475062923125/)

Here's the Multisect link:
https://www.internalfb.com/multisect/2341386
Here are the tasks that are relevant to this breakage:

We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it.

If you believe this diff has been generated in error you may Commandeer and Abandon it.

Test Plan: NA

Reviewed By: huydhn, osalpekar

Differential Revision: D46997394

Pull Request resolved: https://github.com/pytorch/pytorch/pull/104302
Approved by: https://github.com/osalpekar
2023-06-29 20:20:58 +00:00
a6b9a61a6a Added a note to torch.round doc to indicate the return type (#97227)
Added a note to torch.round doc to indicate the return type of output tensor

Fixes #89056

Pull Request resolved: https://github.com/pytorch/pytorch/pull/97227
Approved by: https://github.com/albanD
2023-06-29 20:02:59 +00:00
2642f31e4c Make torch.empty* deterministic by filling with NaN or max int value (#101849)
Part of #82004

Pull Request resolved: https://github.com/pytorch/pytorch/pull/101849
Approved by: https://github.com/lezcano, https://github.com/albanD, https://github.com/kulinseth
2023-06-21 02:53:22 +00:00
d52d1fd5ba add description for unexpected case (#103500)
Fixes #88547

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103500
Approved by: https://github.com/mingfeima, https://github.com/mikaylagawarecki
2023-06-20 19:02:45 +00:00
e82616d900 Add generator argument in torch.randn signature (#102075)
Fix the document issue of `torch.randn`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/102075
Approved by: https://github.com/kit1980, https://github.com/soulitzer
2023-06-14 23:37:19 +00:00