dolpm
66f53889d5
[nativert] port semaphore to c10 util ( #153504 )
...
Summary:
nativert RFC: https://github.com/zhxchen17/rfcs/blob/master/RFC-0043-torch-native-runtime.md
To land the runtime into PyTorch core, we will gradually land logical parts of the code into the Github issue and get each piece properly reviewed.
This diff adds a simple semaphore interface into c10 until c++20 where we get counting_semaphore
gonna need a oss build export to take a look at this...
Test Plan: CI
Differential Revision: D73882656
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153504
Approved by: https://github.com/zhxchen17
2025-05-28 19:17:30 +00:00
Nikita Shulga
c4d1ff02f8
[Lint] Update clang-format to 19.1.4 ( #153889 )
...
All changes other than the one to `tools/linter/adapters/s3_init_config.json` are generated by newer clang-format
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153889
Approved by: https://github.com/cyyever , https://github.com/atalman
2025-05-20 14:12:46 +00:00
redwrasse
f7798d8645
Checks kv pair indexing in OrderedPreservingDictTest.test_range_insert ( #148136 )
...
`OrderedPreservingDictTest.test_range_insert` has an [unused loop variable `j`](https://github.com/pytorch/pytorch/blob/main/c10/test/util/ordered_preserving_dict_test.cpp#L186 ), I think taken from the [inspired project](https://github.com/pytorch/pytorch/blob/main/c10/test/util/ordered_preserving_dict_test.cpp#L165 ) testcase for range inserts, where it [checks kv pair indexing/order](https://github.com/Tessil/ordered-map/blob/master/tests/ordered_map_tests.cpp#L136 ) for the ordered dict.
This just adds in that functionality to the test case.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148136
Approved by: https://github.com/eellison
2025-05-14 06:05:23 +00:00
TJ Yin
81719ebde3
[caffe2] Make c10::str works with scoped enum ( #152705 ) ( #152714 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/152705
Test Plan:
```
buck2 test fbcode//caffe2/c10/test:util_base_tests --fail-fast
```
Differential Revision: D74087796
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152714
Approved by: https://github.com/Skylion007
2025-05-13 21:05:36 +00:00
Yiming Zhou
13fbf21a76
[nativert] Port string join and split to c10/util ( #152873 )
...
Summary:
Torch Native Runtime RFC: https://github.com/pytorch/rfcs/pull/72
Port string utils functions join and split to c10/util
Test Plan:
Added tests in `string_util_test.cpp`
buck2 run mode/opt caffe2/c10/test:util_base_tests
Differential Revision: D74202473
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152873
Approved by: https://github.com/cyyever , https://github.com/Skylion007
2025-05-07 03:58:11 +00:00
dolpm
a766c1d117
[nativert] move intrusive list to c10/util ( #152754 )
...
Summary:
nativert RFC: https://github.com/zhxchen17/rfcs/blob/master/RFC-0043-torch-native-runtime.md
To land the runtime into PyTorch core, we will gradually land logical parts of the code into the Github issue and get each piece properly reviewed.
This diff moves intrusive list to c10/util
Test Plan: CI
Differential Revision: D74104595
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152754
Approved by: https://github.com/Skylion007 , https://github.com/cyyever
2025-05-05 18:49:56 +00:00
dolpm
a765e2ddda
[nativert] port enumerate from folly to c10::utill ( #152481 )
...
Summary:
nativert RFC: https://github.com/zhxchen17/rfcs/blob/master/RFC-0043-torch-native-runtime.md
To land the runtime into PyTorch core, we will gradually land logical parts of the code into the Github issue and get each piece properly reviewed.
This diff ports an enumeration util from folly into c10.
Test Plan: CI
Differential Revision: D73881042
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152481
Approved by: https://github.com/Skylion007 , https://github.com/zhxchen17 , https://github.com/cyyever
2025-05-01 21:41:05 +00:00
Zhengxu Chen
5a66c1d921
[nativert] Add utility function to convert strings into numbers. ( #151467 )
...
Summary:
nativert RFC: https://github.com/zhxchen17/rfcs/blob/master/RFC-0043-torch-native-runtime.md
To land the runtime into PyTorch core, we will gradually land logical parts of the code into the Github issue and get each piece properly reviewed.
This diff adds a small library to convert strings into numbers which will later be used for parsing graph IR.
Differential Revision: D73133034
## Test Plan
c10 unittests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151467
Approved by: https://github.com/cyyever , https://github.com/albanD
2025-04-30 21:20:52 +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
Scott Wolchok
8eb21dffa9
consolidate ATen/test/dispatch_key_set_test.cpp with rest of DispatchKeySet tests ( #151697 )
...
Doesn't seem to be a reason to have two test files for this.
Differential Revision: [D73274020](https://our.internmc.facebook.com/intern/diff/D73274020/ )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151697
Approved by: https://github.com/Skylion007
ghstack dependencies: #151626 , #151627 , #151628 , #151629 , #151630
2025-04-21 02:58:12 +00:00
cyy
e66ad221e9
Use std::string_view in get_fully_qualified_type_name ( #145197 )
...
The same as #139164 but open a new PR due to messy history there.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145197
Approved by: https://github.com/r-barnes
2025-03-14 01:58:35 +00:00
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
203dd18c5c
Bump Clang-tidy to 19.1.4 ( #148648 )
...
Because Clang-tidy 19 has more powerful clang-analyzer checks to detect subtle bugs. New checks such as misc-use-internal-linkage can help identify potential static variables or functions, thus reducing binary sizes.
Some new checks are disabled temporarily for later enabling. Additional warnings have been fixed or suppressed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148648
Approved by: https://github.com/Skylion007
2025-03-10 17:32:30 +00:00
Scott Wolchok
84fcf1bb11
constexpr all the things in irange.h ( #147633 )
...
I got complaints while irangeifying some files in ExecuTorch
that irange could not be used in a constexpr function. This made the
complaints go away.
I added a constexpr function in irange_test that used to fail to build
with `error: variable of non-literal type 'iterator' (aka
'integer_iterator<int, true>') cannot be defined in a constexpr
function before C++23` and now builds fine.
Differential Revision: [D69959614](https://our.internmc.facebook.com/intern/diff/D69959614/ )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/147633
Approved by: https://github.com/albanD
2025-02-22 01:51:51 +00:00
cyy
c751541e79
Fix cppcoreguidelines-init-variables ignorance ( #141795 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141795
Approved by: https://github.com/albanD
2025-01-28 17:11:37 +00:00
Richard Barnes
1dab79470d
c10::string_view -> std::string_view in pytorch ( #143591 )
...
Test Plan: Sandcastle
Differential Revision: D67312322
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143591
Approved by: https://github.com/malfet
2025-01-13 21:44:05 +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
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
00b3b61076
Add and use thread-safe strerror ( #140472 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140472
Approved by: https://github.com/ezyang
2024-11-19 04:24:17 +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
Judicaël Clair
1c63612567
Fix & unit test for c10::ArrayRef constructed from user-defined types ( #139758 )
...
Fixes #139391
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139758
Approved by: https://github.com/ezyang
2024-11-06 04:23:05 +00:00
cyy
a2bc2e38f9
Use clang-tidy 17 ( #139678 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139678
Approved by: https://github.com/Skylion007
2024-11-05 16:00:25 +00:00
Huy Do
560a0704c5
Use a different test name for testConversionToStringView ( #139448 )
...
Summary:
The change comes from D65214804 (https://github.com/pytorch/pytorch/pull/139239 )
`buck2 test @//fbobjc/mode/buck2/ios-tests fbsource//xplat/caffe2/c10:c10_testApple` doesn't like having 2 `testConversionToString` in the same suite `StringViewTest`, so just need to use a different name there.
Test Plan: `buck2 test @//fbobjc/mode/buck2/ios-tests fbsource//xplat/caffe2/c10:c10_testApple` passes
Differential Revision: D65314266
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139448
Approved by: https://github.com/cyyever , https://github.com/malfet
2024-11-01 13:25:16 +00:00
cyy
4e5f9afc7f
Enable c10::sv and std::sv constexpr conversions ( #139239 )
...
As a small step towards moving c10::sv to std::sv and this tiny change shouldn't break META builds.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139239
Approved by: https://github.com/malfet
2024-10-30 03:57:47 +00:00
cyy
383d9e3de6
[4/N] Fix cppcoreguidelines-special-member-functions warnings ( #139027 )
...
Follows #138796
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139027
Approved by: https://github.com/ezyang
2024-10-29 00:18:18 +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
Mwiza Kunda
22d2e2d9a0
Set RUNPATH so installed tests can find the required shared libraries ( #136627 )
...
This change fixes the RUNPATH of installed c++ tests so that the linker can find the shared libraries they depend on.
For example, currently:
```bash
venv/lib/python3.10/site-packages/torch $ ./bin/test_lazy
./bin/test_lazy: error while loading shared libraries: libtorch.so: cannot open shared object file: No such file or directory
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136627
Approved by: https://github.com/malfet
2024-10-25 09:38:08 +00:00
Richard Barnes
e7d4de0e59
Eliminate C10_TYPENAME_CONSTEXPR ( #138702 )
...
Test Plan: Sandcastle
Differential Revision: D64833560
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138702
Approved by: https://github.com/malfet
2024-10-24 10:21:01 +00:00
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
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
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
Richard Barnes
8dd575faf6
[BE] Modernize C10_UNUSED ( #138102 )
...
[`[[maybe_unused]]`](https://en.cppreference.com/w/cpp/language/attributes/maybe_unused ) is part of C++17 standard
Test Plan: Sandcastle
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138102
Approved by: https://github.com/Skylion007 , https://github.com/albanD , https://github.com/malfet , https://github.com/eqy
2024-10-18 16:33:01 +00:00
Nikita Shulga
7711f00553
[BE] Delete unused operator!= from the test ( #138122 )
...
If method is unused, why not delete it altogether?
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138122
Approved by: https://github.com/swolchok
2024-10-17 02:24:48 +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
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
0c0d8c8ff0
[1/N] Fix extra warnings brought by clang-tidy-17 ( #137407 )
...
Before we can use clang-tidy-17
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137407
Approved by: https://github.com/Skylion007 , https://github.com/aaronenyeshi
2024-10-07 17:53:59 +00:00
cyy
47a78daf91
[Environment Variable][1/N] Use thread-safe env variable API in c10 ( #119449 )
...
This PR is the beginning of attempts to wrap thread-unsafe getenv and set_env functions inside a RW mutex.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/119449
Approved by: https://github.com/malfet , https://github.com/albanD , https://github.com/eqy
2024-10-01 06:24:30 +00:00
Yuanhao Ji
44dadf2506
[Fix] Check name when registering privateuse1 backend ( #134071 )
...
do some checks when registering privateuse1 backend to avoid using in-tree deivce names
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134071
Approved by: https://github.com/albanD
2024-08-27 20:28:30 +00:00
David Berard
84b3f1900a
C++ network flow implementation in c10 ( #132188 )
...
The functorch partitioners use network flow to split the joint graph into a forward and backward graph. Internally, we've found that upgrading to networkx 2.8.8 (from 2.5) results in some hard-to-debug failures (internal reference: https://fburl.com/workplace/jrqwagdm ). And I'm told that there's interest to remove the python dependency.
So this PR introduces a C++ implementation that mirrors the API provided by networkx. We'll need to add python bindings and do some additional testing to verify correctness.
Differential Revision: [D61550977](https://our.internmc.facebook.com/intern/diff/D61550977 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132188
Approved by: https://github.com/Chillee
2024-08-21 18:40:54 +00:00
PyTorch MergeBot
a0cb54ab46
Revert "C++ network flow implementation in c10 ( #132188 )"
...
This reverts commit e6272acaec .
Reverted https://github.com/pytorch/pytorch/pull/132188 on behalf of https://github.com/izaitsevfb due to breaks aps models and builds internally ([comment](https://github.com/pytorch/pytorch/pull/132188#issuecomment-2294120234 ))
2024-08-16 19:48:54 +00:00
David Berard
e6272acaec
C++ network flow implementation in c10 ( #132188 )
...
The functorch partitioners use network flow to split the joint graph into a forward and backward graph. Internally, we've found that upgrading to networkx 2.8.8 (from 2.5) results in some hard-to-debug failures (internal reference: https://fburl.com/workplace/jrqwagdm ). And I'm told that there's interest to remove the python dependency.
So this PR introduces a C++ implementation that mirrors the API provided by networkx. We'll need to add python bindings and do some additional testing to verify correctness.
Differential Revision: [D61284135](https://our.internmc.facebook.com/intern/diff/D61284135 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132188
Approved by: https://github.com/Chillee
2024-08-15 07:32:51 +00:00
Yuanhao Ji
343071cd96
Fix privateuse1 backend name case ( #132980 )
...
### Problem
`get_privateuse1_backend(bool lower_case)` always returns a lower case name and `lower_case` is not used.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132980
Approved by: https://github.com/albanD
2024-08-10 07:39:54 +00:00
PyTorch MergeBot
00097f3458
Revert "C++ network flow implementation in c10 ( #132188 )"
...
This reverts commit dccce77935 .
Reverted https://github.com/pytorch/pytorch/pull/132188 on behalf of https://github.com/ZainRizvi due to Sorry but this appears to be failing internal tests. Please see D60702564 to investigate ([comment](https://github.com/pytorch/pytorch/pull/132188#issuecomment-2267098420 ))
2024-08-03 18:44:28 +00:00
David Berard
dccce77935
C++ network flow implementation in c10 ( #132188 )
...
The functorch partitioners use network flow to split the joint graph into a forward and backward graph. Internally, we've found that upgrading to networkx 2.8.8 (from 2.5) results in some hard-to-debug failures (internal reference: https://fburl.com/workplace/jrqwagdm ). And I'm told that there's interest to remove the python dependency.
So this PR introduces a C++ implementation that mirrors the API provided by networkx. We'll need to add python bindings and do some additional testing to verify correctness.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132188
Approved by: https://github.com/Chillee
2024-08-02 20:30:59 +00:00
cyy
043e41f4f4
[10/N] Use std::nullopt and std::make_optional ( #132364 )
...
Follows #130674
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132364
Approved by: https://github.com/ezyang
2024-08-01 07:02:35 +00:00