Kazuaki Ishizaki
50ed38a7eb
Fix typo under docs directory ( #97202 )
...
This PR fixes typo in `.rst` files under docs directory.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97202
Approved by: https://github.com/kit1980
2023-03-21 01:24:10 +00:00
Xuehai Pan
8d45f555d7
[BE] [1/3] Rewrite super() calls in caffe2 and benchmarks ( #94587 )
...
Rewrite Python built-in class `super()` calls. Only non-semantic changes should be applied.
- #94587
- #94588
- #94592
Also, methods with only a `super()` call are removed:
```diff
class MyModule(nn.Module):
- def __init__(self):
- super().__init__()
-
def forward(self, ...):
...
```
Some cases that change the semantics should be kept unchanged. E.g.:
f152a79be9/caffe2/python/net_printer.py (L184-L190)
f152a79be9/test/test_jit_fuser_te.py (L2628-L2635)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94587
Approved by: https://github.com/ezyang
2023-02-11 18:19:48 +00:00
Ivan Kobzarev
2fc73622f8
[jit] Support Awaitable type ( #90863 )
...
We want to make TorchRec sharded models TorchScriptable.
TorchRec sharded models uses generic types Awaitable[W] and LazyAwaitable[W] (https://github.com/pytorch/torchrec/blob/main/torchrec/distributed/types.py#L212 ).
In sharded model those types are used instead of contained type W, having the initialization function that produces object of type W.
At the moment when the first attribute of W is requested - `LazyAwaitable[W]` will call its initialization function (on the same stack), cache the result inside and work transparently as an object of W. So we can think about it as a delayed object initialization.
To support this behavior in TorchScript - we propose a new type to TorchScript - `Await`.
In eager mode it works the same as `LazyAwaitable[W]` in TorchRec, being dynamically typed - acting as a type `W` while it is `Await[W]`.
Within torchscript it is `Await[W]` and can be only explicitly converted to W, using special function `torch.jit.awaitable_wait(aw)`.
Creation of this `Await[W]` is done via another special function `torch.jit.awaitable(func, *args)`.
The semantic is close to `torch.jit.Future`, fork, wait and uses the same jit mechanics (inline fork Closures) with the difference that it does not start this function in parallel on fork. It only stores as a lambda inside IValue that will be called on the same thread when `torch.jit.awaitable_wait` is called.
For example (more examples in this PR `test/jit/test_await.py`)
```
def delayed(z: Tensor) -> Tensor:
return Tensor * 3
@torch.jit.script
def fn(x: Tensor):
aw: Await[int] = torch.jit._awaitable(delayed, 99)
a = torch.eye(2)
b = torch.jit._awaitable_wait(aw)
return a + b + x
```
Functions semantics:
`_awaitable(func -> Callable[Tuple[...], W], *args, **kwargs) -> Await[W]`
Creates Await object, owns args and kwargs. Once _awaitable_wait calls, executes function func and owns the result of the function. Following _awaitable_wait calls will return this result from the first function call.
`_awaitable_wait(Await[W]) -> W`
Returns either cached result of W if it is not the first _awaitable_wait call to this Await object or calls specified function if the first.
`_awaitable_nowait(W) -> Await[W]`
Creates trivial Await[W] wrapper on specified object To be type complaint for the corner cases.
Differential Revision: [D42502706](https://our.internmc.facebook.com/intern/diff/D42502706 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90863
Approved by: https://github.com/davidberard98
2023-01-30 17:38:59 +00:00
Kazuaki Ishizaki
d40a4540d6
Fix typo under docs directory ( #92762 )
...
This PR fixes typo and URL (`http -> https`) in `rst` files under `docs` directory
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92762
Approved by: https://github.com/H-Huang
2023-01-23 18:07:22 +00:00
apeltop
e7635c06ce
Fix typos in docs ( #80602 )
...
I hope it helps.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80602
Approved by: https://github.com/kit1980
2022-08-29 23:32:44 +00:00
gmagogsfm
358e908162
Add Union type to TorchScript Language Ref ( #69514 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69514
Reviewed By: tugsbayasgalan
Differential Revision: D32909371
Pulled By: gmagogsfm
fbshipit-source-id: af1c3040cd59ee913dc576cf8a8c759313f1e07f
2021-12-07 12:53:54 -08:00
Vansh Sharma
ff125a3624
Minor changes in documentation ( #68557 )
...
Summary:
Fixed some small typos
Pull Request resolved: https://github.com/pytorch/pytorch/pull/68557
Reviewed By: mruberry
Differential Revision: D32538749
Pulled By: ngimel
fbshipit-source-id: 09a9cd4031463b6a40d7307bd8fcb7d364444ac3
2021-11-18 17:57:16 -08:00
Kenichi Maehashi
6ed68f3f84
Document torch.jit.is_tracing() ( #67326 )
...
Summary:
This PR adds `torch.jit.is_tracing()` to the JIT API reference.
This function is widely used but left undocumented: https://github.com/search?q=torch.jit.is_tracing&type=code
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67326
Reviewed By: tugsbayasgalan
Differential Revision: D31985251
Pulled By: Krovatkin
fbshipit-source-id: 852b432b08d63df8bd7a7a02c9555e61f5f37978
2021-10-28 09:56:09 -07:00
nikithamalgi
bf053a1296
Fix hasattr support type ( #57950 )
...
Summary:
`hasattr` is partially supported. This PR fixes that in the builtin table.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57950
Reviewed By: pbelevich
Differential Revision: D28329005
Pulled By: nikithamalgifb
fbshipit-source-id: c4cfba9badcc8f7cbc8250a5c21dfb62b35a83fc
2021-05-10 12:21:56 -07:00
Holly Sweeney
626ae7f036
Copy edit of TorchScript Language Reference ( #57694 )
...
Summary:
Initial copy edit of the file.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57694
Reviewed By: malfet, ngimel
Differential Revision: D28289209
Pulled By: holly1238
fbshipit-source-id: 7035d6790767a2f758e6019ae63df16537ef2725
2021-05-07 12:17:32 -07:00
Yanan Cao
2aadeac0ff
Remove duplicate entry for filter in language ref v2 ( #57154 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/57154
Reviewed By: zou3519
Differential Revision: D28061690
Pulled By: gmagogsfm
fbshipit-source-id: b895238c0425cc6b60f5e19c67fc5bc6e0115d7f
2021-04-29 04:52:50 -07:00
Nikitha Malgi
ce79bd255d
Fix doc issues ( #57153 )
...
Summary:
Fixes inconsistencies in the TorchScript Language reference.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57153
Reviewed By: zou3519, gmagogsfm
Differential Revision: D28061449
Pulled By: nikithamalgifb
fbshipit-source-id: a055c7b1417391afe00ec0b35e1042acb049feed
2021-04-28 11:47:10 -07:00
Zhengxu Chen
8176ab6ca0
[JIT] Put explicit error message on class attribute accesses. ( #55723 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55723
Resolving https://github.com/pytorch/pytorch/issues/51139
Test Plan:
python test/test_jit.py TestClassType.test_unresolved_attributes
Imported from OSS
Reviewed By: gmagogsfm
Differential Revision: D27691960
fbshipit-source-id: 1d078a4ab25af1a73109ca6ef0333a67a634bff6
2021-04-16 15:47:10 -07:00
Nikitha Malgi
643dd26389
Fix formatting for the new language reference ( #56042 )
...
Summary:
This PR fixes the formatting issues in the new language reference
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56042
Reviewed By: gmagogsfm
Differential Revision: D27830179
Pulled By: nikithamalgifb
fbshipit-source-id: bce3397d4de3f1536a1a8f0a16f10a703e7d4406
2021-04-16 14:18:09 -07:00
Yukio Siraichi
93bf0ae6fc
Remove legacy constructor calls from pytorch codebase. ( #54142 )
...
Summary:
Follow up from https://github.com/pytorch/pytorch/issues/53889
Related to https://github.com/pytorch/pytorch/issues/47112
Removing every occurrence of the legacy constructor call present in PyTorch at:
- _docs_
- _benchmarks_
- _test_
- _caffe2_
- _CONTRIBUTING.md_
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54142
Reviewed By: ngimel
Differential Revision: D27699450
Pulled By: mruberry
fbshipit-source-id: 530aa3f5746cc8bc1407d5d51b2bbd8075e30546
2021-04-11 15:45:17 -07:00
Yanan Cao
ec609e7420
Adds torch.* API section for TorchScript Lang Ref ( #53236 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53236
Reviewed By: SplitInfinity
Differential Revision: D27526584
Pulled By: gmagogsfm
fbshipit-source-id: ea931ea63aa4b37a7782935a1760bebffedc5b67
2021-04-02 03:01:08 -07:00
Yanan Cao
1b2b3ca86d
Language Ref Python Builtin Functions and Values ( #52830 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52830
Reviewed By: SplitInfinity, nikithamalgifb
Differential Revision: D27407474
Pulled By: gmagogsfm
fbshipit-source-id: 06fcafbcc66376c5f1818cb12fca2f2a57843c9d
2021-04-01 10:14:03 -07:00
nikithamalgi
790b69e096
Language Ref for Statements in Torchscript ( #52847 )
...
Summary:
Addresses the Statements supported in Torchscript for Language Spec
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52847
Reviewed By: gmagogsfm
Differential Revision: D27463142
Pulled By: nikithamalgifb
fbshipit-source-id: ff3def1b878092b0a2afc7c2f47b7857e6658ecf
2021-03-31 19:15:53 -07:00
nikithamalgi
444e5f0b60
Add Type System (I) ( #53244 )
...
Summary:
**Summary**
This commit adds a new .rst file to update the language specification with the updated content for the Type System section.
**Test Plan**

Pull Request resolved: https://github.com/pytorch/pytorch/pull/53244
Reviewed By: H-Huang
Differential Revision: D27445210
Pulled By: nikithamalgifb
fbshipit-source-id: 984c25b06686ba7a72cc03c5c069d819709eedb8
2021-03-30 23:10:27 -07:00
Meghan Lele
d60874354f
[docs] Add updated TorchScript language reference section for types ( #53673 )
...
Summary:
**Summary**
This commit adds information about type annotation and inference to
the updated language specification. It will be rebased on top of https://github.com/pytorch/pytorch/issues/52494
after it lands.
**Test Plan**
Continuous integration.
Screen capture:
https://user-images.githubusercontent.com/4392003/110560184-66371f80-80fa-11eb-803a-923cf8de25ff.mov
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53673
Reviewed By: gmagogsfm
Differential Revision: D27413001
Pulled By: SplitInfinity
fbshipit-source-id: b54b300b4b1f10537ec06e2ee9eeb6d2b1f1810b
2021-03-30 10:32:58 -07:00
Meghan Lele
b69dd910e8
[docs] Add starter content for new TorchScript language reference ( #53837 )
...
Summary:
**Summary**
This commit adds a new .rst file to use for updating the language specification and prepopulates it with the updated content for the expressions section.
**Test Plan**
https://user-images.githubusercontent.com/4392003/110441235-638ee880-806e-11eb-83ae-3b908bf00d5b.mov
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53837
Reviewed By: nikithamalgifb
Differential Revision: D26990801
Pulled By: SplitInfinity
fbshipit-source-id: 3b4e711bfaa8aac4ee3a075822fed7267a818121
2021-03-11 18:18:27 -08:00
Edward Yang
ffac9b2ead
Revert D26965463: [pytorch][PR] [docs] Add starter content for new TorchScript language reference
...
Test Plan: revert-hammer
Differential Revision:
D26965463 (d49c5c74f5 )
Original commit changeset: 246c76a56d91
fbshipit-source-id: 50de1a2ac92204a2f3a2ad9b8fa163338062bf58
2021-03-11 07:26:00 -08:00
Meghan Lele
d49c5c74f5
[docs] Add starter content for new TorchScript language reference ( #52494 )
...
Summary:
**Summary**
This commit adds a new .rst file to use for updating the language specification and prepopulates it with the updated content for the expressions section.
**Test Plan**
https://user-images.githubusercontent.com/4392003/110441235-638ee880-806e-11eb-83ae-3b908bf00d5b.mov
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52494
Reviewed By: nikithamalgifb
Differential Revision: D26965463
Pulled By: SplitInfinity
fbshipit-source-id: 246c76a56d911a8061e720abd200a44d7dfa1f35
2021-03-10 19:36:27 -08:00