From 32da5e9c3d36b81d7b72e039d1833b76f3abbe40 Mon Sep 17 00:00:00 2001 From: Tao Luo Date: Mon, 20 May 2019 15:34:06 +0800 Subject: [PATCH] remove unused expected_kernel_cache_pass (#17486) test=develop --- .../fluid/framework/details/build_strategy.cc | 6 --- .../fluid/framework/details/build_strategy.h | 1 - paddle/fluid/framework/ir/CMakeLists.txt | 1 - .../ir/expected_kernel_cache_pass.cc | 37 ------------------- .../framework/ir/expected_kernel_cache_pass.h | 31 ---------------- paddle/fluid/framework/operator.h | 6 --- paddle/fluid/inference/api/analysis_config.cc | 1 - .../inference/api/paddle_pass_builder.cc | 8 ++-- paddle/fluid/pybind/pybind.cc | 5 +-- 9 files changed, 4 insertions(+), 92 deletions(-) delete mode 100644 paddle/fluid/framework/ir/expected_kernel_cache_pass.cc delete mode 100644 paddle/fluid/framework/ir/expected_kernel_cache_pass.h diff --git a/paddle/fluid/framework/details/build_strategy.cc b/paddle/fluid/framework/details/build_strategy.cc index e55b354f193..b3710dea077 100644 --- a/paddle/fluid/framework/details/build_strategy.cc +++ b/paddle/fluid/framework/details/build_strategy.cc @@ -171,11 +171,6 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder { AppendPass("runtime_context_cache_pass"); } - if (strategy_.cache_expected_kernel_) { - VLOG(10) << "Add expected_kernel_cache_pass"; - AppendPass("expected_kernel_cache_pass"); - } - AppendMultiDevPass(strategy_); if (strategy_.fuse_all_reduce_ops_) { @@ -371,7 +366,6 @@ USE_PASS(fuse_sgd_op_pass); USE_PASS(fuse_momentum_op_pass); USE_PASS(fuse_all_reduce_op_pass); USE_PASS(runtime_context_cache_pass); -USE_PASS(expected_kernel_cache_pass); USE_PASS(record_skip_memory_opt_vars_pass); #ifdef PADDLE_WITH_MKLDNN USE_PASS(mkldnn_placement_pass); diff --git a/paddle/fluid/framework/details/build_strategy.h b/paddle/fluid/framework/details/build_strategy.h index 38cc00a1855..e7117b49c43 100644 --- a/paddle/fluid/framework/details/build_strategy.h +++ b/paddle/fluid/framework/details/build_strategy.h @@ -109,7 +109,6 @@ struct BuildStrategy { bool remove_unnecessary_lock_{true}; bool cache_runtime_context_{false}; - bool cache_expected_kernel_{true}; std::unordered_set mkldnn_enabled_op_types_; // NOTE: diff --git a/paddle/fluid/framework/ir/CMakeLists.txt b/paddle/fluid/framework/ir/CMakeLists.txt index 032fcbedf49..10eac94d797 100644 --- a/paddle/fluid/framework/ir/CMakeLists.txt +++ b/paddle/fluid/framework/ir/CMakeLists.txt @@ -72,7 +72,6 @@ pass_library(transpose_flatten_concat_fuse_pass inference) pass_library(identity_scale_op_clean_pass base) pass_library(sync_batch_norm_pass base) pass_library(runtime_context_cache_pass base) -pass_library(expected_kernel_cache_pass base) pass_library(quant_conv2d_dequant_fuse_pass inference) pass_library(fillconstant_elementwisemul_fuse inference) pass_library(shuffle_channel_detect_pass inference) diff --git a/paddle/fluid/framework/ir/expected_kernel_cache_pass.cc b/paddle/fluid/framework/ir/expected_kernel_cache_pass.cc deleted file mode 100644 index 4a99d4c1a9c..00000000000 --- a/paddle/fluid/framework/ir/expected_kernel_cache_pass.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -#include "paddle/fluid/framework/ir/expected_kernel_cache_pass.h" -#include -#include "paddle/fluid/framework/operator.h" - -namespace paddle { -namespace framework { -namespace ir { - -void ExpectedKernelCachePass::ApplyImpl(ir::Graph* graph) const { - VLOG(3) << "Applies Expected Kernel Cache strategy."; - for (const Node* n : graph->Nodes()) { - if (n->IsOp() && n->Op()) { - n->Op()->SetAttr(kEnableCacheExpectedKernel, true); - } - } -} - -} // namespace ir -} // namespace framework -} // namespace paddle - -REGISTER_PASS(expected_kernel_cache_pass, - paddle::framework::ir::ExpectedKernelCachePass); diff --git a/paddle/fluid/framework/ir/expected_kernel_cache_pass.h b/paddle/fluid/framework/ir/expected_kernel_cache_pass.h deleted file mode 100644 index bf0907d3feb..00000000000 --- a/paddle/fluid/framework/ir/expected_kernel_cache_pass.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -#pragma once - -#include -#include "paddle/fluid/framework/ir/pass.h" - -namespace paddle { -namespace framework { -namespace ir { - -class ExpectedKernelCachePass : public Pass { - protected: - void ApplyImpl(ir::Graph* graph) const override; -}; - -} // namespace ir -} // namespace framework -} // namespace paddle diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index 9090b7e1d13..0c8ab533fce 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -71,12 +71,6 @@ constexpr char kNewGradSuffix[] = "@NEWGRAD@"; /// this Op's execution to save the elapsed time. constexpr char kEnableCacheRuntimeContext[] = "@ENABLE_CACHE_RUNTIME_CONTEXT@"; -/// If an Op has attribtue kEnableCacheExpectedKernel, it means that in a same -/// name scope and same place, since the expected kerenl of this Op does not -/// change in the execution, it could be recorded only at the first iteration of -/// this Op's execution to save the elapsed time. -constexpr char kEnableCacheExpectedKernel[] = "@ENABLE_CACHE_EXPECTED_KERNEL@"; - /// If an Op has this attribute, all its kernels should calculate output /// variable's shape in the corresponding Compute() function. And /// OperatorWithKernel::RunImpl() would skip call this Op's InferShape() diff --git a/paddle/fluid/inference/api/analysis_config.cc b/paddle/fluid/inference/api/analysis_config.cc index 8b940b67e3f..4fe0c48d8f3 100644 --- a/paddle/fluid/inference/api/analysis_config.cc +++ b/paddle/fluid/inference/api/analysis_config.cc @@ -235,7 +235,6 @@ void AnalysisConfig::Update() { pass_builder()->InsertPass(3, "tensorrt_subgraph_pass"); } pass_builder()->DeletePass("runtime_context_cache_pass"); - pass_builder()->DeletePass("expected_kernel_cache_pass"); } if (use_mkldnn_) { diff --git a/paddle/fluid/inference/api/paddle_pass_builder.cc b/paddle/fluid/inference/api/paddle_pass_builder.cc index 2a7bd55a76e..914a07432e6 100644 --- a/paddle/fluid/inference/api/paddle_pass_builder.cc +++ b/paddle/fluid/inference/api/paddle_pass_builder.cc @@ -98,9 +98,8 @@ GpuPassStrategy::GpuPassStrategy() : PassStrategy({}) { "conv_elementwise_add_fuse_pass", // #endif // "transpose_flatten_concat_fuse_pass", - // following two passes should be located in the last, since they will + // following pass should be located in the last, since it will // work on all fused ops. - "expected_kernel_cache_pass", // "runtime_context_cache_pass" }); @@ -134,9 +133,8 @@ CpuPassStrategy::CpuPassStrategy() : PassStrategy({}) { "conv_bn_fuse_pass", // "conv_eltwiseadd_bn_fuse_pass", // "is_test_pass", // - // following two passes should be located in the last, since - // they will work on all fused ops. - "expected_kernel_cache_pass", // + // following pass should be located in the last, since + // it will work on all fused ops. "runtime_context_cache_pass"}); use_gpu_ = false; diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 6795621781f..c2b8e8874fc 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -18,6 +18,7 @@ limitations under the License. */ #include // NOLINT // for call_once #include #include +#include #include #include @@ -1492,10 +1493,6 @@ All parameter, weight, gradient are variables in Paddle. "cache_runtime_context", [](const BuildStrategy &self) { return self.cache_runtime_context_; }, [](BuildStrategy &self, bool b) { self.cache_runtime_context_ = b; }) - .def_property( - "cache_expected_kernel", - [](const BuildStrategy &self) { return self.cache_expected_kernel_; }, - [](BuildStrategy &self, bool b) { self.cache_expected_kernel_ = b; }) .def_property( "mkldnn_enabled_op_types", [](const BuildStrategy &self) { -- GitLab