cyy
8fa81a6066
Enable misc-use-internal-linkage check and apply fixes ( #148948 )
...
Enables clang-tidy rule [`misc-use-internal-linkage`](https://clang.llvm.org/extra/clang-tidy/checks/misc/use-internal-linkage.html ). This new check was introduced in Clang-Tidy 18 and is available due to recent update of Clang-Tidy 19.
The check marks functions and variables used only in the translation unit as static. Therefore undesired symbols are not leaked into other units, more link time optimisations are possible and the resulting binaries may be smaller.
The detected violations were mostly fixed by using static. In other cases, the symbols were indeed consumed by others files, then their declaring headers were included. Still some declarations were wrong and have been fixed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148948
Approved by: https://github.com/Skylion007
2025-03-12 14:22:56 +00:00
cyy
25aa7ca62d
Cleanup CallOnce.h ( #146700 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146700
Approved by: https://github.com/albanD
2025-02-07 16:44:45 +00:00
rpsilva
4abff4b271
Introduce cache clearing APIs for the lazy graph executor ( #144489 )
...
This PR introduces two new methods to the LazyGraphExecutor class:
- ClearComputationCache(): Allows clearing the entire computation cache.
- RemoveFromComputationCache(hash): Enables removal of specific cache entries based on their hash.
The main objective is to expose cache management functionality for debugging cache hits and misses across different computations. For instance:
- Reset the cache state in tests, allowing reuse of the same computation client to evaluate cache logic consistently.
- Selectively remove cache entries to analyze the impact on subsequent computations.
- Improve observability into the cache behavior, aiding in the investigation of cache-related issues or optimizations.
On the XLA lazy graph executor, we want to run a series of tests that modify some parts of the HLO module proto of the computation, and we need a means to ensure that the hash is agnostic to some elements (OpMetadata in the XLA proto data). Hence, it would be easy to parameterize the test, clear the cache and validate that the resulting hash is the same between runs. Otherwise, we'd need to hardcode the resulting serialized hash.
Simultaneously, **another motivation**, is that users could also clear some computation hashes for an added flexibility in their applications, by introducing their own custom strategies for maintaining the cache (without relying on the default LRU).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144489
Approved by: https://github.com/wconstab
2025-01-29 17:38:01 +00:00
cyyever
ef28df5c9e
[Reland][Environment Variable][4/N] Use thread-safe getenv functions ( #140593 )
...
Reland of #137843 , after checking the code again.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140593
Approved by: https://github.com/albanD
Co-authored-by: albanD <desmaison.alban@gmail.com>
2025-01-28 20:51:49 +00:00
cyy
b0be30dd79
[19/N] Fix extra warnings brought by clang-tidy-17 ( #144448 )
...
Apply more clang-tidy fixes. There was a bug introduced by #144014 due to incorrect namespace concatenation which is reverted here.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144448
Approved by: https://github.com/albanD
2025-01-09 15:58:05 +00:00
cyy
d0070ca07e
[18/N] Fix extra warnings brought by clang-tidy-17 ( #144014 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144014
Approved by: https://github.com/Skylion007 , https://github.com/albanD
2025-01-08 17:21:55 +00:00
cyy
dca443835e
Enable more readability-redundant checks ( #143963 )
...
They are helpful to simplifying code.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143963
Approved by: https://github.com/albanD
2024-12-30 14:49:33 +00:00
cyy
af8789c056
Hide torch_python symbols ( #142214 )
...
Change symbols in torch_python to invisible by default on platforms other than Apple.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142214
Approved by: https://github.com/ezyang
2024-12-16 00:59:26 +00:00
cyy
2903cf0ad8
Re-enable some C++ warnings ( #142332 )
...
It enables some C++ warnings since the code base is fairly clean. Meanwhile, Wextra-semi is disabled on CUDA generated code since there is no way to fix them without the cooperation of CUDA team.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142332
Approved by: https://github.com/albanD , https://github.com/eqy
2024-12-12 04:02:12 +00:00
cyy
7d98b3dcee
[3/N] Apply bugprone-unchecked-optional-access ( #142442 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142442
Approved by: https://github.com/albanD
2024-12-11 01:39:10 +00:00
cyy
b4c0973b59
[2/N] Apply bugprone-unchecked-optional-access ( #141091 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141091
Approved by: https://github.com/Skylion007 , https://github.com/albanD
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2024-12-09 19:30:19 +00:00
Yue Dong
022cbf2f31
Back out "[Reland][Environment Variable][5/N] Use thread-safe getenv functions ( #140594 )" ( #142226 )
...
Summary: Failed to write the auto-tune result to `PYTORCH_TUNABLEOP_FILENAME` with this change (empty file) , reverting to unblock.
Test Plan: CI
Differential Revision: D66870750
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142226
Approved by: https://github.com/leitian
2024-12-07 00:59:22 +00:00
cyy
ab5467897a
Fix NOLINTNEXTLINE ( #141794 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141794
Approved by: https://github.com/Skylion007
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2024-12-02 19:22:00 +00:00
PyTorch MergeBot
eb7deb2db5
Revert "Fix NOLINTNEXTLINE ( #141794 )"
...
This reverts commit 7dd9b5fc43 .
Reverted https://github.com/pytorch/pytorch/pull/141794 on behalf of https://github.com/atalman due to [GH job link](https://github.com/pytorch/pytorch/actions/runs/12087979418/job/33711943084 ) [HUD commit link](7dd9b5fc43 ) ([comment](https://github.com/pytorch/pytorch/pull/141794#issuecomment-2511789484 ))
2024-12-02 15:07:50 +00:00
cyyever
7dd9b5fc43
Fix NOLINTNEXTLINE ( #141794 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141794
Approved by: https://github.com/Skylion007
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2024-11-29 16:23:59 +00:00
cyy
45ed7c13fa
Remove unneeded std::make_optional ( #141567 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141567
Approved by: https://github.com/albanD
2024-11-28 00:05:21 +00:00
Richard Barnes
fca0f34b83
Switch c10::string_view to std::string_view ( #139635 )
...
Shortens `string_view_starts_with` to `starts_with`. Adds some missing headers. Isolates `c10_string_view` to use with `get_fully_qualified_name`.
Test Plan: Sandcastle
Reviewed By: ezyang
Differential Revision: D64833558
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139635
Approved by: https://github.com/Skylion007 , https://github.com/ezyang
2024-11-27 01:41:18 +00:00
cyy
2f082e1e56
[13/N] Fix extra warnings brought by clang-tidy-17 ( #140897 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140897
Approved by: https://github.com/ezyang
2024-11-27 00:35:19 +00:00
cyy
d91484509a
[1/N] Apply bugprone-unchecked-optional-access ( #140679 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140679
Approved by: https://github.com/ezyang
2024-11-20 04:04:41 +00:00
cyy
8cd7ad8b48
[Reland][Environment Variable][5/N] Use thread-safe getenv functions ( #140594 )
...
Reland of #139762 with no bug found.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140594
Approved by: https://github.com/ezyang
2024-11-18 21:45:35 +00:00
PyTorch MergeBot
2675ef8758
Revert " [Environment Variable][5/N] Use thread-safe getenv functions ( #139762 )"
...
This reverts commit 43f0fe60a3 .
Reverted https://github.com/pytorch/pytorch/pull/139762 on behalf of https://github.com/malfet due to One of these diffs had incorrect downstream optional handling, we must reaudit all of these diffs ([comment](https://github.com/pytorch/pytorch/pull/139762#issuecomment-2474174813 ))
2024-11-13 16:50:00 +00:00
PyTorch MergeBot
c6a29fc3d8
Revert "[Environment Variable][4/N] Use thread-safe getenv functions ( #137843 )"
...
This reverts commit 82eb09aafd .
Reverted https://github.com/pytorch/pytorch/pull/137843 on behalf of https://github.com/ezyang due to One of these diffs had incorrect downstream optional handling, we must reaudit all of these diffs ([comment](https://github.com/pytorch/pytorch/pull/137843#issuecomment-2473709760 ))
2024-11-13 14:06:52 +00:00
cyy
40fb738197
Use Wextra-semi ( #140236 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140236
Approved by: https://github.com/ezyang
2024-11-13 02:15:16 +00:00
cyy
7624d625c0
[Reland][7/N] Fix Wextra-semi warning ( #140342 )
...
Reland of #140225 to fix a change in FBCODE_CAFFE2
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140342
Approved by: https://github.com/kit1980
2024-11-12 18:55:31 +00:00
PyTorch MergeBot
dbb55b448b
Revert "[7/N] Fix Wextra-semi warning ( #140225 )"
...
This reverts commit ffb979032d .
Reverted https://github.com/pytorch/pytorch/pull/140225 on behalf of https://github.com/kit1980 due to breaking internal builds ([comment](https://github.com/pytorch/pytorch/pull/140225#issuecomment-2469312229 ))
2024-11-12 00:02:06 +00:00
cyy
ffb979032d
[7/N] Fix Wextra-semi warning ( #140225 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140225
Approved by: https://github.com/ezyang
2024-11-10 14:28:10 +00:00
cyy
ab55a99283
Use TORCH_DECLARE_XXX ( #139952 )
...
Because those files use TORCH_API
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139952
Approved by: https://github.com/ezyang
2024-11-09 04:56:28 +00:00
cyy
43f0fe60a3
[Environment Variable][5/N] Use thread-safe getenv functions ( #139762 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139762
Approved by: https://github.com/ezyang
2024-11-08 03:49:09 +00:00
cyy
d558c1a047
Enable cppcoreguidelines-special-member-functions ( #139132 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139132
Approved by: https://github.com/sraikund16
2024-11-06 13:42:20 +00:00
PyTorch MergeBot
10d7729333
Revert "Enable cppcoreguidelines-special-member-functions ( #139132 )"
...
This reverts commit a9b4989c72 .
Reverted https://github.com/pytorch/pytorch/pull/139132 on behalf of https://github.com/ZainRizvi due to Sorry but this fails on trunk. See inductor/test_mkldnn_pattern_matcher.py::TestPatternMatcher::test_smooth_quant_with_int_mm [GH job link](https://github.com/pytorch/pytorch/actions/runs/11699366379/job/32591132460 ) [HUD commit link](22e89ea2aa ) ([comment](https://github.com/pytorch/pytorch/pull/139132#issuecomment-2459743145 ))
2024-11-06 13:27:42 +00:00
cyy
a9b4989c72
Enable cppcoreguidelines-special-member-functions ( #139132 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139132
Approved by: https://github.com/sraikund16
2024-11-06 07:59:09 +00:00
cyy
419a7e197d
[6/N] Fix Wextra-semi warning ( #139605 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139605
Approved by: https://github.com/ezyang
2024-11-04 13:43:16 +00:00
cyy
4a2da52137
[1/N] Replace c10::sv with std::sv ( #139453 )
...
Picks some safe replacements.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139453
Approved by: https://github.com/Skylion007
2024-11-01 05:39:37 +00:00
cyy
1dd503c6fb
[4/N] Fix Wextra-semi warning ( #139256 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139256
Approved by: https://github.com/ezyang
2024-10-31 03:01:14 +00:00
cyyever
456c87c8a2
[8/N] Fix extra warnings brought by clang-tidy-17 ( #139151 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139151
Approved by: https://github.com/ezyang
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2024-10-30 14:20:08 +00:00
FFFrog
af0bc75460
Remove deprecated alias macro(1/3) ( #137556 )
...
**Detailed Descriptions:**
- Remove AT_ERROR Macro
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137556
Approved by: https://github.com/ezyang
2024-10-21 17:32:32 +00:00
cyy
a05b64a38f
[5/N] Fix extra warnings brought by clang-tidy-17 ( #138403 )
...
Follows #137983
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138403
Approved by: https://github.com/ezyang
2024-10-21 02:59:54 +00:00
cyy
82eb09aafd
[Environment Variable][4/N] Use thread-safe getenv functions ( #137843 )
...
Follows #137328
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137843
Approved by: https://github.com/ezyang
2024-10-21 02:58:59 +00:00
PyTorch MergeBot
a1899b5a9e
Revert "[Environment Variable][4/N] Use thread-safe getenv functions ( #137843 )"
...
This reverts commit 239ad73cb1 .
Reverted https://github.com/pytorch/pytorch/pull/137843 on behalf of https://github.com/yf225 due to Sorry for reverting your PR but I believe this PR breaks the binary builds. Example: https://ossci-raw-job-status.s3.amazonaws.com/log/31790258895 , with error message: `getenv is not a member of c10::utils`, might be easier to search for `not a member of` in the log ([comment](https://github.com/pytorch/pytorch/pull/137843#issuecomment-2425192780 ))
2024-10-20 19:48:14 +00:00
cyy
239ad73cb1
[Environment Variable][4/N] Use thread-safe getenv functions ( #137843 )
...
Follows #137328
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137843
Approved by: https://github.com/ezyang
2024-10-20 13:05:04 +00:00
Richard Barnes
fddabc6e0b
C10_UNUSED to [[maybe_unused]] ( #6357 ) ( #138364 )
...
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/6357
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138364
Approved by: https://github.com/Skylion007 , https://github.com/eqy
2024-10-19 13:17:43 +00:00
Aleksei Nikiforov
949b6f685d
Enable -Werror on s390x ( #136527 )
...
Enable -Werror on s390x
Example of original issue on s390x:
https://github.com/pytorch/pytorch/actions/runs/11014606340/job/30585632704
Most of warnings are not specific to s390x, but specific to gcc-13 or gcc-14. To test it on s390x an image with gcc-13 is needed. For s390x it's tested for new regressions on every merge due to trunk workflow.
`-Wdangling-reference` produces either obviously false warnings or suspicious warnings, which on closer inspection look plausibly safe.
`-Wredundant-move` with new gcc complains about `std::move(...)` disabling copy elision. But removing `std::move(...)` makes used clang versions complain about copying objects when they could be moved. For now also disable it.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136527
Approved by: https://github.com/malfet
2024-10-19 01:18:42 +00:00
PyTorch MergeBot
cd292908e5
Revert "Make c10::string_view an alias of std::string_view ( #130417 )"
...
This reverts commit c48fe89011 .
Reverted https://github.com/pytorch/pytorch/pull/130417 on behalf of https://github.com/clee2000 due to breaking some internal tests, probably usages of string_view that need to be changed? ([comment](https://github.com/pytorch/pytorch/pull/130417#issuecomment-2414775064 ))
2024-10-15 18:55:09 +00:00
Richard Barnes
b7f798caa4
Use C10_UNUSED instead of (void)X ( #137239 )
...
Summary:
Auto-generated with
```
buck run //scripts/rbarnes/regex_multiline_replacer:regex_multiline_replacer -- --find '^(\s*for\s*\()(const.*\n)\s*\(void\)[A-Za-z]+;\s*//\s*Suppress.*\s*\n(.*)' --replace '\1C10_UNUSED \2\3' `find caffe2/ -regex ".*\.\(cpp\|h\)"`
```
Differential Revision: D33432600
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137239
Approved by: https://github.com/Skylion007
2024-10-15 14:32:59 +00:00
cyy
c48fe89011
Make c10::string_view an alias of std::string_view ( #130417 )
...
In order to facilitate the mitigation from c10::string_view to std::string_view, the old c10::string_view was renamed to c10::string_view_ext.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130417
Approved by: https://github.com/ezyang
2024-10-14 09:28:04 +00:00
Ryan Landay
513563eb09
Fix stack named "queue" in Util::ComputePostOrder ( #130526 )
...
This function computes a topological sort using a non-recursive implementation of DFS. Upon first reading, I thought it was using Kahn’s algorithm because it uses a variable called `queue`, but upon closer reading, I noticed this variable is actually used as a stack.
This pull request improves readability by renaming the stack and changing it from `std::vector` to `std::stack`.
Note: this also changes the backing store from an `std::vector` to an `std::deque`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130526
Approved by: https://github.com/alanwaketan , https://github.com/malfet
2024-10-11 20:21:07 +00:00
cyy
a2396b2dd8
[2/N] Fix extra warnings brought by clang-tidy-17 ( #137459 )
...
Follows #137407
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137459
Approved by: https://github.com/Skylion007
2024-10-08 19:05:02 +00:00
cyy
156ca01e51
Enable clang-tidy on torch/csrc/lazy ( #136851 )
...
Enable clang-tidy on torch/csrc/lazy
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136851
Approved by: https://github.com/Skylion007
2024-09-28 21:16:40 +00:00
cyy
cbc182d2e0
Remove problematic constructor ( #136708 )
...
Since it calls a pure virtual function and it is not used elsewhere.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136708
Approved by: https://github.com/ezyang
2024-09-27 16:16:58 +00:00
cyy
59e8f8228f
[3/N] Fix clang-tidy warnings in torch/csrc/lazy ( #136705 )
...
Follows #136634
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136705
Approved by: https://github.com/Skylion007
2024-09-26 16:29:43 +00:00