Jeddie Ji
20ec61a02f
[BE] fix lint errors caused by const SROpFunctor fn ( #154552 )
...
Summary: Remove const quaiflier from SR suggsted from CLANGTIDY.
Test Plan: arc lint -a -e extra --take CLANGTIDY caffe2/torch/fb/sparsenn/cpu_operators/to_dense_representation_cpu.cpp
Reviewed By: henryoier
Differential Revision: D75534056
Pull Request resolved: https://github.com/pytorch/pytorch/pull/154552
Approved by: https://github.com/Skylion007
2025-05-29 19:40:08 +00:00
Yuanyuan Chen
ed5f4a4fa8
Replace size() checks with empty() ( #153805 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153805
Approved by: https://github.com/nareshrajkumar866 , https://github.com/Skylion007
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2025-05-19 16:20:57 +00:00
Huy Do
8904ba6387
Forward fix D74196435 ( #152926 )
...
Summary: Forward fix a misplace declaration from D74196435
Test Plan: Random check with a failed build `buck2 build --config fbcode.enable_gpu_sections=true --flagfile fbcode//mode/opt fbcode//accelerators/workloads/models/emu_flash/tests:test_compile_eager`
Reviewed By: wdvr
Differential Revision: D74225582
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152926
Approved by: https://github.com/cyyever , https://github.com/wdvr
2025-05-06 07:33:38 +00:00
cyy
45efa1aaa8
[3/N] Use internal linkage in C++ files ( #151297 )
...
Follows #151070 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151297
Approved by: https://github.com/Skylion007
2025-05-05 17:48:39 +00:00
cyy
ce94b212c7
[Environment Variable][Rebase] Use thread-safe getenv functions ( #140200 )
...
Use our thread-safe getenv wrappers.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140200
Approved by: https://github.com/kwen2501 , https://github.com/eqy
2025-05-02 00:41:49 +00:00
cyy
41bd0c900a
[1/N] Deprecate c10::string_view and at::string ( #151972 )
...
The calls of `c10::string_view` in the code base are replaced by `std::string_view`. The calls of `at::string` are replaced by `std::string`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151972
Approved by: https://github.com/malfet
2025-04-29 07:23:52 +00:00
cyy
70d7638b0d
Fix clang-tidy suppression in torch/csrc/jit ( #152271 )
...
Remove some clang-tidy suppression in torch/csrc/jit by applying fixes or refactoring.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152271
Approved by: https://github.com/Skylion007 , https://github.com/malfet
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2025-04-27 21:18:39 +00:00
cyyever
24ca7e91e6
[1/N] Use internal linkage in torch/csrc C++ files. ( #150930 )
...
Turn more functions and variables into static if they are not used outside the cpp files. Unused functions are removed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/150930
Approved by: https://github.com/Skylion007
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2025-04-11 02:19:31 +00:00
cyy
142f0f86ce
Enable modernize-use-default-member-init ( #149046 )
...
``modernize-use-default-member-init`` prefers initialisation in class members, that make more ``= default`` constructors possible. Some violations or modernize rules have been fixed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/149046
Approved by: https://github.com/zou3519
2025-04-09 11:57:24 +00:00
cyy
e872c38eb3
Remove cppcoreguidelines-pro-type-member-init_fix suppression ( #148638 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148638
Approved by: https://github.com/zou3519
2025-04-02 01:33:20 +00:00
Scott Ramsby
842a072fd3
[codemod] Fix clang-tidy command line doc comments ( #149524 )
...
Summary:
Fixes the comments to match the latest updates to the checked-in tools.
Search/replace applied in this order:
* `# /fbsource/tools/lint/clangtidy/clang-tidy-platform010 -list-checks` -> `# ~/fbsource/tools/lint/clangtidy/clang-tidy-platform010-clang-17 -list-checks`
* `# ~/fbsource/tools/lint/clangtidy/clang-tidy-platform010 -list-checks` -> `# ~/fbsource/tools/lint/clangtidy/clang-tidy-platform010-clang-17 -list-checks`
* `fbsource/tools/lint/clangtidy/clang-tidy-platform010 -list-checks` -> `fbsource/tools/lint/clangtidy/clang-tidy-platform010-clang-17 -list-checks`
Test Plan: CI
Reviewed By: johnkearney
Differential Revision: D71431516
Pull Request resolved: https://github.com/pytorch/pytorch/pull/149524
Approved by: https://github.com/janeyx99
2025-03-19 19:22:11 +00:00
Riham Selim
b963d96bad
[Torchscript] Add a flag to use mangled names instead of demangled ( #148906 )
...
Summary: Optionally keep mangled names when expanding torchscript stacks
Test Plan:
```
buck2 build mode/opt //scripts/rihams/LearnPyTorch:torch_script_generate --show-full-output
/data/users/rihams/fbsource/buck-out/v2/gen/fbcode/0bd9d136228ad8a7/scripts/rihams/LearnPyTorch/__torch_script_generate__/torch_script_generate.par
buck2 build mode/opt //scripts/rihams/LearnPyTorch:torch_script_execute --show-full-output
```
- With `--torch_jit_expanded_stacks_mangled` Flag:
/data/users/rihams/fbsource/buck-out/v2/gen/fbcode/ef35e45045e8164c/scripts/rihams/LearnPyTorch/__torch_script_execute__/torch_script_execute fbcode/model.pt --torch_jit_expanded_stacks_mangled --torch_jit_enable_expanded_stacks
https://fburl.com/scuba/strobelight_function_tracer/8die4rvm
{F1975933247}
Without Flag:
/data/users/rihams/fbsource/buck-out/v2/gen/fbcode/ef35e45045e8164c/scripts/rihams/LearnPyTorch/__torch_script_execute__/torch_script_execute ./model.pt --torch_jit_enable_expanded_stacks
https://fburl.com/scuba/strobelight_function_tracer/x3nladpf
{F1975933268}
Reviewed By: bbus
Differential Revision: D70905872
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148906
Approved by: https://github.com/zdevito
2025-03-19 07:53:02 +00:00
zeshengzong
97272e4b49
Fix torch.nn.functional.hardswish gradients corner case ( #148049 )
...
Fixes #147801
## Changes
- Change hardswish gradient compute condition as [torch.nn.functional.hardswish](https://pytorch.org/docs/stable/generated/torch.nn.functional.hardswish.html )
- Enable cuda for test `test_hardswish_grad_corner`
- Add test case for value=-3
## Test Result
```bash
pytest test/test_nn.py -k test_hardswish
pytest test/test_unary_ufuncs.py -k test_hardswish
pytest test/inductor/test_torchinductor.py -k test_hardswish
```



Pull Request resolved: https://github.com/pytorch/pytorch/pull/148049
Approved by: https://github.com/soulitzer
2025-03-14 18:53:10 +00:00
PyTorch MergeBot
abcca2fcbb
Revert "Fix torch.nn.functional.hardswish gradients corner case ( #148049 )"
...
This reverts commit 29b28e9d9f .
Reverted https://github.com/pytorch/pytorch/pull/148049 on behalf of https://github.com/soulitzer due to This may be causing an accuracy failure on inductor ([comment](https://github.com/pytorch/pytorch/pull/148049#issuecomment-2706839169 ))
2025-03-07 16:05:56 +00:00
zeshengzong
29b28e9d9f
Fix torch.nn.functional.hardswish gradients corner case ( #148049 )
...
Fixes #147801
## Changes
- Change hardswish gradient compute condition as [torch.nn.functional.hardswish](https://pytorch.org/docs/stable/generated/torch.nn.functional.hardswish.html )
- Enable cuda for test `test_hardswish_grad_corner`
- Add test case for value=-3
## Test Result
```bash
pytest test/test_nn.py -k test_hardswish
pytest test/test_unary_ufuncs.py -k test_hardswish
pytest test/inductor/test_torchinductor.py -k test_hardswish
```



Pull Request resolved: https://github.com/pytorch/pytorch/pull/148049
Approved by: https://github.com/soulitzer
2025-03-06 19:04:52 +00:00
cyy
9aa897b992
Remove unnecessary tensor clone ( #148159 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148159
Approved by: https://github.com/Skylion007
2025-03-02 16:21:39 +00:00
Kevin Fu
4986f0f52e
[PT2]: allow empty dict to pass type check ( #147167 ) ( #147480 )
...
Summary:
Seeing errors like when testing sigmoid for inline_cvr and perevent_cvr models.
```
terminate called after throwing an instance of 'c10::Error'
what(): forward() Expected a value of type 'Dict[int, Tuple[Tensor, Tensor, Tensor]]' for argument 'event_based_features' but instead found type 'Dict[Any, Any]'.
```
Let empty dict pass type check.
please, do NOT use any of the following flags, those are result of manual interventions in other parts of the system, misuse of them can be very painful for both detect and recover:
Test Plan:
```
MODEL_ENTITY_ID=691508446
SNAPSHOT_ID=0
OTHER_MODEL_ENTITY_ID=649645886
OTHER_SNAPSHOT_ID=0
MODULE=local
buck2 run mode/opt caffe2/torch/fb/model_transform/fx2trt/packaging:load_net_predictor -- \
--loadMode=BenchmarkAB \
--inputNetFile=/data/users/${USER}/models/${MODEL_ENTITY_ID}/${SNAPSHOT_ID}/${MODEL_ENTITY_ID}_${SNAPSHOT_ID}${suffix} \
--otherNetFile=/data/users/${USER}/models/${OTHER_MODEL_ENTITY_ID}/${OTHER_SNAPSHOT_ID}/${OTHER_MODEL_ENTITY_ID}_${OTHER_SNAPSHOT_ID}${suffix} \
--moduleName=${module} \
--submodToDevice "" \
--benchmarkDontRebatchSamples=true \
--sampleInputFilePath=/data/users/${USER}/models/${MODEL_ENTITY_ID}/${SNAPSHOT_ID}/archive_.predictor.disagg.gpu.local/data/sample_inputs/local.pt
```
Reviewed By: yjhao
Differential Revision: D69871393
Pull Request resolved: https://github.com/pytorch/pytorch/pull/147480
Approved by: https://github.com/henryoier , https://github.com/jeanschmidt
2025-02-21 07:00:46 +00:00
Zhou Fang
a8fa4bcfd2
[StaticRuntime] Support a new pattern (aten::to with 5 inputs) for ClipRangesToGatherToOffsets ( #147189 )
...
Summary:
Support the following new pattern for ClipRangesToGatherToOffsets:
Before optimization:
```
%11175 : Tensor, %11176 : Tensor = fb::clip_ranges_gather(%int_66.1, %getitem_1784.1, %347)
%getattr_256.1 : int = prim::dtype(%11175)
%to_298.1 : Tensor = aten::to(%11176, %getattr_256.1, %13, %13, %12)
%lengths_to_offsets_333.1 : Tensor = fb::lengths_to_offsets(%to_298.1, %8)
```
After optimization:
```
%11199 : int = prim::dtype(%int_66.1)
%11200 : Tensor, %11201 : Tensor = fb::clip_ranges_gather_to_offsets(%int_66.1, %getitem_1784.1, %347, %8, %11199)
```
It is similar with https://github.com/pytorch/pytorch/pull/146931 , but aten::to has 5 inputs instead of 4.
Differential Revision: D69627793
Pull Request resolved: https://github.com/pytorch/pytorch/pull/147189
Approved by: https://github.com/hanyilou123
2025-02-16 22:16:02 +00:00
cyy
8f291e8c00
Fix clang-tidy warnings in torch/jit ( #146963 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146963
Approved by: https://github.com/davidberard98
2025-02-15 03:36:59 +00:00
Zhou Fang
d774a6333d
[StaticRuntime] Support a new pattern for ClipRangesToGatherToOffsets ( #146931 )
...
Summary:
Support the following new pattern for ClipRangesToGatherToOffsets:
Before optimization:
```
%18267 : Tensor, %18268 : Tensor = fb::clip_ranges_gather(%int_77.1, %getitem_2484.1, %493)
%getattr_368.1 : int = prim::dtype(%18267)
%to_443.1 : Tensor = aten::to(%18268, %getattr_368.1, %self._maybe_compute_kjt_to_jt_dict.is_weighted, %self._maybe_compute_kjt_to_jt_dict.is_weighted)
%lengths_to_offsets_490.1 : Tensor = fb::lengths_to_offsets(%to_443.1, %8)
```
After optimization:
```
%18297 : int = prim::dtype(%int_77.1)
%18298 : Tensor, %18299 : Tensor = fb::clip_ranges_gather_to_offsets(%int_77.1, %getitem_2484.1, %493, %8, %18297)
```
Reviewed By: garroud
Differential Revision: D69373835
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146931
Approved by: https://github.com/hanyilou123
2025-02-12 08:19:41 +00:00
Zhou Fang
fc5913b6bf
[StaticRuntime] Fix a bug that memory planner ignores subblocks ( #146728 ) ( #146855 )
...
Summary:
When Static Runtime graph node has sub-blocks, the memory planner does not consider sub-blocks' inputs as a node's input in memory planner. As the result, such nodes' inputs' lifetime is incorrect and corresponding tensor memory is released earlier than required and causes errors.
Differential Revision: D69195886
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146855
Approved by: https://github.com/swolchok
2025-02-11 13:59:54 +00:00
Michal Gallus
9ea1823f96
[ROCm][Windows] Remove external linkage from an anonymous namespace ( #146607 )
...
Fixes a clang-cl compiler error related to attempt to export a symbol that doesn't have any external linkage, since its declared within a local anonymous namespace.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146607
Approved by: https://github.com/jeffdaily
2025-02-06 23:48:20 +00:00
cyy
6293d1446b
[2/N] Remove NOLINT suppressions ( #146402 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146402
Approved by: https://github.com/soulitzer
2025-02-05 08:38:52 +00:00
Richard Barnes
7e41717a26
c10::string_view -> std::string_view in caffe2/jit ( #142383 )
...
Test Plan: Sandcastle
Differential Revision: D66939979
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142383
Approved by: https://github.com/malfet
2024-12-10 15:42:28 +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
PyTorch MergeBot
a58a565819
Revert "[Environment Variable][6/N] Use thread-safe getenv functions ( #140200 )"
...
This reverts commit 7d4f5f7508 .
Reverted https://github.com/pytorch/pytorch/pull/140200 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/140200#issuecomment-2473956859 ))
2024-11-13 15:33:23 +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
7d4f5f7508
[Environment Variable][6/N] Use thread-safe getenv functions ( #140200 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140200
Approved by: https://github.com/ezyang
2024-11-09 15:05:51 +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
da1e120dfd
[2/N] Replace c10::sv with std::sv ( #139456 )
...
Follows #139453
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139456
Approved by: https://github.com/ezyang , https://github.com/malfet
2024-11-08 01:48:00 +00:00
cyy
bf1b8adee6
Turn static inline into static function ( #139843 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139843
Approved by: https://github.com/ezyang
2024-11-07 23:58:18 +00:00
PyTorch MergeBot
68f1b52d8a
Revert "Turn static inline into static function ( #139843 )"
...
This reverts commit 72d3f5b26d .
Reverted https://github.com/pytorch/pytorch/pull/139843 on behalf of https://github.com/ZainRizvi due to Sorry but this is causing tests to fail on trunk. See [GH job link](https://github.com/pytorch/pytorch/actions/runs/11729669425/job/32675829894 ) [HUD commit link](72d3f5b26d ) ([comment](https://github.com/pytorch/pytorch/pull/139843#issuecomment-2463354131 ))
2024-11-07 22:29:45 +00:00
cyy
72d3f5b26d
Turn static inline into static function ( #139843 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139843
Approved by: https://github.com/ezyang
2024-11-07 19:08:41 +00:00
PyTorch MergeBot
7e02386303
Revert "[2/N] Replace c10::sv with std::sv ( #139456 )"
...
This reverts commit 028c5d3426 .
Reverted https://github.com/pytorch/pytorch/pull/139456 on behalf of https://github.com/ZainRizvi due to Sorry but this breaks internally. @ezyang can you please help get this landed? See D65546398 for more details ([comment](https://github.com/pytorch/pytorch/pull/139456#issuecomment-2462768891 ))
2024-11-07 17:00:59 +00:00
Nikita Shulga
c0c6bf4ef2
Don't use deprecated type properties in UpsampleKernel ( #139399 )
...
By replacing `at::CPU(dtype)` pattern with `at::device(kCPU).dtype(dtype)` pattern
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139399
Approved by: https://github.com/Skylion007
ghstack dependencies: #139353
2024-11-06 13:34:45 +00:00
PyTorch MergeBot
53299b8a38
Revert "Don't use deprecated type properties in UpsampleKernel ( #139399 )"
...
This reverts commit 0058f71002 .
Reverted https://github.com/pytorch/pytorch/pull/139399 on behalf of https://github.com/malfet due to And it was backed out again due to the internal usages of deprecated API ([comment](https://github.com/pytorch/pytorch/pull/139358#issuecomment-2459740090 ))
2024-11-06 13:23:43 +00:00
cyy
028c5d3426
[2/N] Replace c10::sv with std::sv ( #139456 )
...
Follows #139453
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139456
Approved by: https://github.com/ezyang
2024-11-06 01:50:38 +00:00
Nikita Shulga
0058f71002
Don't use deprecated type properties in UpsampleKernel ( #139399 )
...
By replacing `at::CPU(dtype)` pattern with `at::device(kCPU).dtype(dtype)` pattern
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139399
Approved by: https://github.com/Skylion007
ghstack dependencies: #139353 , #139358
2024-11-05 00:29:58 +00:00
PyTorch MergeBot
4a3ee96427
Revert "Don't use deprecated type properties in UpsampleKernel ( #139399 )"
...
This reverts commit 9d096e4d9f .
Reverted https://github.com/pytorch/pytorch/pull/139399 on behalf of https://github.com/ZainRizvi due to Change reverted internally due to broken builds. See D65378845 ([comment](https://github.com/pytorch/pytorch/pull/139358#issuecomment-2455959040 ))
2024-11-05 00:13:48 +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
Nikita Shulga
9d096e4d9f
Don't use deprecated type properties in UpsampleKernel ( #139399 )
...
By replacing `at::CPU(dtype)` pattern with `at::device(kCPU).dtype(dtype)` pattern
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139399
Approved by: https://github.com/Skylion007
ghstack dependencies: #139353 , #139358
2024-10-31 17:32:19 +00:00
cyy
0274d16c01
Fix clang-tidy warnings in jit code ( #138974 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138974
Approved by: https://github.com/ezyang
2024-10-29 04:33:40 +00:00
cyy
d8f99f39cb
Avoid unnecessary tensor constructions ( #139039 )
...
Because Variable is an alias of Tensor
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139039
Approved by: https://github.com/Skylion007
2024-10-29 02:23:23 +00:00
Richard Barnes
42994234a6
std::value/std::type -> std::_v/std::_t ( #138746 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138746
Approved by: https://github.com/cyyever , https://github.com/malfet
2024-10-26 20:59:24 +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
Nikita Shulga
c0879d0c21
Fix lint
...
Regression casued by fddabc6e0b that was force merged
2024-10-19 08:33:41 -07: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