Commit Graph

941 Commits

Author SHA1 Message Date
Tobias Ringwald
06d6bb4eba Switched from parameter in can_cast to from_. (#126030)
Fixes #126012.

`from` is a reserved keyword in Python, thus we can't make the C++ impl available with `from` as function parameter. This PR changes the name to `from_` and also adjusts the docs.

If we want to preserve backwards compatibility, we can leave the C++ name as-is and only fix the docs. However, `torch.can_cast(from_=torch.int, to=torch.int)` won't work then.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126030
Approved by: https://github.com/albanD
2024-05-16 00:09:54 +00:00
Tom Ritchford
4d8fa7df40 Fix four misspellings of "its" in documentation (#125681)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/125681
Approved by: https://github.com/Skylion007, https://github.com/svekars
2024-05-13 18:14:09 +00:00
Apurva
c0c2f6156a Updated docs to add the error case for torch.multinomial Issue#125388 (#125495)
Summary: Updated docs to add the error condition for torch.multinomial

Test Plan: No change in code

Reviewers: @drisspg

Subscribers: @drisspg

Tasks:

Tags:

Fixes #125388

Pull Request resolved: https://github.com/pytorch/pytorch/pull/125495
Approved by: https://github.com/drisspg
2024-05-07 00:26:27 +00:00
Aaron Orenstein
a8574a9719 Fix global flake8 issues (#124771)
Prior to this `lintrunner --all-files --take FLAKE8` failed.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124771
Approved by: https://github.com/Skylion007
ghstack dependencies: #124428
2024-04-26 15:35:53 +00:00
PyTorch MergeBot
1ac60484c1 Revert "Fix global flake8 issues (#124771)"
This reverts commit f01275934b.

Reverted https://github.com/pytorch/pytorch/pull/124771 on behalf of https://github.com/jeanschmidt due to Unfortunately, I needed to revert #123735 and this one depends on it. So please check if there are no merge conflicts or breakages and feel free to merge this PR again ([comment](https://github.com/pytorch/pytorch/pull/124428#issuecomment-2078699836))
2024-04-26 06:15:17 +00:00
Aaron Orenstein
f01275934b Fix global flake8 issues (#124771)
Prior to this `lintrunner --all-files --take FLAKE8` failed.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124771
Approved by: https://github.com/Skylion007
ghstack dependencies: #124428
2024-04-25 14:25:00 +00:00
Frank Lin
249e65b92d Graph-Safe RNG State Exchange for Tensor Parallelism (#114068)
See #113541

The PR allows for registering and controlling multiple RNG states using indices, ensuring cudagraph-safe operations, and includes both C++ and Python API changes to support this functionality.

cc  @eellison @anijain2305 @jansel @ezyang @ptrblck @csarofeen @mcarilli
Pull Request resolved: https://github.com/pytorch/pytorch/pull/114068
Approved by: https://github.com/ezyang, https://github.com/eqy, https://github.com/xuzhao9
2024-03-27 01:14:38 +00:00
PyTorch MergeBot
4dc09d6aa4 Revert "Graph-Safe RNG State Exchange for Tensor Parallelism (#114068)"
This reverts commit e9dcda5cba.

Reverted https://github.com/pytorch/pytorch/pull/114068 on behalf of https://github.com/ezyang due to memory leak in another ci ([comment](https://github.com/pytorch/pytorch/pull/114068#issuecomment-2018044527))
2024-03-25 13:49:04 +00:00
Frank Lin
e9dcda5cba Graph-Safe RNG State Exchange for Tensor Parallelism (#114068)
See #113541

The PR allows for registering and controlling multiple RNG states using indices, ensuring cudagraph-safe operations, and includes both C++ and Python API changes to support this functionality.

cc  @eellison @anijain2305 @jansel @ezyang @ptrblck @csarofeen @mcarilli
Pull Request resolved: https://github.com/pytorch/pytorch/pull/114068
Approved by: https://github.com/ezyang
2024-03-21 01:57:08 +00:00
lancerts
680cfec295 Fix the default value of side in torch.searchsorted (#120066)
Fixes #119999, currently the [doc](https://pytorch.org/docs/stable/generated/torch.searchsorted.html#torch.searchsorted) shows the default value of `side = "left"`
<img width="600" alt="Screenshot 2024-02-16 at 10 36 08 AM" src="https://github.com/pytorch/pytorch/assets/7495155/e7d159aa-4985-4f50-9d81-6e71c3116c0d">
while the [implementation ](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml#L11247) gives the default value of `side = c10::nullopt`.

- fix the [torch doc](https://github.com/pytorch/pytorch/blob/main/torch/_torch_docs.py#L13782) such that the default value of side is None.

- fix the [comment in cpp](4dc75f9084/aten/src/ATen/native/Bucketization.cpp (L19)) such that the default value of side is None.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/120066
Approved by: https://github.com/malfet
2024-02-22 19:35:17 +00:00
Andrei
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
rajibm
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
Nikita Shulga
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
jeejeeli
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
maajidkhann
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
Edward Z. Yang
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
Mateus Devino
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
Linus
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
Tobias Ringwald
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
albanD
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
PyTorch MergeBot
767e1b6349 Revert "Bring docstring to .pyi file (#114705)"
This reverts commit 0dd5deeced.

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
Shawn Zhong
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
Tobias Ringwald
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
min-jean-cho
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
Kurt Mohler
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
PyTorch MergeBot
ace2713d1e Revert "Add torch.utils.deterministic.fill_uninitialized_memory flag (#111377)"
This reverts commit f1785373c0.

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
Kurt Mohler
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
Mikayla Gawarecki
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
Peter Bell
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
Igor Sugak
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
Jez Ng
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
Raphael Reme
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
Tobias Ringwald
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
Nikita Shulga
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
Andrea D'Eusanio
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
lezcano
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
Guilherme Leobas
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
Li-Huai (Allan) Lin
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
igm503
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
PyTorch MergeBot
a7f5abeade Revert "Introduce Tensor overload to linspace and logspace (#104889)"
This reverts commit 57e5239321.

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
Li-Huai (Allan) Lin
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
PyTorch MergeBot
e5e653a660 Revert "docs: Match open bracket with close bracket in unsqueeze (#95215)"
This reverts commit 9d04d376d8.

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
Pearu Peterson
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
FFFrog
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
Digant Desai
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
David Berard
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
Yukio Siraichi
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
Oren Leung
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
Aaron Gokaslan
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
Shreyas Bhat Kera
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