mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Disable avoid-non-const-global-variables
lint check (#62008)
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
This commit is contained in:
committed by
Facebook GitHub Bot
parent
260198d42c
commit
a9b0a921d5
@ -39,7 +39,6 @@ static void checkRoundtrip(const std::string& s) {
|
||||
AT_ASSERT(original == parsed);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, Basic) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
std::unordered_map<std::string, Value*> vmap;
|
||||
@ -84,7 +83,6 @@ graph(%0 : Tensor, %1 : Tensor):
|
||||
AT_ASSERT(add->outputs() == std::vector<Value*>({t2}));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, NestedBlock) {
|
||||
checkRoundtrip(R"IR(
|
||||
graph():
|
||||
@ -100,7 +98,6 @@ graph():
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, If) {
|
||||
checkRoundtrip(R"IR(
|
||||
graph(%0 : Tensor,
|
||||
@ -121,7 +118,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, If2) {
|
||||
checkRoundtrip(R"IR(
|
||||
graph(%0 : Tensor,
|
||||
@ -142,7 +138,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, InferredTypeIsTensor) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
parseIR(
|
||||
@ -153,7 +148,6 @@ graph(%a):
|
||||
AT_ASSERT(graph->inputs()[0]->type()->isSubtypeOf(TensorType::get()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, ValueReuse) {
|
||||
// Check that parser correctly handles values reusing the same name.
|
||||
auto graph = std::make_shared<Graph>();
|
||||
@ -175,7 +169,6 @@ graph(%x):
|
||||
AT_ASSERT(b->outputs() == std::vector<Value*>({x2}));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, Attributes) {
|
||||
// Check that parser handles attributes and types.
|
||||
checkRoundtrip(
|
||||
@ -191,7 +184,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, OptionalTypes) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -203,7 +195,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, StarTensor) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -215,7 +206,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, UnshapedTensor) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -227,7 +217,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, ShapedTensor) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -239,7 +228,6 @@ graph(%0 : Tensor,
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, NestedContrainer) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -251,7 +239,6 @@ graph():
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, MalformedShapeAnnotation) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_ANY_THROW(checkRoundtrip(
|
||||
@ -264,7 +251,6 @@ graph(%0 : Tensor,
|
||||
)IR"));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, FileCheck) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
const std::string& text =
|
||||
@ -278,7 +264,6 @@ TEST(IRParserTest, FileCheck) {
|
||||
torch::jit::testing::FileCheck().run(text, *graph);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, Strides) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
std::unordered_map<std::string, Value*> vmap;
|
||||
@ -313,7 +298,6 @@ graph(%a : Float(4, 5),
|
||||
AT_ASSERT(c_type->strides().concrete_sizes() == c10::nullopt);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, MalformedStrides) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
std::unordered_map<std::string, Value*> vmap;
|
||||
@ -328,7 +312,6 @@ graph(%a : Float(4, strides=[5], 5)):
|
||||
vmap));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, TensorShapes) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -339,7 +322,6 @@ graph(%a : Float(4, 5),
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, DeviceAndRequiresGradTensors) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -357,7 +339,6 @@ graph(%a : Float(*, *, device=cpu),
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, ListConstant) {
|
||||
auto graph = std::make_shared<Graph>();
|
||||
parseIR(
|
||||
@ -380,7 +361,6 @@ graph():
|
||||
AT_ASSERT(int_vals[0] == 1 && int_vals[1] == 2 && int_vals[2] == 3);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, PartialStarTensor) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
@ -389,7 +369,6 @@ graph(%x : Float(10, *, 10)):
|
||||
)IR");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(IRParserTest, ComplexTensorAttributes) {
|
||||
checkRoundtrip(
|
||||
R"IR(
|
||||
|
Reference in New Issue
Block a user