Skip to content

Commit

Permalink
conv fuse for custom device (#60708)
Browse files Browse the repository at this point in the history
  • Loading branch information
engineer1109 authored Jan 19, 2024
1 parent f2232e1 commit 87b1b00
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion paddle/fluid/framework/ir/conv_elementwise_add_act_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ void ConvElementwiseAddActFusePass::ApplyImpl(ir::Graph* graph) const {
all_act_set.insert(cutlass_act_set.begin(), cutlass_act_set.end());
}

std::unordered_set<std::string> custom_act_set{};
if (Get<bool>("use_custom_device")) {
custom_act_set = {
"identity", "relu", "sigmoid", "tanh", "swish", "leaky_relu"};
all_act_set.insert(custom_act_set.begin(), custom_act_set.end());
}

patterns::ConvElementwiseaddAct pattern(gpd.mutable_pattern(), pattern_name);
pattern(x, all_act_set);
int found_count = 0;
Expand All @@ -197,7 +204,8 @@ void ConvElementwiseAddActFusePass::ApplyImpl(ir::Graph* graph) const {
// When this fused_conv2d_add_act specified by problem size and act type is
// not supported by cutlass and not supported by cuDNN, we should not apply
// this pass.
if (!cutlass_can_fuse && !cudnn_can_fuse) {
bool custom_can_fuse = custom_act_set.count(act_op_type);
if (!cutlass_can_fuse && !cudnn_can_fuse && !custom_can_fuse) {
return;
}

Expand Down

0 comments on commit 87b1b00

Please sign in to comment.