cyy
38d3c27849
[1/N] Enable cppcoreguidelines-special-member-functions ( #137405 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137405
Approved by: https://github.com/ezyang
2024-10-23 00:16:53 +00:00
cyy
1544c37520
[7/N] Fixes clang-tidy warnings in c10/{core,util}/*.h ( #115495 )
...
This PR continues to fix clang-tidy warnings for headers in c10/core and c10/util.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/115495
Approved by: https://github.com/malfet
2023-12-19 02:14:30 +00:00
Benson Ma
66a2600b6a
[T153220354] Fix header inclusions in c10 ( #1541 ) ( #101846 )
...
Summary:
This is a re-attempt to land the iwyu header changes, by taking the diff from [PR 100304](https://github.com/pytorch/pytorch/pull/100304 ), and adding the bare minimal changes to make the diff build corectly in the internal builds.
X-link: https://github.com/facebookresearch/pytorch3d/pull/1541
X-link: https://github.com/fairinternal/pytorch3d/pull/44
- Re-work D45769819 to fix header inclusions in c10
Test Plan:
```
buck2 build --no-remote-cache mode/dev-nosan //caffe2/c10/...
buck2 build --no-remote-cache mode/dev-nosan //deeplearning/fbgemm/fbgemm_gpu/...
buck2 build mode/dev-nosan //vision/fair/pytorch3d/pytorch3d:_C
```
Reviewed By: malfet
Differential Revision: D45920611
Pull Request resolved: https://github.com/pytorch/pytorch/pull/101846
Approved by: https://github.com/malfet , https://github.com/Skylion007
2023-05-20 19:35:14 +00:00
PyTorch MergeBot
4eaaa08623
Revert "Fix header inclusions in c10 by iwyu ( #100304 )"
...
This reverts commit 6037ee8cc9 .
Reverted https://github.com/pytorch/pytorch/pull/100304 on behalf of https://github.com/jeanschmidt due to Breaking meta internal builds and fbgemm builds ([comment](https://github.com/pytorch/pytorch/pull/100304#issuecomment-1543919257 ))
2023-05-11 12:37:35 +00:00
cyy
6037ee8cc9
Fix header inclusions in c10 by iwyu ( #100304 )
...
This work introduces include-what-you-use support for c10 by a CMake option defaulting to off. We also remove some unused header inclusions and fix a trivial inclusion error.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/100304
Approved by: https://github.com/ezyang
2023-05-11 05:19:42 +00:00
PyTorch MergeBot
3271413e74
Revert "Fix header inclusions in c10 by iwyu ( #100304 )"
...
This reverts commit 39ec5fa722 .
Reverted https://github.com/pytorch/pytorch/pull/100304 on behalf of https://github.com/huydhn due to Sorry for reverting your PR, it is almost there but fails on Windows 39ec5fa722 , which is in unstable mode after https://github.com/pytorch/pytorch/pull/100548 ([comment](https://github.com/pytorch/pytorch/pull/100304#issuecomment-1542975714 ))
2023-05-11 00:37:32 +00:00
cyy
39ec5fa722
Fix header inclusions in c10 by iwyu ( #100304 )
...
This work introduces include-what-you-use support for c10 by a CMake option defaulting to off. We also remove some unused header inclusions and fix a trivial inclusion error.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/100304
Approved by: https://github.com/ezyang
2023-05-10 15:42:43 +00:00
Kazuaki Ishizaki
64b8d20a5c
Fix typos under c10 directory ( #98079 )
...
This PR fixes typos in comments and messages of files under `c10` directory
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98079
Approved by: https://github.com/Skylion007
2023-03-31 18:31:11 +00:00
cyy
3c6bc58f63
use C10_API in libc10.so ( #94171 )
...
MSVC emits several C4273 warning when compiling c10. I think the offending files should use C10_API instead of TORCH_API. If the tests pass, the changes should be safe.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94171
Approved by: https://github.com/Skylion007
2023-02-06 20:16:22 +00:00
Aaron Gokaslan
700941f683
Fixup c10 headers with clang-tidy ( #91407 )
...
Clang-tidy was not applied properly to headers in c10 as documented #91406 . These are the easy automated fixes that came out of applying clang-tidy to the c10 part of the code base. cc @ezyang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91407
Approved by: https://github.com/ezyang
2022-12-28 11:12:22 +00:00
Elias Ellison
d04889323e
Add Context Manager for Disabling Multithreading in Backwards, use in aot autograd ( #86245 )
...
We were running into a few issues with running multithreaded backwards in aot_autograd: such as https://github.com/pytorch/pytorch/issues/86136 , and `FakeTensorMode` getting into a weird state as a result of not executing functions completely sequentially. The multithreaded backwards is lost in translation when we trace out the backwards anyway, and adds a lot of additional complexity.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86245
Approved by: https://github.com/albanD , https://github.com/yf225
2022-10-06 03:27:42 +00:00
albanD
04108592a3
New TLS to disable forward mode AD ( #63117 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63117
Test Plan: Imported from OSS
Reviewed By: ngimel
Differential Revision: D30388097
Pulled By: albanD
fbshipit-source-id: f1bc777064645db1ff848bdd64af95bffb530984
2021-08-27 11:59:24 -07:00
Alban Desmaison
41ffec07ce
Add a common autograd TLS state ( #63860 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63860
Test Plan: Imported from OSS
Reviewed By: heitorschueroff
Differential Revision: D30513253
Pulled By: albanD
fbshipit-source-id: 97d76ed54dfbdf4ba3fc7051ce3b9bb636cefb4b
2021-08-24 15:34:06 -07:00
Alban Desmaison
688f06cac3
Revert D30388099: Add a common autograd TLS state
...
Test Plan: revert-hammer
Differential Revision:
D30388099 (83d9bad44a )
Original commit changeset: 8e03f940150f
fbshipit-source-id: f6d60fec66e8292f5268335bb8a3e7e1a662f23b
2021-08-24 07:22:39 -07:00
albanD
83d9bad44a
Add a common autograd TLS state ( #63114 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63114
This PR collapses the GradMode and InferenceMode thread local booleans into a single thread local uint8.
This helps reducing the number of thread local variable accesses done when we propagate ThreadLocalStates.
Note that this is even more beneficial as we will add a forward mode AD TLS (similar to GradMode) higher in this stack and this new structure should reduce the perf impact of adding this new TLS.
Here is the full benchmark result between master and the top of this stack: https://gist.github.com/albanD/e421101e9ed344e94999bef3a54bf0f3
tl;dr: give a benefit in most cases. It is never detrimental.
Test Plan: Imported from OSS
Reviewed By: ejguan
Differential Revision: D30388099
Pulled By: albanD
fbshipit-source-id: 8e03f940150ff063c2edd792733663413ae2f486
2021-08-24 06:54:02 -07:00
Ailing Zhang
e554731b32
Hide set_enabled since it's not public facing. ( #58078 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58078
Test Plan: Imported from OSS
Reviewed By: albanD
Differential Revision: D28362048
Pulled By: ailzhang
fbshipit-source-id: 4c78a7c58860ec4963bc8d05d133ea26e47dcf00
2021-05-12 22:52:17 -07:00
Ailing Zhang
0ecdbfebff
s/InplaceOrView/ADInplaceOrView/g ( #57372 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57372
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57324
Test Plan: Imported from OSS
Reviewed By: ZolotukhinM
Differential Revision: D28121821
Pulled By: ailzhang
fbshipit-source-id: f568dd2505f6279da9ffb93ce1d22e0f98c606bb
2021-05-01 22:56:18 -07:00
Scott Wolchok
44cc873fba
[PyTorch] Autoformat c10 ( #56830 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56830
Opt into formatting on GitHub and format everything. This is a trial run before turning on formatting for more and eventually all of the codebase.
Test Plan: CI
Reviewed By: zertosh
Differential Revision: D27979080
fbshipit-source-id: a80f0c48691c08ae8ca0af06377b87e6a2351151
2021-04-30 21:23:28 -07:00
Ailing Zhang
98162cb0bb
Enable AutoGradMode in InferenceMode. ( #56107 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56107
Test Plan: Imported from OSS
Reviewed By: pbelevich, driazati
Differential Revision: D27807137
Pulled By: ailzhang
fbshipit-source-id: bfacf11ec5a431589cec73d6371cac81b425a115
2021-04-19 10:24:20 -07:00
Ailing Zhang
da01f4398b
Add InferenceMode TLS to ThreadLocalState. ( #55822 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55822
Test Plan: Imported from OSS
Reviewed By: bhosmer
Differential Revision: D27721285
Pulled By: ailzhang
fbshipit-source-id: c978927f8cb3a91de45635b8279e166a3d5652ab
2021-04-12 21:37:27 -07:00
Ailing Zhang
6842da6251
[WIP]Relax some limitations of InferenceMode. ( #54403 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54403
A few important points about InferenceMode behavior:
1. All tensors created in InferenceMode are inference tensors except for view ops.
- view ops produce output has the same is_inference_tensor property as their input.
Namely view of normal tensor inside InferenceMode produce a normal tensor, which is
exactly the same as creating a view inside NoGradMode. And view of
inference tensor outside InferenceMode produce inference tensor as output.
2. All ops are allowed inside InferenceMode, faster than normal mode.
3. Inference tensor cannot be saved for backward.
Test Plan: Imported from OSS
Reviewed By: ezyang
Differential Revision: D27316483
Pulled By: ailzhang
fbshipit-source-id: e03248a66d42e2d43cfe7ccb61e49cc4afb2923b
2021-04-09 14:40:37 -07:00
Ailing Zhang
bc05867618
Separate TLS for InferenceMode ( #55424 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55424
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55238
I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
https://github.com/pytorch/pytorch/pull/55008 .
```
λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
100 0x0000000004854750
-100 0x0000000004854760
-4400 c10::impl::tls_is_dispatch_key_included(...)
```
Test Plan: Imported from OSS
Reviewed By: ezyang
Differential Revision: D27539230
Pulled By: ailzhang
fbshipit-source-id: e040877faef966dca3c2c3d5f9e9a80496c81415
2021-04-06 22:17:26 -07:00
Ailing Zhang
43d4f3b8d0
Implement public API InferenceMode and its error handling ( #55008 )
...
Summary:
https://www.internalfb.com/phabricator/paste/view/P360377337Pull Request resolved: https://github.com/pytorch/pytorch/pull/53343
For easier review, here's a diff between the version before revert. https://www.internalfb.com/phabricator/paste/view/P360750919
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55008
Test Plan: Imported from OSS
Pulled By: ailzhang
Reviewed By: bhosmer
Differential Revision: D27443229
fbshipit-source-id: 01b03446a1f6373f43dd5c7170d26226b50f363c
2021-03-31 10:48:00 -07:00
Ailing Zhang
263180d7fc
Revert D26973911: Implement public API InferenceMode and its error handling
...
Test Plan: revert-hammer
Differential Revision:
D26973911 (7caa464631 )
Original commit changeset: 0ebdac7a3cd5
fbshipit-source-id: afd37a3785bc694e8ffbd679eba1cfed89ef2273
2021-03-29 11:17:49 -07:00
Ailing Zhang
7caa464631
Implement public API InferenceMode and its error handling ( #53343 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53343
Test Plan: Imported from OSS
Reviewed By: ezyang, nikithamalgifb
Differential Revision: D26973911
Pulled By: ailzhang
fbshipit-source-id: 0ebdac7a3cd554822d26d5a40f539b6e2aaec61d
2021-03-27 13:44:23 -07:00