diff --git a/aten/src/ATen/core/op_registration/kernel_function_legacy_test.cpp b/aten/src/ATen/core/op_registration/kernel_function_legacy_test.cpp index 687d5b59cda34..fd996e091aad8 100644 --- a/aten/src/ATen/core/op_registration/kernel_function_legacy_test.cpp +++ b/aten/src/ATen/core/op_registration/kernel_function_legacy_test.cpp @@ -803,9 +803,9 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenFallbackKernelWith EXPECT_EQ(4, outputs[0].toInt()); } -c10::optional called_arg2; -c10::optional called_arg3; -c10::optional called_arg4; +c10::optional called_arg2 = c10::nullopt; +c10::optional called_arg3 = c10::nullopt; +c10::optional called_arg4 = c10::nullopt; void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional& arg2, c10::optional arg3, c10::optional arg4) { called = true; diff --git a/aten/src/ATen/core/op_registration/kernel_function_test.cpp b/aten/src/ATen/core/op_registration/kernel_function_test.cpp index 6f8f1fe090e6a..4a216a45caf5c 100644 --- a/aten/src/ATen/core/op_registration/kernel_function_test.cpp +++ b/aten/src/ATen/core/op_registration/kernel_function_test.cpp @@ -526,9 +526,9 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenFallbackKernelWithoutTen EXPECT_EQ(4, outputs[0].toInt()); } -c10::optional called_arg2; -c10::optional called_arg3; -c10::optional called_arg4; +c10::optional called_arg2 = c10::nullopt; +c10::optional called_arg3 = c10::nullopt; +c10::optional called_arg4 = c10::nullopt; void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional& arg2, c10::optional arg3, c10::optional arg4) { called = true; diff --git a/aten/src/ATen/core/op_registration/kernel_functor_test.cpp b/aten/src/ATen/core/op_registration/kernel_functor_test.cpp index 66631fa4374c6..ce7e5d4eea4e4 100644 --- a/aten/src/ATen/core/op_registration/kernel_functor_test.cpp +++ b/aten/src/ATen/core/op_registration/kernel_functor_test.cpp @@ -675,9 +675,9 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenFallbackKernelWithoutTens EXPECT_EQ(4, outputs[0].toInt()); } -c10::optional called_arg2; -c10::optional called_arg3; -c10::optional called_arg4; +c10::optional called_arg2 = c10::nullopt; +c10::optional called_arg3 = c10::nullopt; +c10::optional called_arg4 = c10::nullopt; struct KernelWithOptInputWithoutOutput final : OperatorKernel { void operator()(Tensor arg1, const c10::optional& arg2, c10::optional arg3, c10::optional arg4) { diff --git a/aten/src/ATen/core/op_registration/kernel_lambda_legacy_test.cpp b/aten/src/ATen/core/op_registration/kernel_lambda_legacy_test.cpp index 73e0c1ac51719..d0dc2c4fd814e 100644 --- a/aten/src/ATen/core/op_registration/kernel_lambda_legacy_test.cpp +++ b/aten/src/ATen/core/op_registration/kernel_lambda_legacy_test.cpp @@ -729,9 +729,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithou TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) { bool called; - c10::optional called_arg2; - c10::optional called_arg3; - c10::optional called_arg4; + c10::optional called_arg2 = c10::nullopt; + c10::optional called_arg3 = c10::nullopt; + c10::optional called_arg4 = c10::nullopt; auto registrar = RegisterOperators().op( "_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()", @@ -768,9 +768,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) { bool called; - c10::optional called_arg2; - c10::optional called_arg3; - c10::optional called_arg4; + c10::optional called_arg2 = c10::nullopt; + c10::optional called_arg3 = c10::nullopt; + c10::optional called_arg4 = c10::nullopt; auto registrar = RegisterOperators().op( "_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?", @@ -810,9 +810,9 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) { bool called; - c10::optional called_arg2; - c10::optional called_arg3; - c10::optional called_arg4; + c10::optional called_arg2 = c10::nullopt; + c10::optional called_arg3 = c10::nullopt; + c10::optional called_arg4 = c10::nullopt; auto registrar = RegisterOperators().op( "_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)", diff --git a/aten/src/ATen/core/op_registration/kernel_lambda_test.cpp b/aten/src/ATen/core/op_registration/kernel_lambda_test.cpp index 49202b077e326..f6e4c06867cd8 100644 --- a/aten/src/ATen/core/op_registration/kernel_lambda_test.cpp +++ b/aten/src/ATen/core/op_registration/kernel_lambda_test.cpp @@ -461,9 +461,9 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutTenso EXPECT_EQ(4, outputs[0].toInt()); } -c10::optional called_arg2; -c10::optional called_arg3; -c10::optional called_arg4; +c10::optional called_arg2 = c10::nullopt; +c10::optional called_arg3 = c10::nullopt; +c10::optional called_arg4 = c10::nullopt; TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) { auto registrar = RegisterOperators().op( diff --git a/aten/src/ATen/core/op_registration/op_registration.h b/aten/src/ATen/core/op_registration/op_registration.h index daa7e7552a818..605317c8a5c41 100644 --- a/aten/src/ATen/core/op_registration/op_registration.h +++ b/aten/src/ATen/core/op_registration/op_registration.h @@ -425,7 +425,12 @@ class CAFFE2_API RegisterOperators final { ); } - Options() = default; + Options() + : schemaOrName_(c10::nullopt) + , legacyATenSchema_(c10::nullopt) + , kernels() + , aliasAnalysisKind_(c10::nullopt) + {} // KernelRegistrationConfig accumulates all information from the config // parameters passed to a RegisterOperators::op() call into one object. diff --git a/aten/src/ATen/core/op_registration/op_registration_test.cpp b/aten/src/ATen/core/op_registration/op_registration_test.cpp index 4bfc120a1092f..2c00c3f5aef22 100644 --- a/aten/src/ATen/core/op_registration/op_registration_test.cpp +++ b/aten/src/ATen/core/op_registration/op_registration_test.cpp @@ -818,28 +818,28 @@ TEST(OperatorRegistrationTest, testAvailableArgTypes) { // optional types (with has_value() == false) testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(float? a) -> float?"); testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(int? a) -> int?"); testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(bool? a) -> bool?"); testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(bool? a) -> bool?"); testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(str? a) -> str?"); testArgTypes>::test( - c10::optional(), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, - c10::optional(), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, + c10::optional(c10::nullopt), [] (const c10::optional& v) {EXPECT_FALSE(v.has_value());}, + c10::optional(c10::nullopt), [] (const IValue& v) {EXPECT_TRUE(v.isNone());}, "(Tensor? a) -> Tensor?");