diff --git a/onnxruntime/test/framework/inference_session_test.cc b/onnxruntime/test/framework/inference_session_test.cc index 7c0361fe15f4b..60effda9ec772 100644 --- a/onnxruntime/test/framework/inference_session_test.cc +++ b/onnxruntime/test/framework/inference_session_test.cc @@ -84,7 +84,7 @@ class FuseAdd : public OpKernel { explicit FuseAdd(const OpKernelInfo& info) : OpKernel(info) { // logic for testing that a session options config value can be read here auto test_throw_in_ctor = info.GetConfigOptions().GetConfigEntry("ThrowInKernelCtor"); - if (test_throw_in_ctor.has_value() && test_throw_in_ctor.value() == "1") { + if (test_throw_in_ctor == "1") { ORT_THROW("Test exception in ctor"); }; } diff --git a/onnxruntime/test/optimizer/cse_test.cc b/onnxruntime/test/optimizer/cse_test.cc index 7d62a032ede68..bad96406df845 100644 --- a/onnxruntime/test/optimizer/cse_test.cc +++ b/onnxruntime/test/optimizer/cse_test.cc @@ -282,7 +282,7 @@ TEST(CseTests, MergeConstants) { std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register(std::make_unique(), TransformerLevel::Level1)); - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), TransformerLevel::Level1)); diff --git a/onnxruntime/test/optimizer/graph_transform_test.cc b/onnxruntime/test/optimizer/graph_transform_test.cc index 6834cde2d6ffc..bf02c1741725f 100755 --- a/onnxruntime/test/optimizer/graph_transform_test.cc +++ b/onnxruntime/test/optimizer/graph_transform_test.cc @@ -579,7 +579,7 @@ TEST_F(GraphTransformationTests, ConstantFolding) { std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), TransformerLevel::Level1)); @@ -599,7 +599,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingNodesOnDifferentEP) { ASSERT_TRUE(op_to_count["Unsqueeze"] == 2); std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), @@ -630,7 +630,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingUnsupportedFloat16) { ASSERT_TRUE(op_to_count["Mul"] == 1); std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), TransformerLevel::Level1)); @@ -714,7 +714,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingSubgraph) { ASSERT_TRUE(op_to_count["Add"] == 2); // one in each subgraph std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), TransformerLevel::Level1)); @@ -739,7 +739,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingWithShapeToInitializer) { InlinedHashSet compatible_eps; InlinedHashSet excluded_initializers = {"matmul_weight"}; onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register( @@ -770,7 +770,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingWithScalarShapeToInitializer) { InlinedHashSet compatible_eps; onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register( @@ -799,7 +799,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingForOpsWithMissingOptionalInputs) InlinedHashSet compatible_eps; onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register( @@ -974,7 +974,7 @@ TEST_F(GraphTransformationTests, ConstantFolding_RemoveDanglingInputNodesToConst std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; ASSERT_STATUS_OK(graph_transformation_mgr.Register( std::make_unique(*e.get(), false /*skip_dequantize_linear*/, empty_config_options), TransformerLevel::Level1)); @@ -996,7 +996,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingAShapeNodeDeepInTheGraph) { ASSERT_TRUE(op_to_count["Shape"] == 4); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register( @@ -1025,7 +1025,7 @@ TEST_F(GraphTransformationTests, ConstantFoldingStringInitializer) { ASSERT_EQ(op_to_count["Identity"], 1); onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; std::unique_ptr e = std::make_unique(CPUExecutionProviderInfo()); ASSERT_STATUS_OK(graph_transformation_mgr.Register( diff --git a/onnxruntime/test/optimizer/optimizer_test.cc b/onnxruntime/test/optimizer/optimizer_test.cc index 448b2b18ebeb9..79704f2cc79e3 100644 --- a/onnxruntime/test/optimizer/optimizer_test.cc +++ b/onnxruntime/test/optimizer/optimizer_test.cc @@ -85,7 +85,7 @@ TEST(OptimizerTest, Basic) { OptimizerExecutionFrame frame(info, fetch_mlvalue_idxs); const logging::Logger& logger = DefaultLoggingManager().DefaultLogger(); - ConfigOptions empty_config_options; + const ConfigOptions empty_config_options; for (auto& node : graph.Nodes()) { auto kernel = info.CreateKernel(&node, empty_config_options); diff --git a/orttraining/orttraining/core/optimizer/graph_transformer_utils.cc b/orttraining/orttraining/core/optimizer/graph_transformer_utils.cc index 330a640b4737a..894fe3b052fb2 100644 --- a/orttraining/orttraining/core/optimizer/graph_transformer_utils.cc +++ b/orttraining/orttraining/core/optimizer/graph_transformer_utils.cc @@ -157,7 +157,7 @@ std::vector> GeneratePreTrainingTransformers( transformers.emplace_back(std::make_unique(compatible_eps)); } InlinedHashSet excluded_initializers(weights_to_train.begin(), weights_to_train.end()); - static ConfigOptions empty_config_options; + static const ConfigOptions empty_config_options; transformers.emplace_back(std::make_unique( execution_provider, false /*skip_dequantize_linear*/, empty_config_options, compatible_eps, excluded_initializers));