From 5c7c6b1e83a8bf546a96f484fb1fdb95a94435b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=99=93=E4=BC=9F?= <39303645+Shixiaowei02@users.noreply.github.com> Date: Tue, 3 Dec 2019 11:29:06 +0800 Subject: [PATCH] revert ProgOptimUnsupported check, test=release/1.6 (#21475) --- paddle/fluid/framework/op_compatible_info.cc | 45 ------------------- paddle/fluid/framework/op_compatible_info.h | 5 --- .../fluid/inference/api/analysis_predictor.cc | 8 ---- 3 files changed, 58 deletions(-) diff --git a/paddle/fluid/framework/op_compatible_info.cc b/paddle/fluid/framework/op_compatible_info.cc index d0702081d1..934f682811 100644 --- a/paddle/fluid/framework/op_compatible_info.cc +++ b/paddle/fluid/framework/op_compatible_info.cc @@ -215,50 +215,5 @@ bool OpCompatibleMap::ReadFromProto(const proto::OpCompatibleMap& desc) { return true; } -bool ProgOptimUnsupported(std::shared_ptr program) { - auto op_type_checker = [](const std::string& name) { - const std::vector op_types({ - "conv2d", "conv3d", "conv2d_transpose", "conv3d_transpose", - "depthwise_conv2d", "depthwise_conv2d_transpose", "pool2d", "pool3d", - }); - return std::find(op_types.begin(), op_types.end(), name) != op_types.end(); - }; - auto checker = [](const framework::OpDesc& op) { - if (op.HasAttr("paddings") && op.HasAttr("strides")) { - auto paddings = boost::get>(op.GetAttr("paddings")); - auto strides = boost::get>(op.GetAttr("strides")); - if (paddings.size() != strides.size()) { - VLOG(3) << "== paddings size is not equal to strides size."; - return true; - } - } - if (op.HasAttr("data_format")) { - auto data_format = boost::get(op.GetAttr("data_format")); - if (data_format == "NHWC" || data_format == "NDHWC") { - VLOG(3) << "== data_format is NHWC or NDHWC."; - return true; - } - } - if (op.HasAttr("padding_algorithm")) { - auto padding_algorithm = - boost::get(op.GetAttr("padding_algorithm")); - if (padding_algorithm != "EXPLICIT") { - VLOG(3) << "== padding_algorithm is not EXPLICIT."; - return true; - } - } - return false; - }; - for (size_t i = 0; i < program->Size(); i++) { - const auto& block = program->Block(i); - for (auto* op : block.AllOps()) { - if ((op_type_checker(op->Type())) && checker(*op)) { - return true; - } - } - } - return false; -} - } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/op_compatible_info.h b/paddle/fluid/framework/op_compatible_info.h index e72d206b14..08b5734b5b 100644 --- a/paddle/fluid/framework/op_compatible_info.h +++ b/paddle/fluid/framework/op_compatible_info.h @@ -13,7 +13,6 @@ // limitations under the License. #include -#include #include #include "paddle/fluid/framework/program_desc.h" @@ -71,9 +70,5 @@ class OpCompatibleMap { std::string default_required_version_; }; -// Determine if the model contains operators that the optimization cannot -// support. -bool ProgOptimUnsupported(std::shared_ptr program); - } // namespace framework } // namespace paddle diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index 4f632946f3..90d4444acc 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -458,14 +458,6 @@ void AnalysisPredictor::PrepareArgument() { // NOTE All the members in AnalysisConfig should be copied to Argument. void AnalysisPredictor::OptimizeInferenceProgram() { - if (ProgOptimUnsupported(inference_program_)) { - LOG(INFO) << "NOTICE: Your inference model contains parameters such " - "as asymmetric padding, and ir optimization is temporarily " - "not supported, " - "so it is turned off."; - config_.SwitchIrOptim(false); - argument_.SetEnableAnalysisOptim(false); - } PrepareArgument(); Analyzer().Run(&argument_); -- GitLab