Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi_encoder support adaptive seqlen #53982

Merged
merged 5 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions paddle/fluid/framework/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ if(WITH_XPU)
pass_library(fc_xpu_fuse_pass inference DIR xpu DEPS ${XPU_PASS_DEPS})
pass_library(multi_encoder_xpu_fuse_pass inference DIR xpu DEPS
${XPU_PASS_DEPS})
pass_library(multi_encoder_xpu_adaptive_seqlen_fuse_pass inference DIR xpu
DEPS ${XPU_PASS_DEPS})
pass_library(multi_encoder_xpu_slice_fuse_pass inference DIR xpu DEPS
${XPU_PASS_DEPS})
pass_library(generate_sequence_xpu_fuse_pass inference DIR xpu DEPS
Expand Down Expand Up @@ -529,4 +531,8 @@ if(WITH_XPU)
test_fused_multi_transformer_cachekv_layout_trans_pass
SRCS xpu/fused_multi_transformer_cachekv_layout_trans_pass_test.cc
DEPS fused_multi_transformer_cachekv_layout_trans_pass)
cc_test(
test_multi_encoder_xpu_adaptive_seqlen_fuse_pass
SRCS xpu/multi_encoder_xpu_adaptive_seqlen_fuse_pass_test.cc
DEPS multi_encoder_xpu_adaptive_seqlen_fuse_pass)
endif()
1 change: 1 addition & 0 deletions paddle/fluid/framework/ir/pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static const std::vector<std::string> xpu_support_subgraph_passes = {
"generate_sequence_xpu_fuse_pass",
"embedding_with_eltwise_add_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",
"one_beam_size_fuse_pass",
Expand Down
21 changes: 21 additions & 0 deletions paddle/fluid/framework/ir/pass_tester_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,17 @@ struct Layers {
return unary_op("logical_not", input);
}

VarDesc* not_equal(VarDesc* x, VarDesc* y, int axis = -1) {
VarDesc* out = lod_tensor(unique_name());
OpDesc* op = program_.MutableBlock(0)->AppendOp();
op->SetType("not_equal");
op->SetInput("X", {x->Name()});
op->SetInput("Y", {y->Name()});
op->SetAttr("axis", axis);
op->SetOutput("Out", {out->Name()});
return out;
}

VarDesc* stack(std::vector<VarDesc*> inputs, int axis = -1) {
VarDesc* out = lod_tensor(unique_name());
OpDesc* op = program_.MutableBlock(0)->AppendOp();
Expand All @@ -838,6 +849,16 @@ struct Layers {
return out;
}

VarDesc* tile(VarDesc* x, const std::vector<int>& repeat_times = {2}) {
VarDesc* out = lod_tensor(unique_name());
OpDesc* op = program_.MutableBlock(0)->AppendOp();
op->SetType("tile");
op->SetInput("X", {x->Name()});
op->SetAttr("repeat_times", repeat_times);
op->SetOutput("Out", {out->Name()});
return out;
}

private:
VarDesc* lod_tensor(std::string name,
std::vector<int64_t> shape = {},
Expand Down
Loading