Skip to content

Commit 30fb2c4

Browse files
suopytorchmergebot
authored andcommitted
[lint] autoformat test/cpp and torch/csrc
Let's have some fun. Pull Request resolved: pytorch#78828 Approved by: https://github.com/ezyang
1 parent 1ec30a6 commit 30fb2c4

File tree

564 files changed

+42007
-27159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

564 files changed

+42007
-27159
lines changed

.lintrunner.toml

+4-8
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,10 @@ include_patterns = [
4444
'aten/src/ATen/*.h',
4545
'c10/**/*.h',
4646
'c10/**/*.cpp',
47-
'torch/csrc/jit/**/*.h',
48-
'torch/csrc/jit/**/*.cpp',
49-
'torch/csrc/deploy/**/*.h',
50-
'torch/csrc/deploy/**/*.cpp',
51-
'test/cpp/jit/**/*.h',
52-
'test/cpp/jit/**/*.cpp',
53-
'test/cpp/tensorexpr/**/*.h',
54-
'test/cpp/tensorexpr/**/*.cpp',
47+
'torch/csrc/**/*.h',
48+
'torch/csrc/**/*.cpp',
49+
'test/cpp/**/*.h',
50+
'test/cpp/**/*.cpp',
5551
]
5652
exclude_patterns = [
5753
'c10/util/strong_type.h',

aten/src/ATen/autocast_mode.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <ATen/ATen.h>
4+
35
namespace at {
46
namespace autocast {
57

test/cpp/api/any.cpp

+44-21
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,35 @@ TEST_F(AnyModuleTest, WrongNumberOfArguments) {
100100
#endif
101101
ASSERT_THROWS_WITH(
102102
any.forward(),
103-
module_name + "'s forward() method expects 2 argument(s), but received 0. "
104-
"If " + module_name + "'s forward() method has default arguments, "
105-
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
103+
module_name +
104+
"'s forward() method expects 2 argument(s), but received 0. "
105+
"If " +
106+
module_name +
107+
"'s forward() method has default arguments, "
108+
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
106109
ASSERT_THROWS_WITH(
107110
any.forward(5),
108-
module_name + "'s forward() method expects 2 argument(s), but received 1. "
109-
"If " + module_name + "'s forward() method has default arguments, "
110-
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
111+
module_name +
112+
"'s forward() method expects 2 argument(s), but received 1. "
113+
"If " +
114+
module_name +
115+
"'s forward() method has default arguments, "
116+
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
111117
ASSERT_THROWS_WITH(
112118
any.forward(1, 2, 3),
113-
module_name + "'s forward() method expects 2 argument(s), but received 3.");
119+
module_name +
120+
"'s forward() method expects 2 argument(s), but received 3.");
114121
}
115122

116123
struct M_default_arg_with_macro : torch::nn::Module {
117124
double forward(int a, int b = 2, double c = 3.0) {
118125
return a + b + c;
119126
}
127+
120128
protected:
121-
FORWARD_HAS_DEFAULT_ARGS({1, torch::nn::AnyValue(2)}, {2, torch::nn::AnyValue(3.0)})
129+
FORWARD_HAS_DEFAULT_ARGS(
130+
{1, torch::nn::AnyValue(2)},
131+
{2, torch::nn::AnyValue(3.0)})
122132
};
123133

124134
struct M_default_arg_without_macro : torch::nn::Module {
@@ -127,7 +137,9 @@ struct M_default_arg_without_macro : torch::nn::Module {
127137
}
128138
};
129139

130-
TEST_F(AnyModuleTest, PassingArgumentsToModuleWithDefaultArgumentsInForwardMethod) {
140+
TEST_F(
141+
AnyModuleTest,
142+
PassingArgumentsToModuleWithDefaultArgumentsInForwardMethod) {
131143
{
132144
AnyModule any(M_default_arg_with_macro{});
133145

@@ -155,22 +167,32 @@ TEST_F(AnyModuleTest, PassingArgumentsToModuleWithDefaultArgumentsInForwardMetho
155167

156168
ASSERT_THROWS_WITH(
157169
any.forward(),
158-
module_name + "'s forward() method expects 3 argument(s), but received 0. "
159-
"If " + module_name + "'s forward() method has default arguments, "
160-
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
170+
module_name +
171+
"'s forward() method expects 3 argument(s), but received 0. "
172+
"If " +
173+
module_name +
174+
"'s forward() method has default arguments, "
175+
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
161176
ASSERT_THROWS_WITH(
162177
any.forward<double>(1),
163-
module_name + "'s forward() method expects 3 argument(s), but received 1. "
164-
"If " + module_name + "'s forward() method has default arguments, "
165-
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
178+
module_name +
179+
"'s forward() method expects 3 argument(s), but received 1. "
180+
"If " +
181+
module_name +
182+
"'s forward() method has default arguments, "
183+
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
166184
ASSERT_THROWS_WITH(
167185
any.forward<double>(1, 3),
168-
module_name + "'s forward() method expects 3 argument(s), but received 2. "
169-
"If " + module_name + "'s forward() method has default arguments, "
170-
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
186+
module_name +
187+
"'s forward() method expects 3 argument(s), but received 2. "
188+
"If " +
189+
module_name +
190+
"'s forward() method has default arguments, "
191+
"please make sure the forward() method is declared with a corresponding `FORWARD_HAS_DEFAULT_ARGS` macro.");
171192
ASSERT_THROWS_WITH(
172193
any.forward(1, 2, 3.0, 4),
173-
module_name + "'s forward() method expects 3 argument(s), but received 4.");
194+
module_name +
195+
"'s forward() method expects 3 argument(s), but received 4.");
174196
}
175197
}
176198

@@ -345,13 +367,14 @@ TEST_F(AnyValueTest, CorrectlyAccessesIntWhenCorrectType) {
345367
ASSERT_NE(value.try_get<int>(), nullptr);
346368
// const and non-const types have the same typeid(),
347369
// but casting Holder<int> to Holder<const int> is undefined
348-
// behavior according to UBSAN: https://github.com/pytorch/pytorch/issues/26964
370+
// behavior according to UBSAN:
371+
// https://github.com/pytorch/pytorch/issues/26964
349372
// ASSERT_NE(value.try_get<const int>(), nullptr);
350373
ASSERT_EQ(value.get<int>(), 5);
351374
}
352375
// This test does not work at all, because it looks like make_value
353376
// decays const int into int.
354-
//TEST_F(AnyValueTest, CorrectlyAccessesConstIntWhenCorrectType) {
377+
// TEST_F(AnyValueTest, CorrectlyAccessesConstIntWhenCorrectType) {
355378
// auto value = make_value<const int>(5);
356379
// ASSERT_NE(value.try_get<const int>(), nullptr);
357380
// // ASSERT_NE(value.try_get<int>(), nullptr);

0 commit comments

Comments
 (0)