From 35a70cc54d0717b41b31c629b2691663970ed1c5 Mon Sep 17 00:00:00 2001 From: Xiaoyang LI Date: Wed, 30 Oct 2019 08:09:53 +0800 Subject: [PATCH] turn off conv_leaky_relu fusion when target is not cuda(#2288) --- lite/core/mir/fusion/conv_activation_fuse_pass.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lite/core/mir/fusion/conv_activation_fuse_pass.cc b/lite/core/mir/fusion/conv_activation_fuse_pass.cc index 613482eb6c..ff064fb2ee 100644 --- a/lite/core/mir/fusion/conv_activation_fuse_pass.cc +++ b/lite/core/mir/fusion/conv_activation_fuse_pass.cc @@ -23,8 +23,15 @@ namespace lite { namespace mir { void ConvActivationFusePass::Apply(const std::unique_ptr& graph) { + std::vector act_types{"relu"}; + for (auto& place : graph->valid_places()) { + if (place.target == TARGET(kCUDA)) { + act_types.push_back("leaky_relu"); + break; + } + } for (auto conv_type : {"conv2d", "depthwise_conv2d"}) { - for (auto act_type : {"relu", "leaky_relu"}) { + for (auto act_type : act_types) { for (auto has_bias : {true, false}) { fusion::ConvActivationFuser fuser(conv_type, act_type, has_bias); fuser(graph.get()); -- GitLab