Skip to content

Commit a2e5445

Browse files
smessmerfacebook-github-bot
authored andcommitted
Fix Windows build (#26246)
Summary: Pull Request resolved: #26246 Broken due to #12117. Try fixing it. ghstack-source-id: 90137033 Test Plan: waitforsandcastle Reviewed By: zou3519 Differential Revision: D17387317 fbshipit-source-id: 705998c0b1608668d510b47f4fe20cecf5057c5f
1 parent b6b2b4c commit a2e5445

File tree

7 files changed

+39
-34
lines changed

7 files changed

+39
-34
lines changed

aten/src/ATen/core/op_registration/kernel_function_legacy_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,9 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenFallbackKernelWith
803803
EXPECT_EQ(4, outputs[0].toInt());
804804
}
805805

806-
c10::optional<Tensor> called_arg2;
807-
c10::optional<int64_t> called_arg3;
808-
c10::optional<std::string> called_arg4;
806+
c10::optional<Tensor> called_arg2 = c10::nullopt;
807+
c10::optional<int64_t> called_arg3 = c10::nullopt;
808+
c10::optional<std::string> called_arg4 = c10::nullopt;
809809

810810
void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& arg2, c10::optional<int64_t> arg3, c10::optional<std::string> arg4) {
811811
called = true;

aten/src/ATen/core/op_registration/kernel_function_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,9 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenFallbackKernelWithoutTen
526526
EXPECT_EQ(4, outputs[0].toInt());
527527
}
528528

529-
c10::optional<Tensor> called_arg2;
530-
c10::optional<int64_t> called_arg3;
531-
c10::optional<std::string> called_arg4;
529+
c10::optional<Tensor> called_arg2 = c10::nullopt;
530+
c10::optional<int64_t> called_arg3 = c10::nullopt;
531+
c10::optional<std::string> called_arg4 = c10::nullopt;
532532

533533
void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& arg2, c10::optional<int64_t> arg3, c10::optional<std::string> arg4) {
534534
called = true;

aten/src/ATen/core/op_registration/kernel_functor_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,9 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenFallbackKernelWithoutTens
675675
EXPECT_EQ(4, outputs[0].toInt());
676676
}
677677

678-
c10::optional<Tensor> called_arg2;
679-
c10::optional<int64_t> called_arg3;
680-
c10::optional<std::string> called_arg4;
678+
c10::optional<Tensor> called_arg2 = c10::nullopt;
679+
c10::optional<int64_t> called_arg3 = c10::nullopt;
680+
c10::optional<std::string> called_arg4 = c10::nullopt;
681681

682682
struct KernelWithOptInputWithoutOutput final : OperatorKernel {
683683
void operator()(Tensor arg1, const c10::optional<Tensor>& arg2, c10::optional<int64_t> arg3, c10::optional<std::string> arg4) {

aten/src/ATen/core/op_registration/kernel_lambda_legacy_test.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithou
729729

730730
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
731731
bool called;
732-
c10::optional<Tensor> called_arg2;
733-
c10::optional<int64_t> called_arg3;
734-
c10::optional<std::string> called_arg4;
732+
c10::optional<Tensor> called_arg2 = c10::nullopt;
733+
c10::optional<int64_t> called_arg3 = c10::nullopt;
734+
c10::optional<std::string> called_arg4 = c10::nullopt;
735735

736736
auto registrar = RegisterOperators().op(
737737
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()",
@@ -768,9 +768,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn
768768

769769
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
770770
bool called;
771-
c10::optional<Tensor> called_arg2;
772-
c10::optional<int64_t> called_arg3;
773-
c10::optional<std::string> called_arg4;
771+
c10::optional<Tensor> called_arg2 = c10::nullopt;
772+
c10::optional<int64_t> called_arg3 = c10::nullopt;
773+
c10::optional<std::string> called_arg4 = c10::nullopt;
774774

775775
auto registrar = RegisterOperators().op(
776776
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?",
@@ -810,9 +810,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn
810810

811811
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
812812
bool called;
813-
c10::optional<Tensor> called_arg2;
814-
c10::optional<int64_t> called_arg3;
815-
c10::optional<std::string> called_arg4;
813+
c10::optional<Tensor> called_arg2 = c10::nullopt;
814+
c10::optional<int64_t> called_arg3 = c10::nullopt;
815+
c10::optional<std::string> called_arg4 = c10::nullopt;
816816

817817
auto registrar = RegisterOperators().op(
818818
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)",

aten/src/ATen/core/op_registration/kernel_lambda_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutTenso
461461
EXPECT_EQ(4, outputs[0].toInt());
462462
}
463463

464-
c10::optional<Tensor> called_arg2;
465-
c10::optional<int64_t> called_arg3;
466-
c10::optional<std::string> called_arg4;
464+
c10::optional<Tensor> called_arg2 = c10::nullopt;
465+
c10::optional<int64_t> called_arg3 = c10::nullopt;
466+
c10::optional<std::string> called_arg4 = c10::nullopt;
467467

468468
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
469469
auto registrar = RegisterOperators().op(

aten/src/ATen/core/op_registration/op_registration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ class CAFFE2_API RegisterOperators final {
425425
);
426426
}
427427

428-
Options() = default;
428+
Options()
429+
: schemaOrName_(c10::nullopt)
430+
, legacyATenSchema_(c10::nullopt)
431+
, kernels()
432+
, aliasAnalysisKind_(c10::nullopt)
433+
{}
429434

430435
// KernelRegistrationConfig accumulates all information from the config
431436
// parameters passed to a RegisterOperators::op() call into one object.

aten/src/ATen/core/op_registration/op_registration_test.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -818,28 +818,28 @@ TEST(OperatorRegistrationTest, testAvailableArgTypes) {
818818

819819
// optional types (with has_value() == false)
820820
testArgTypes<c10::optional<double>>::test(
821-
c10::optional<double>(), [] (const c10::optional<double>& v) {EXPECT_FALSE(v.has_value());},
822-
c10::optional<double>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
821+
c10::optional<double>(c10::nullopt), [] (const c10::optional<double>& v) {EXPECT_FALSE(v.has_value());},
822+
c10::optional<double>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
823823
"(float? a) -> float?");
824824
testArgTypes<c10::optional<int64_t>>::test(
825-
c10::optional<int64_t>(), [] (const c10::optional<int64_t>& v) {EXPECT_FALSE(v.has_value());},
826-
c10::optional<int64_t>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
825+
c10::optional<int64_t>(c10::nullopt), [] (const c10::optional<int64_t>& v) {EXPECT_FALSE(v.has_value());},
826+
c10::optional<int64_t>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
827827
"(int? a) -> int?");
828828
testArgTypes<c10::optional<bool>>::test(
829-
c10::optional<bool>(), [] (const c10::optional<bool>& v) {EXPECT_FALSE(v.has_value());},
830-
c10::optional<bool>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
829+
c10::optional<bool>(c10::nullopt), [] (const c10::optional<bool>& v) {EXPECT_FALSE(v.has_value());},
830+
c10::optional<bool>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
831831
"(bool? a) -> bool?");
832832
testArgTypes<c10::optional<bool>>::test(
833-
c10::optional<bool>(), [] (const c10::optional<bool>& v) {EXPECT_FALSE(v.has_value());},
834-
c10::optional<bool>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
833+
c10::optional<bool>(c10::nullopt), [] (const c10::optional<bool>& v) {EXPECT_FALSE(v.has_value());},
834+
c10::optional<bool>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
835835
"(bool? a) -> bool?");
836836
testArgTypes<c10::optional<std::string>>::test(
837-
c10::optional<std::string>(), [] (const c10::optional<std::string>& v) {EXPECT_FALSE(v.has_value());},
838-
c10::optional<std::string>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
837+
c10::optional<std::string>(c10::nullopt), [] (const c10::optional<std::string>& v) {EXPECT_FALSE(v.has_value());},
838+
c10::optional<std::string>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
839839
"(str? a) -> str?");
840840
testArgTypes<c10::optional<Tensor>>::test(
841-
c10::optional<Tensor>(), [] (const c10::optional<Tensor>& v) {EXPECT_FALSE(v.has_value());},
842-
c10::optional<Tensor>(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
841+
c10::optional<Tensor>(c10::nullopt), [] (const c10::optional<Tensor>& v) {EXPECT_FALSE(v.has_value());},
842+
c10::optional<Tensor>(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());},
843843
"(Tensor? a) -> Tensor?");
844844

845845

0 commit comments

Comments
 (0)