zeshengzong
abb00efc14
Add torch.squeeze parameter description to declare allowed type ( #137485 )
...
Fixes #137422
Add parameter type definition in API docs to clarify allowed value type, eliminate users pass `None` as `dim` value directly.
```python
>>> import torch
>>> x = torch.randn(3,1,2)
>>> x.squeeze(dim=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Please look up dimensions by name, got: name = None.
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137485
Approved by: https://github.com/albanD
2024-10-09 05:29:13 +00:00
Nikita Shulga
4830bd0dd4
[Doc] Clarify that NaNs are not equal to each other ( #137386 )
...
Fixes https://github.com/pytorch/pytorch/issues/137337
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137386
Approved by: https://github.com/janeyx99 , https://github.com/huydhn , https://github.com/kit1980
2024-10-05 06:19:12 +00:00
PyTorch MergeBot
e9d2765ec8
Revert "Add deterministic path for CUDA cumsum ( #136224 )"
...
This reverts commit d1bb8e828f .
Reverted https://github.com/pytorch/pytorch/pull/136224 on behalf of https://github.com/atalman due to Break internal CI ([comment](https://github.com/pytorch/pytorch/pull/136224#issuecomment-2379214226 ))
2024-09-27 12:54:47 +00:00
Kurt Mohler
d1bb8e828f
Add deterministic path for CUDA cumsum ( #136224 )
...
Change `cumsum` to call its decomposition when `use_deterministic_algorithms(True)` and input is CUDA.
Fixes #89492
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136224
Approved by: https://github.com/ezyang , https://github.com/justinchuby
2024-09-26 04:52:05 +00:00
PyTorch MergeBot
e3b89ca124
Revert "Add deterministic path for CUDA cumsum ( #136224 )"
...
This reverts commit b1a02bf708 .
Reverted https://github.com/pytorch/pytorch/pull/136224 on behalf of https://github.com/ezyang due to Failing internall CI ([comment](https://github.com/pytorch/pytorch/pull/136224#issuecomment-2374201626 ))
2024-09-25 14:11:01 +00:00
Kurt Mohler
b1a02bf708
Add deterministic path for CUDA cumsum ( #136224 )
...
Change `cumsum` to call its decomposition when `use_deterministic_algorithms(True)` and input is CUDA.
Fixes #89492
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136224
Approved by: https://github.com/ezyang , https://github.com/justinchuby
2024-09-24 21:34:43 +00:00
enkilee
54fc4f56ff
[Docs fix] fix syntax error in docs :torch.blackman_window ( #136354 )
...
Fixes #ISSUE_NUMBER
https://pytorch.org/docs/stable/generated/torch.blackman_window.html
error at : equal to torch.blackman_window(L + 1, periodic=False)[:-1]).
should delete the last ).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136354
Approved by: https://github.com/soulitzer
2024-09-24 14:00:26 +00:00
PyTorch MergeBot
fd182b90a7
Revert "Add deterministic path for CUDA cumsum ( #136224 )"
...
This reverts commit d45b0151e5 .
Reverted https://github.com/pytorch/pytorch/pull/136224 on behalf of https://github.com/atalman due to Failing internall CI ([comment](https://github.com/pytorch/pytorch/pull/136224#issuecomment-2369244135 ))
2024-09-23 19:57:13 +00:00
Kurt Mohler
d45b0151e5
Add deterministic path for CUDA cumsum ( #136224 )
...
Change `cumsum` to call its decomposition when `use_deterministic_algorithms(True)` and input is CUDA.
Fixes #89492
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136224
Approved by: https://github.com/ezyang , https://github.com/justinchuby
2024-09-20 02:41:56 +00:00
Alexander Jipa
5ca46be15e
Fix/torch cat doc attr ( #135698 )
...
The `torch.cat` attr name for tensors in the docs differs from the method signature, unlike other methods.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/135698
Approved by: https://github.com/albanD
Co-authored-by: Alexander Jipa <azzhipa@amazon.com>
2024-09-11 22:32:55 +00:00
PhilipMay
90e12cf63d
Fix return type of nansum example. ( #135435 )
...
One of the examples in the documentation of `torch.nansum` contains a wrong return type. This fixes it.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/135435
Approved by: https://github.com/ezyang
2024-09-09 03:34:52 +00:00
ooooo
32e052e468
[docs] improve torch.stack example code to be reproducible ( #133857 )
...
Improve the sample code can produce the expected results after copying and executing it.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133857
Approved by: https://github.com/soulitzer
2024-08-21 14:07:02 +00:00
Tobias Ringwald
441c1c03d5
Prevent an unnecessary device -> host copy for CuPy arrays when not explicitly setting a device in torch.as_tensor. ( #132595 )
...
See title. Until now, calling `torch.as_tensor` on a CuPy array would return a CPU tensor, when not providing a device. This is most likely not desired.
Fixes #132553
```python3
import torch
import cupy as cp
cupy_arr = cp.asarray([1, 2, 3])
# Default case
t = torch.as_tensor(cupy_arr)
# New behavior, same device as cupy_arr now, was cpu before
print(t.device) # cuda:0
# Explicitly set device
t = torch.as_tensor(cupy_arr, device='cpu')
print(t.device) # cpu
# Implicit default device
torch.set_default_device('cpu')
t = torch.as_tensor(cupy_arr)
print(t.device) # cpu
# Default device via context manager
torch.set_default_device('cuda')
with torch.device('cpu'):
t = torch.as_tensor(cupy_arr)
print(t.device) # cpu
# Unset default device
torch.set_default_device(None)
t = torch.as_tensor(cupy_arr)
# New behavior, same device as cupy_arr now, was cpu before
print(t.device) # cuda:0
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132595
Approved by: https://github.com/ezyang
2024-08-08 00:26:58 +00:00
Xuehai Pan
4226ed1585
[BE] Format uncategorized Python files with ruff format ( #132576 )
...
Remove patterns `**`, `test/**`, and `torch/**` in `tools/linter/adapters/pyfmt_linter.py` and run `lintrunner`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132576
Approved by: https://github.com/ezyang , https://github.com/Skylion007
ghstack dependencies: #132574
2024-08-04 17:13:31 +00:00
Pearu Peterson
a4ea776881
Add pinned memory support to sparse COO/CSR/CSC/BSR/BSC tensors ( #129645 )
...
As in the title:
To register indices/values of a sparse XYZ tensor with CUDA, the following methods are supported
- `sparse_xyz_tensor(indices, values, pin_memory=True)`
- `sparse_xyz_tensor(indices, values).pin_memory()`
- `sparse_xyz_tensor(indices.pin_memory(), values.pin_memory())`
Fixes https://github.com/pytorch/pytorch/issues/115330
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129645
Approved by: https://github.com/amjames , https://github.com/cpuhrsch , https://github.com/eqy
2024-08-02 08:55:55 +00:00
Aos Dabbagh
9f6d7df3d9
docs(multinomial): Add reference to Multinomial class ( #131904 )
...
This PR just adds the reference to the class
`torch.distributions.multinomial.Multinomial` in `torch.multinomial`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131904
Approved by: https://github.com/jbschlosser
2024-07-30 18:05:07 +00:00
Yu, Guangye
9cae2160f5
Introduce the concept of Accelerators to PyTorch doc ( #129363 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129363
Approved by: https://github.com/EikanWang , https://github.com/gujinghui , https://github.com/albanD
ghstack dependencies: #129463 , #129205
2024-07-15 14:24:46 +00:00
Aaron Orenstein
634b62f111
typing proxy_tensor.py ( #129182 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129182
Approved by: https://github.com/Chillee
2024-07-12 23:17:09 +00:00
Tianyi Tao
1d93367cfa
Fix typo ( #130305 )
...
Fixes #130241
that is a reopen pr of #130244 , for possibly fixing the failed job
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130305
Approved by: https://github.com/Skylion007
2024-07-09 20:02:00 +00:00
Xuehai Pan
735044191f
[Easy] Add whitespace after comma when re-rendering tuple default value in schema ( #129884 )
...
The default value of `rot90()` in the schema registry is `[0,1]` because we split the function schema by `", "`. There should be no space after `,` in `[0,1]`.
5c9d5272e4/aten/src/ATen/native/native_functions.yaml (L6120-L6126)
Then the the default value is formatted to `(0,1)` in `pyi` files. This PR manually adds an extra whitespace when rerendering the default value to a string.
```python
", ".join(string.split(","))
```
```python
# before
def rot90(input: Tensor, k: _int = 1, dims: _size = (0,1)) -> Tensor: ...
# after
def rot90(input: Tensor, k: _int = 1, dims: _size = (0, 1)) -> Tensor: ...
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129884
Approved by: https://github.com/ezyang
2024-07-03 11:45:24 +00:00
Xuehai Pan
75f64e1203
Fix test test_type_hints.py::TestTypeHints::test_doc_examples ( #129829 )
...
As per the title, this test was broken for months.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129829
Approved by: https://github.com/ezyang
2024-07-01 13:28:37 +00:00
Shashank Shekhar
a70a7337d2
Update torch.nanmean() docstring to mention input dtype requirement ( #128155 )
...
Fixes #120570
## Description
Update torch.nanmean() docstring to mention input dtype requirement as either floating point type or complex.
Previously, the torch.mean() docstring had been updated in #120208 in a similar manner, but the torch.nanmean() docstring was not updated.
## Checklist
- [X] The issue that is being fixed is referred in the description.
- [X] Only one issue is addressed in this pull request.
- [x] Labels from the issue that this PR is fixing are added to this pull request.
- [X] No unnecessary issues are included into this pull request.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128155
Approved by: https://github.com/malfet
2024-06-12 17:46:36 +00:00
Aaron Orenstein
afe15d2d2f
Flip default value for mypy disallow_untyped_defs [3/11] ( #127840 )
...
See #127836 for details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127840
Approved by: https://github.com/oulgen
2024-06-08 18:28:01 +00:00
hippocookie
3591bce6c7
Add usage explanation in torch.dot ducment ( #125908 )
...
Fixes #125842
Add unsupported declaration on <code>torch.dot</code>, avoid misused like:
```python
>>> t1, t2 = torch.tensor([0,1]), torch.tensor([2,3])
>>> torch.dot(input=t1, other=t2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: dot() missing 1 required positional arguments: "tensor"
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/125908
Approved by: https://github.com/albanD
2024-05-22 20:33:12 +00:00
Tobias Ringwald
4f1a56cd42
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 20:58:24 +00:00
PyTorch MergeBot
6065a4d46e
Revert "Switched from parameter in can_cast to from_. ( #126030 )"
...
This reverts commit 06d6bb4eba .
Reverted https://github.com/pytorch/pytorch/pull/126030 on behalf of https://github.com/huydhn due to Sorry for reverting your change but i need to revert it to avoid a diff train conflict with https://github.com/pytorch/pytorch/pull/125995 . Please help rebase and I will reland the change ([comment](https://github.com/pytorch/pytorch/pull/126030#issuecomment-2113757469 ))
2024-05-16 01:42:23 +00:00
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