From 1ae26706588d4fcaa7e0c5ddb78c07cf07edffb8 Mon Sep 17 00:00:00 2001 From: Chunwei Date: Mon, 1 Jul 2019 08:50:24 +0000 Subject: [PATCH] some code clean --- paddle/fluid/lite/api/paddle_use_passes.h | 4 ++-- paddle/fluid/lite/core/mir/CMakeLists.txt | 4 ++-- paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc | 2 +- ...ast_transform_pass.cc => type_precision_cast_pass.cc} | 4 ++-- ..._cast_transform_pass.h => type_precision_cast_pass.h} | 0 ...target_transform_pass.cc => type_target_cast_pass.cc} | 4 ++-- ...e_target_transform_pass.h => type_target_cast_pass.h} | 0 .../lite/core/mir/variable_place_inference_pass_test.cc | 2 +- paddle/fluid/lite/core/optimizer.cc | 2 +- paddle/fluid/lite/core/optimizer.h | 8 ++++---- paddle/fluid/lite/core/type_system.h | 9 +++++---- paddle/fluid/lite/core/types.h | 4 ++-- paddle/fluid/lite/tools/debug/model_debug_tool.cc | 2 +- 13 files changed, 23 insertions(+), 22 deletions(-) rename paddle/fluid/lite/core/mir/{precision_cast_transform_pass.cc => type_precision_cast_pass.cc} (98%) rename paddle/fluid/lite/core/mir/{precision_cast_transform_pass.h => type_precision_cast_pass.h} (100%) rename paddle/fluid/lite/core/mir/{type_target_transform_pass.cc => type_target_cast_pass.cc} (97%) rename paddle/fluid/lite/core/mir/{type_target_transform_pass.h => type_target_cast_pass.h} (100%) diff --git a/paddle/fluid/lite/api/paddle_use_passes.h b/paddle/fluid/lite/api/paddle_use_passes.h index cae0bdd19e..b64f963813 100644 --- a/paddle/fluid/lite/api/paddle_use_passes.h +++ b/paddle/fluid/lite/api/paddle_use_passes.h @@ -18,7 +18,7 @@ USE_MIR_PASS(demo); USE_MIR_PASS(static_kernel_pick_pass); USE_MIR_PASS(variable_place_inference_pass); -USE_MIR_PASS(type_target_transform_pass); +USE_MIR_PASS(type_target_cast_pass); USE_MIR_PASS(generate_program_pass); USE_MIR_PASS(io_copy_kernel_pick_pass); USE_MIR_PASS(argument_type_display_pass); @@ -31,5 +31,5 @@ USE_MIR_PASS(identity_scale_eliminate_pass); USE_MIR_PASS(lite_conv_elementwise_add_activation_fuse_pass); USE_MIR_PASS(lite_elementwise_add_activation_fuse_pass); USE_MIR_PASS(lite_quant_dequant_fuse_pass); -USE_MIR_PASS(precision_cast_transform_pass); +USE_MIR_PASS(type_precision_cast_pass); USE_MIR_PASS(trans_weight_pass); diff --git a/paddle/fluid/lite/core/mir/CMakeLists.txt b/paddle/fluid/lite/core/mir/CMakeLists.txt index 647336a421..92a31f4532 100644 --- a/paddle/fluid/lite/core/mir/CMakeLists.txt +++ b/paddle/fluid/lite/core/mir/CMakeLists.txt @@ -17,8 +17,8 @@ lite_cc_library(mir_passes elimination/identity_scale_eliminate_pass.cc static_kernel_pick_pass.cc variable_place_inference_pass.cc - type_target_transform_pass.cc - precision_cast_transform_pass.cc + type_target_cast_pass.cc + type_precision_cast_pass.cc io_copy_kernel_pick_pass.cc graph_visualize_pass.cc generate_program_pass.cc diff --git a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc index 620aa48fdb..d703db1f3d 100644 --- a/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc +++ b/paddle/fluid/lite/core/mir/static_kernel_pick_pass.cc @@ -29,7 +29,7 @@ bool KernelScoreCmp(const std::pair>& a, } void StaticKernelPickPass::Apply(const std::unique_ptr& graph) { - CHECK(kernel_pick_factors_.AnyFactorConsidered()) + CHECK(kernel_pick_factors_.any_factor_considered()) << "kernel_pick_factors should be specified first"; CHECK(graph) << "graph not valid"; // sort kernels by the factors. diff --git a/paddle/fluid/lite/core/mir/precision_cast_transform_pass.cc b/paddle/fluid/lite/core/mir/type_precision_cast_pass.cc similarity index 98% rename from paddle/fluid/lite/core/mir/precision_cast_transform_pass.cc rename to paddle/fluid/lite/core/mir/type_precision_cast_pass.cc index e75fd1863d..c424b2f238 100644 --- a/paddle/fluid/lite/core/mir/precision_cast_transform_pass.cc +++ b/paddle/fluid/lite/core/mir/type_precision_cast_pass.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/lite/core/mir/precision_cast_transform_pass.h" +#include "paddle/fluid/lite/core/mir/type_precision_cast_pass.h" #include #include #include @@ -162,5 +162,5 @@ void PrecisionCastPass::SetValidPlaces(const std::vector& valid_places) { } // namespace lite } // namespace paddle -REGISTER_MIR_PASS(precision_cast_transform_pass, +REGISTER_MIR_PASS(type_precision_cast_pass, paddle::lite::mir::PrecisionCastPass); diff --git a/paddle/fluid/lite/core/mir/precision_cast_transform_pass.h b/paddle/fluid/lite/core/mir/type_precision_cast_pass.h similarity index 100% rename from paddle/fluid/lite/core/mir/precision_cast_transform_pass.h rename to paddle/fluid/lite/core/mir/type_precision_cast_pass.h diff --git a/paddle/fluid/lite/core/mir/type_target_transform_pass.cc b/paddle/fluid/lite/core/mir/type_target_cast_pass.cc similarity index 97% rename from paddle/fluid/lite/core/mir/type_target_transform_pass.cc rename to paddle/fluid/lite/core/mir/type_target_cast_pass.cc index 93ac94b389..1d8095cb63 100644 --- a/paddle/fluid/lite/core/mir/type_target_transform_pass.cc +++ b/paddle/fluid/lite/core/mir/type_target_cast_pass.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/lite/core/mir/type_target_transform_pass.h" +#include "paddle/fluid/lite/core/mir/type_target_cast_pass.h" #include #include #include @@ -142,5 +142,5 @@ void TypeTargetTransformPass::SetValidPlaces( } // namespace lite } // namespace paddle -REGISTER_MIR_PASS(type_target_transform_pass, +REGISTER_MIR_PASS(type_target_cast_pass, paddle::lite::mir::TypeTargetTransformPass); diff --git a/paddle/fluid/lite/core/mir/type_target_transform_pass.h b/paddle/fluid/lite/core/mir/type_target_cast_pass.h similarity index 100% rename from paddle/fluid/lite/core/mir/type_target_transform_pass.h rename to paddle/fluid/lite/core/mir/type_target_cast_pass.h diff --git a/paddle/fluid/lite/core/mir/variable_place_inference_pass_test.cc b/paddle/fluid/lite/core/mir/variable_place_inference_pass_test.cc index 808835a6f6..aeffdd2eec 100644 --- a/paddle/fluid/lite/core/mir/variable_place_inference_pass_test.cc +++ b/paddle/fluid/lite/core/mir/variable_place_inference_pass_test.cc @@ -60,7 +60,7 @@ TEST(variable_place_inference_pass, test) { "argument_type_display_pass", // "variable_place_inference_pass", // "argument_type_display_pass", // - "type_target_transform_pass", // + "type_target_cast_pass", // }); Place prefered_place{ diff --git a/paddle/fluid/lite/core/optimizer.cc b/paddle/fluid/lite/core/optimizer.cc index 1502d15e2b..0c08688aa7 100644 --- a/paddle/fluid/lite/core/optimizer.cc +++ b/paddle/fluid/lite/core/optimizer.cc @@ -15,7 +15,7 @@ #include "paddle/fluid/lite/core/optimizer.h" #include #include "paddle/fluid/lite/core/mir/static_kernel_pick_pass.h" -#include "paddle/fluid/lite/core/mir/type_target_transform_pass.h" +#include "paddle/fluid/lite/core/mir/type_target_cast_pass.h" #include "paddle/fluid/lite/model_parser/model_parser.h" #include "paddle/fluid/lite/utils/all.h" diff --git a/paddle/fluid/lite/core/optimizer.h b/paddle/fluid/lite/core/optimizer.h index 437eec50dc..7c6e4a2dff 100644 --- a/paddle/fluid/lite/core/optimizer.h +++ b/paddle/fluid/lite/core/optimizer.h @@ -20,7 +20,7 @@ #include "paddle/fluid/lite/core/mir/pass_manager.h" #include "paddle/fluid/lite/core/mir/ssa_graph.h" #include "paddle/fluid/lite/core/mir/static_kernel_pick_pass.h" -#include "paddle/fluid/lite/core/mir/type_target_transform_pass.h" +#include "paddle/fluid/lite/core/mir/type_target_cast_pass.h" #include "paddle/fluid/lite/core/program.h" #include "paddle/fluid/lite/core/types.h" #include "paddle/fluid/lite/model_parser/model_parser.h" @@ -70,12 +70,12 @@ class Optimizer { "static_kernel_pick_pass", // "variable_place_inference_pass", // "argument_type_display_pass", // - "type_target_transform_pass", // + "type_target_cast_pass", // "variable_place_inference_pass", // "argument_type_display_pass", // "io_copy_kernel_pick_pass", // "variable_place_inference_pass", // - "precision_cast_transform_pass", // + "type_precision_cast_pass", // "argument_type_display_pass", // "trans_weight_pass", // "runtime_context_assign_pass", // @@ -109,7 +109,7 @@ class Optimizer { void InitTargetTypeTransformPass() { auto* pass = mir::PassManager::Global().LookUp( - "type_target_transform_pass"); + "type_target_cast_pass"); CHECK(pass); CHECK(!valid_places_.empty()); LOG(INFO) << "valid_places.size " << valid_places_.size(); diff --git a/paddle/fluid/lite/core/type_system.h b/paddle/fluid/lite/core/type_system.h index 8bd1f37394..d8b88f8e26 100644 --- a/paddle/fluid/lite/core/type_system.h +++ b/paddle/fluid/lite/core/type_system.h @@ -34,11 +34,12 @@ namespace lite { // Type is the definition of all the types that supported by the Variable that // represents as the input and output of an operator or kernel. -// The DNN system is simple, and the architecture can not process that many data -// types as a compiler, or that will turn out to a chaos. +// The DNN system is simple, just a list of operators, and the architecture +// can not process that many data types as a compiler, or that will turn out to +// a chaos. // // We should make sure that the supported data types be registered here, and -// keep the quantity small and avoid using some special data types as op's +// keep the set small and avoid using some special data types as op's // inputs or outputs, such as some runtime cache, those types can't be processed // by the MIR. // @@ -51,7 +52,7 @@ namespace lite { // transforming operators, for example, a DataLayoutTransformOp can convert a // `TensorFp32NCHWTy` to a `TensorFp32NHWCTy`; a IoCopyOp can convert a // `TensorFp32NCHWTy(kHost)` to `TensorFp32NCHWTy(kCUDA)`. There are many other -// convertions between different Types, but there are some unsupportted type +// convertions between different Types, but there are some unsupported type // convertions, for example, there is noway to convert a `UnsupportedTy` to a // `TensorAnyTy`. // diff --git a/paddle/fluid/lite/core/types.h b/paddle/fluid/lite/core/types.h index 810901d15b..50c3d69d85 100644 --- a/paddle/fluid/lite/core/types.h +++ b/paddle/fluid/lite/core/types.h @@ -36,10 +36,10 @@ class KernelPickFactor { }; // Has any factors considered. - bool AnyFactorConsidered() const { return data_; } + bool any_factor_considered() const { return data_; } KernelPickFactor& ConsiderTarget(); - // Perfer a specific target, e.g. prefer CUDA kernels. + // Prefer a specific target, e.g. prefer CUDA kernels. KernelPickFactor& ConsiderPrecision(); KernelPickFactor& ConsiderDataLayout(); KernelPickFactor& ConsiderDevice(); diff --git a/paddle/fluid/lite/tools/debug/model_debug_tool.cc b/paddle/fluid/lite/tools/debug/model_debug_tool.cc index 00552f18fd..7e8556a157 100644 --- a/paddle/fluid/lite/tools/debug/model_debug_tool.cc +++ b/paddle/fluid/lite/tools/debug/model_debug_tool.cc @@ -46,7 +46,7 @@ void Run(DebugConfig* conf) { std::vector passes{{ "static_kernel_pick_pass", "variable_place_inference_pass", - "type_target_transform_pass", "variable_place_inference_pass", + "type_target_cast_pass", "variable_place_inference_pass", "io_copy_kernel_pick_pass", "variable_place_inference_pass", "runtime_context_assign_pass", }}; -- GitLab