From f0efc244c6e051b14ff9e48863f32088b95e9858 Mon Sep 17 00:00:00 2001 From: Michal Gallus Date: Wed, 26 Sep 2018 14:46:09 +0200 Subject: [PATCH] MKLDNN conv + elementwise_add fusion: Fix transpiler integration to predict skip connection input of eltwise_add --- .../fluid/transpiler/inference_transpiler.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/transpiler/inference_transpiler.py b/python/paddle/fluid/transpiler/inference_transpiler.py index b2cdad36a..9a36605d3 100644 --- a/python/paddle/fluid/transpiler/inference_transpiler.py +++ b/python/paddle/fluid/transpiler/inference_transpiler.py @@ -455,11 +455,15 @@ class InferenceTranspiler(object): :type eltwise_op: Operator ''' - residual_var = self.block.var(eltwise_op.input("X")[0]) - out_var = self.block.var(eltwise_op.output("Out")[0]) - filter_var = self.block.var(conv_op.input("Filter")[0]) - in_var = self.block.var(conv_op.input("Input")[0]) - bias_var = self.block.var(conv_op.input("Bias")[0]) + eltwise_input = "X" + if eltwise_op.input("X")[0] == conv_op.output("Output")[0]: + eltwise_input = "Y" + + residual_var = self.block.vars[eltwise_op.input(eltwise_input)[0]] + out_var = self.block.vars[eltwise_op.output("Out")[0]] + filter_var = self.block.vars[conv_op.input("Filter")[0]] + in_var = self.block.vars[conv_op.input("Input")[0]] + bias_var = self.block.vars[conv_op.input("Bias")[0]] conv_op.set_attr("fuse_eltwise", True) attrs = {name: conv_op.attr(name) for name in conv_op.attr_names} -- GitLab