From 8d67748ef1a30575f49f5bb0a536d0be3a0176dd Mon Sep 17 00:00:00 2001 From: TR666 Date: Wed, 3 Jan 2024 16:21:40 +0800 Subject: [PATCH] adjust pass order and follow naming conventions --- paddle/fluid/framework/ir/CMakeLists.txt | 2 +- ....cc => decoder_attention_xpu_fuse_pass.cc} | 28 +++++++++---------- ...ss.h => decoder_attention_xpu_fuse_pass.h} | 4 +-- .../inference/api/paddle_pass_builder.cc | 2 +- ...st_xpu_decoder_attention_xpu_fuse_pass.py} | 4 +-- 5 files changed, 20 insertions(+), 20 deletions(-) rename paddle/fluid/framework/ir/xpu/{vis_decoder_attention_xpu_fuse_pass.cc => decoder_attention_xpu_fuse_pass.cc} (93%) rename paddle/fluid/framework/ir/xpu/{vis_decoder_attention_xpu_fuse_pass.h => decoder_attention_xpu_fuse_pass.h} (96%) rename test/ir/inference/{test_xpu_vis_decoder_attention_xpu_fuse_pass.py => test_xpu_decoder_attention_xpu_fuse_pass.py} (97%) diff --git a/paddle/fluid/framework/ir/CMakeLists.txt b/paddle/fluid/framework/ir/CMakeLists.txt index c8283a9a75108..8d5f5f64fd88f 100755 --- a/paddle/fluid/framework/ir/CMakeLists.txt +++ b/paddle/fluid/framework/ir/CMakeLists.txt @@ -273,7 +273,7 @@ if(WITH_XPU) ${XPU_PASS_DEPS}) pass_library(qk_qkv_attention_xpu_fuse_pass inference DIR xpu DEPS ${XPU_PASS_DEPS}) - pass_library(vis_decoder_attention_xpu_fuse_pass inference DIR xpu DEPS + pass_library(decoder_attention_xpu_fuse_pass inference DIR xpu DEPS ${XPU_PASS_DEPS}) pass_library(multi_encoder_xpu_fuse_pass inference DIR xpu DEPS ${XPU_PASS_DEPS}) diff --git a/paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.cc b/paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.cc similarity index 93% rename from paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.cc rename to paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.cc index a97eee259bd47..ad8dd1a55a868 100644 --- a/paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.cc +++ b/paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.h" +#include "paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.h" #include "glog/logging.h" @@ -27,9 +27,9 @@ namespace ir { namespace patterns { -struct VisDecoderAttentionFusePattern : public PatternBase { - VisDecoderAttentionFusePattern(PDPattern* pattern, - const std::string& name_scope); +struct DecoderAttentionFusePattern : public PatternBase { + DecoderAttentionFusePattern(PDPattern* pattern, + const std::string& name_scope); // declare operator node's name PATTERN_DECL_NODE(reshape2_1); @@ -63,7 +63,7 @@ struct VisDecoderAttentionFusePattern : public PatternBase { PATTERN_DECL_NODE(output); }; -VisDecoderAttentionFusePattern::VisDecoderAttentionFusePattern( +DecoderAttentionFusePattern::DecoderAttentionFusePattern( PDPattern* pattern, const std::string& name_scope) : PatternBase(pattern, name_scope, name_scope) { auto* input_q = pattern->NewNode(input_q_repr()) @@ -179,16 +179,16 @@ VisDecoderAttentionFusePattern::VisDecoderAttentionFusePattern( } // namespace patterns -void VisDecoderAttentionXPUFusePass::ApplyVisDecoderAttentionXPUFuse( +void DecoderAttentionXPUFusePass::ApplyDecoderAttentionXPUFuse( ir::Graph* graph) const { GraphPatternDetector gpd; - patterns::VisDecoderAttentionFusePattern pattern(gpd.mutable_pattern(), - name_scope_); + patterns::DecoderAttentionFusePattern pattern(gpd.mutable_pattern(), + name_scope_); int found_subgraph_count = 0; auto handler = [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - VLOG(4) << "handle VisDecoderAttentionXPUFusePass"; + VLOG(4) << "handle DecoderAttentionXPUFusePass"; // declare operator node's name GET_IR_NODE(reshape2_1); @@ -292,22 +292,22 @@ void VisDecoderAttentionXPUFusePass::ApplyVisDecoderAttentionXPUFuse( AddStatis(found_subgraph_count); } -void VisDecoderAttentionXPUFusePass::ApplyImpl(ir::Graph* graph) const { +void DecoderAttentionXPUFusePass::ApplyImpl(ir::Graph* graph) const { PADDLE_ENFORCE_NOT_NULL( graph, platform::errors::PreconditionNotMet("graph should not be null.")); Init(name_scope_, graph); - ApplyVisDecoderAttentionXPUFuse(graph); + ApplyDecoderAttentionXPUFuse(graph); } } // namespace ir } // namespace framework } // namespace paddle -REGISTER_PASS(vis_decoder_attention_xpu_fuse_pass, - paddle::framework::ir::VisDecoderAttentionXPUFusePass); +REGISTER_PASS(decoder_attention_xpu_fuse_pass, + paddle::framework::ir::DecoderAttentionXPUFusePass); -REGISTER_PASS_CAPABILITY(vis_decoder_attention_xpu_fuse_pass) +REGISTER_PASS_CAPABILITY(decoder_attention_xpu_fuse_pass) .AddCombination( paddle::framework::compatible::OpVersionComparatorCombination().EQ( "qkv_attention_xpu", 0)); diff --git a/paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.h b/paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.h similarity index 96% rename from paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.h rename to paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.h index a9de1f0ca1532..c41e455f2acc4 100644 --- a/paddle/fluid/framework/ir/xpu/vis_decoder_attention_xpu_fuse_pass.h +++ b/paddle/fluid/framework/ir/xpu/decoder_attention_xpu_fuse_pass.h @@ -89,12 +89,12 @@ Fused subgraph: */ -class VisDecoderAttentionXPUFusePass : public FusePassBase { +class DecoderAttentionXPUFusePass : public FusePassBase { protected: void ApplyImpl(ir::Graph* graph) const override; private: - void ApplyVisDecoderAttentionXPUFuse(ir::Graph* graph) const; + void ApplyDecoderAttentionXPUFuse(ir::Graph* graph) const; const std::string name_scope_{"vis_decoder_attention_xpu_fuse_pass"}; }; diff --git a/paddle/fluid/inference/api/paddle_pass_builder.cc b/paddle/fluid/inference/api/paddle_pass_builder.cc index 5845dcf420eb8..c6f6d1b8c7642 100644 --- a/paddle/fluid/inference/api/paddle_pass_builder.cc +++ b/paddle/fluid/inference/api/paddle_pass_builder.cc @@ -538,12 +538,12 @@ XpuPassStrategy::XpuPassStrategy() : PassStrategy({}) { "generate_sequence_xpu_fuse_pass", "embedding_with_eltwise_add_xpu_fuse_pass", "qk_qkv_attention_xpu_fuse_pass", - "vis_decoder_attention_xpu_fuse_pass", "multi_encoder_xpu_fuse_pass", "multi_encoder_xpu_adaptive_seqlen_fuse_pass", "multi_encoder_xpu_slice_fuse_pass", "fused_multi_transformer_cachekv_layout_trans_pass", "fused_multi_transformer_int8_cachekv_layout_trans_pass", + "decoder_attention_xpu_fuse_pass", "one_beam_size_fuse_pass", "fold_interp_outsize_fuse_pass", "fold_two_squeeze2_fuse_pass", diff --git a/test/ir/inference/test_xpu_vis_decoder_attention_xpu_fuse_pass.py b/test/ir/inference/test_xpu_decoder_attention_xpu_fuse_pass.py similarity index 97% rename from test/ir/inference/test_xpu_vis_decoder_attention_xpu_fuse_pass.py rename to test/ir/inference/test_xpu_decoder_attention_xpu_fuse_pass.py index 5c7d3759c696a..a7c5e069e23d1 100644 --- a/test/ir/inference/test_xpu_vis_decoder_attention_xpu_fuse_pass.py +++ b/test/ir/inference/test_xpu_decoder_attention_xpu_fuse_pass.py @@ -20,7 +20,7 @@ from program_config import OpConfig, ProgramConfig, TensorConfig -class TestVisDecoderAttentionXPUFusePass(PassAutoScanTest): +class TestDecoderAttentionXPUFusePass(PassAutoScanTest): def sample_predictor_configs(self, program_config): config = self.create_inference_config(use_xpu=True) yield config, ["qkv_attention_xpu"], (1e-1, 1e-1) @@ -164,7 +164,7 @@ def test(self): self.run_and_statis( quant=False, max_examples=25, - passes=["vis_decoder_attention_xpu_fuse_pass"], + passes=["decoder_attention_xpu_fuse_pass"], )