From 6e9ed17adc28a4e62516d24b8c85f2109cb4cfda Mon Sep 17 00:00:00 2001 From: Du Li Date: Tue, 2 Apr 2019 21:48:06 -0700 Subject: [PATCH] Fix a shape inference bug for FusedConv and MaxpoolWithMask (#748) --- onnxruntime/core/graph/contrib_ops/contrib_defs.cc | 4 ++-- onnxruntime/core/optimizer/graph_transformer_utils.cc | 3 ++- onnxruntime/test/optimizer/graph_transform_test.cc | 9 ++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc index 8a47edb765..e84af1256e 100644 --- a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc +++ b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc @@ -385,7 +385,7 @@ Sample echo operator.)DOC"); "T") .TypeConstraint("T", {"tensor(float)"}, "Constrain input0 and output types to float tensors") .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { - ONNX_NAMESPACE::convPoolTypeAndShapeInference(ctx, true, false); + ONNX_NAMESPACE::convPoolTypeAndShapeInference(ctx, false, true); }); ONNX_CONTRIB_OPERATOR_SCHEMA(FusedConv) @@ -447,7 +447,7 @@ activation.)DOC") "T") .TypeConstraint("T", {"tensor(float16)", "tensor(float)", "tensor(double)"}, "Constrain input and output types to float tensors") .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { - ONNX_NAMESPACE::convPoolTypeAndShapeInference(ctx, false, true); + ONNX_NAMESPACE::convPoolTypeAndShapeInference(ctx, true, false); }); ONNX_CONTRIB_OPERATOR_SCHEMA(FusedGemm) diff --git a/onnxruntime/core/optimizer/graph_transformer_utils.cc b/onnxruntime/core/optimizer/graph_transformer_utils.cc index c668deffa7..4fa39a46d4 100644 --- a/onnxruntime/core/optimizer/graph_transformer_utils.cc +++ b/onnxruntime/core/optimizer/graph_transformer_utils.cc @@ -57,7 +57,7 @@ std::unique_ptr GenerateRuleBasedGraphTransformer(Tra std::unique_ptr rule_transformer = std::make_unique(transformer_utils::GenerateRuleBasedTransformerName(level), - "Apply rewrite rules for Level" + + "Apply rewrite rules for Level" + std::to_string(static_cast(level)), compatible_execution_providers); for (auto& entry : rewrite_rules_to_register) { @@ -97,6 +97,7 @@ std::vector> GenerateTransformers(TransformerL } transformers.emplace_back(std::make_unique(l2_execution_providers)); transformers.emplace_back(std::make_unique(l2_execution_providers)); + transformers.emplace_back(std::make_unique(l2_execution_providers)); transformers.emplace_back(std::make_unique()); transformers.emplace_back(std::make_unique()); transformers.emplace_back(std::make_unique()); diff --git a/onnxruntime/test/optimizer/graph_transform_test.cc b/onnxruntime/test/optimizer/graph_transform_test.cc index 75aea559be..932fcb899b 100644 --- a/onnxruntime/test/optimizer/graph_transform_test.cc +++ b/onnxruntime/test/optimizer/graph_transform_test.cc @@ -149,11 +149,10 @@ TEST(GraphTransformationTests, FuseConvBNMulAddUnsqueeze) { } TEST(GraphTransformationTests, FuseConvActivation) { - - std::unordered_map model_to_op_name {{"fusion/conv_relu.onnx", "Relu"}, - {"fusion/conv_sigmoid.onnx", "Sigmoid"}, - {"fusion/conv_tanh.onnx", "Tanh"}, - {"fusion/conv_leakyrelu.onnx", "LeakyRelu"}}; + std::unordered_map model_to_op_name{{"fusion/conv_relu.onnx", "Relu"}, + {"fusion/conv_sigmoid.onnx", "Sigmoid"}, + {"fusion/conv_tanh.onnx", "Tanh"}, + {"fusion/conv_leakyrelu.onnx", "LeakyRelu"}}; for (const auto& model : model_to_op_name) { std::string model_uri = MODEL_FOLDER + model.first;