diff --git a/paddle/fluid/operators/CMakeLists.txt b/paddle/fluid/operators/CMakeLists.txt index 4c3b8ec78190723598a56f7633764f10dd5047f3..8cd80ca6be45713ca471793c76f33bc018d697a2 100644 --- a/paddle/fluid/operators/CMakeLists.txt +++ b/paddle/fluid/operators/CMakeLists.txt @@ -295,12 +295,6 @@ op_library(channel_recv_op DEPS concurrency) list(REMOVE_ITEM GENERAL_OPS ${DEPS_OPS}) -# The fully connected layer is deleted when the WITH_MKLDNN flag is OFF -# Because the fully connected layer has only one MKLDNN's operator -if(NOT WITH_MKLDNN) - list(REMOVE_ITEM GENERAL_OPS fc_op) -endif(NOT WITH_MKLDNN) - foreach(src ${GENERAL_OPS}) op_library(${src}) endforeach() diff --git a/paddle/fluid/operators/fc_op.cc b/paddle/fluid/operators/fc_op.cc index e71f63c13498492101a301372fad6e6804ae6ef0..ec8dfb659c33882cedd02406288d0bbf62ac99d8 100644 --- a/paddle/fluid/operators/fc_op.cc +++ b/paddle/fluid/operators/fc_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include "paddle/fluid/operators/fc_op.h" #include +#include "paddle/fluid/operators/math/blas.h" DECLARE_int32(paddle_num_threads); @@ -127,13 +128,13 @@ class FCOpKernel : public framework::OpKernel { "It must use CPUPlace."); auto input = ctx.Input("Input"); auto w = ctx.Input("W"); - auto b = ctx.Input("Bias"); + auto bias = ctx.Input("Bias"); auto output = ctx.Output("Out"); - auto in_dims = ctx->GetInputDim("Input"); - auto w_dims = ctx->GetInputDim("W"); + auto in_dims = input->dims(); + auto w_dims = w->dims(); - auto& dev_ctx = ctx.template device_context(); - auto blas = math::GetBlas(dev_ctx); + auto& dev_ctx = ctx.template device_context(); + auto blas = math::GetBlas(dev_ctx); const T* input_data = input->data(); const T* w_data = w->data(); T* output_data = output->mutable_data(ctx.GetPlace()); @@ -147,7 +148,7 @@ class FCOpKernel : public framework::OpKernel { #pragma omp parallel for if (FLAGS_paddle_num_threads > 1) for (int bs = 0; bs < in_dims[0]; bs++) { blas.AXPY(w_dims[1], static_cast(1), bias_data, - output_data + bs * w_dimws[1]); + output_data + bs * w_dims[1]); } } }