From b8e54ab5cc39774e05fa902c3fe10d476bfe1308 Mon Sep 17 00:00:00 2001 From: Tomasz Patejko Date: Tue, 18 Sep 2018 07:42:19 +0200 Subject: [PATCH] MKLDNN conv + elementwise_add fusion: parameter name changed to ResidualData --- .../ir/conv_elementwise_add_mkldnn_fuse_pass.cc | 2 +- paddle/fluid/operators/conv_mkldnn_op.cc | 10 +++++----- paddle/fluid/operators/conv_op.cc | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc index ac15e1b3d5f..9cd3c401b0e 100644 --- a/paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc @@ -184,7 +184,7 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const { op_desc.SetInput("Input", {conv_input->Name()}); op_desc.SetInput("Filter", {conv_filter->Name()}); - op_desc.SetInput("EltwiseParameter", {elementwise_add_x->Name()}); + op_desc.SetInput("ResidualData", {elementwise_add_x->Name()}); op_desc.SetOutput("Output", {conv_output->Name()}); op_desc.SetAttr("use_mkldnn", true); diff --git a/paddle/fluid/operators/conv_mkldnn_op.cc b/paddle/fluid/operators/conv_mkldnn_op.cc index c849caf94ff..8c9ea7c409b 100644 --- a/paddle/fluid/operators/conv_mkldnn_op.cc +++ b/paddle/fluid/operators/conv_mkldnn_op.cc @@ -390,14 +390,14 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { T* output_data = nullptr; if (fuse_eltwise) { - auto eltwise_param = ctx.Input("EltwiseParameter"); - auto eltwise_param_data = eltwise_param->data(); + auto residual_param = ctx.Input("ResidualData"); + auto residual_param_data = residual_param->data(); - PADDLE_ENFORCE(eltwise_param_data != nullptr, "Provide data if you want MKLDNN conv+elementwise_add fusion"); - PADDLE_ENFORCE_EQ(output->dims(), eltwise_param->dims(), "Output and elementwise parameter need to have the same dimension sizes"); + PADDLE_ENFORCE(residual_param_data != nullptr, "Provide data if you want MKLDNN conv+elementwise_add fusion"); + PADDLE_ENFORCE_EQ(output->dims(), residual_param->dims(), "Output and elementwise parameter need to have the same dimension sizes"); output_data = output->mutable_data(ctx.GetPlace()); - output->ShareDataWith(*eltwise_param); + output->ShareDataWith(*residual_param); } else { output_data = output->mutable_data(ctx.GetPlace(), handler.GetDstMemorySize()); diff --git a/paddle/fluid/operators/conv_op.cc b/paddle/fluid/operators/conv_op.cc index 99c50a52078..1e913dea1b1 100644 --- a/paddle/fluid/operators/conv_op.cc +++ b/paddle/fluid/operators/conv_op.cc @@ -132,8 +132,9 @@ void Conv2DOpMaker::Make() { "(Tensor) The output tensor of convolution operator. " "The format of output tensor is also NCHW.") .Reuse("Input"); - AddInput("EltwiseParameter", - "(Tensor) Tensor to which convolution output will be added." + AddInput("ResidualData", + "(Tensor) Tensor with residual data " + "to which convolution output will be added." "Used on with fuse_eltwise fusion.") .AsDispensable(); AddAttr>("strides", -- GitLab