diff --git a/paddle/gserver/layers/MkldnnFcLayer.cpp b/paddle/gserver/layers/MkldnnFcLayer.cpp index 7e09ed33d2694b83865bccc30a85db1aed96b99e..e4c4d4675d13c130290b063e9ed85ba41af1a5fe 100644 --- a/paddle/gserver/layers/MkldnnFcLayer.cpp +++ b/paddle/gserver/layers/MkldnnFcLayer.cpp @@ -50,7 +50,7 @@ bool MkldnnFcLayer::init(const LayerMap& layerMap, return true; } -void MkldnnFcLayer::cvtWgtFromPaddle() { +void MkldnnFcLayer::convertWeightsFromPaddle() { if (FLAGS_use_mkldnn_wgt) { return; } @@ -75,7 +75,7 @@ void MkldnnFcLayer::cvtWgtFromPaddle() { hasInitedWgt_ = true; } -void MkldnnFcLayer::cvtWgtToPaddle() { +void MkldnnFcLayer::convertWeightsToPaddle() { MatrixPtr dnnWgt = weight_->getW(); MatrixPtr paddleWgt; dnnWgt->transpose(paddleWgt, true); diff --git a/paddle/gserver/layers/MkldnnFcLayer.h b/paddle/gserver/layers/MkldnnFcLayer.h index 0064fc472716a0e59dfdb629ccf39b5306a522cd..f89105228498f8136cbcca15201fe714323663e2 100644 --- a/paddle/gserver/layers/MkldnnFcLayer.h +++ b/paddle/gserver/layers/MkldnnFcLayer.h @@ -44,9 +44,9 @@ public: bool init(const LayerMap& layerMap, const ParameterMap& parameterMap) override; - void cvtWgtFromPaddle() override; + void convertWeightsFromPaddle() override; - void cvtWgtToPaddle() override; + void convertWeightsToPaddle() override; void forward(PassType passType) override; diff --git a/paddle/gserver/layers/MkldnnLayer.cpp b/paddle/gserver/layers/MkldnnLayer.cpp index c909fe274d4e9a87f07e23fdeaefa3aab2029836..6bd2b15a1712a34df5f3af36219c65d79975efe1 100644 --- a/paddle/gserver/layers/MkldnnLayer.cpp +++ b/paddle/gserver/layers/MkldnnLayer.cpp @@ -14,7 +14,6 @@ limitations under the License. */ #include "MkldnnLayer.h" -// using namespace mkldnn; // NOLINT using mem = mkldnn::memory; // NOLINT typedef mem::format format; typedef mkldnn::inner_product_forward fc_fwd; @@ -94,7 +93,7 @@ void MkldnnLayer::mkldnnForwardFC(int bs, // if input size changed, reset it resetForwardFC(bs, ic, ih, iw, botData, oc, topData, wgtData, biasData); - this->cvtWgtFromPaddle(); + this->convertWeightsFromPaddle(); // update input, since the data might be changed if this is after data layer inVal_->set_data_handle(botData); @@ -208,9 +207,9 @@ void MkldnnLayer::mkldnnBackwardFC(int bs, } void MkldnnLayer::printSizeInfo() { - VLOG(DNN_SIZES) << "bs: " << bs_ << ", ic: " << ic_ << ", ih: " << ih_ - << ", iw: " << iw_ << ", oc: " << oc_ << ", oh: " << oh_ - << ", ow: " << ow_; + VLOG(DNN_SIZES) << getName() << ": bs: " << bs_ << ", ic: " << ic_ + << ", ih: " << ih_ << ", iw: " << iw_ << ", oc: " << oc_ + << ", oh: " << oh_ << ", ow: " << ow_; } mem::desc MkldnnLayer::createMD(mem::dims dims, diff --git a/paddle/gserver/layers/MkldnnLayer.h b/paddle/gserver/layers/MkldnnLayer.h index c653eb9985057198fbaa04f20246ea10f5127dad..e5c93500c75433624c692882bd075ceeaa69cf84 100644 --- a/paddle/gserver/layers/MkldnnLayer.h +++ b/paddle/gserver/layers/MkldnnLayer.h @@ -87,13 +87,13 @@ public: * convert weight from paddle format to mkldnn format * weight_ will be override */ - virtual void cvtWgtFromPaddle() { ; } + virtual void convertWeightsFromPaddle() {} /** * convert mkldnn weight to paddle format * weight_ will be override */ - virtual void cvtWgtToPaddle() { ; } + virtual void convertWeightsToPaddle() {} void resetForwardFC(int bs, int ic, diff --git a/paddle/gserver/tests/MkldnnTester.cpp b/paddle/gserver/tests/MkldnnTester.cpp index ef99b384a93f71b51cc47b3f0ab7907fb54efb98..59b3861df81d995b2657298ef1565ccca3562fb6 100644 --- a/paddle/gserver/tests/MkldnnTester.cpp +++ b/paddle/gserver/tests/MkldnnTester.cpp @@ -149,7 +149,7 @@ void MkldnnTester::checkBackwardWgts() { const MkldnnLayerPtr dnnlayer = std::dynamic_pointer_cast(dnnLayer_); CHECK(dnnlayer); - dnnlayer->cvtWgtToPaddle(); + dnnlayer->convertWeightsToPaddle(); for (size_t i = 0; i < parameters_[DNN].size(); ++i) { const VectorPtr& dnn = parameters_[DNN][i]->getBuf(PARAMETER_VALUE); const VectorPtr& ref = parameters_[REF][i]->getBuf(PARAMETER_VALUE); diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index dc07af343d2cbb7c16b3a95f47ac16fbc2a4b242..3213df5186042ef3d72b52b6b428a28b98b33736 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -1614,13 +1614,13 @@ class FCLayer(LayerBase): error_clipping_threshold=None, **xargs): use_mkldnn = bool(int(g_command_config_args.get("use_mkldnn", 0))) + use_mkldnn_wgt = bool( + int(g_command_config_args.get("use_mkldnn_wgt", 0))) if use_mkldnn: self.layer_type = 'mkldnn_fc' config_assert( len(inputs) == 1, "MkldnnFCLayer support one and only one input!") - use_mkldnn_wgt = bool( - int(g_command_config_args.get("use_mkldnn_wgt", 0))) super(FCLayer, self).__init__( name, self.layer_type, size, inputs=inputs, **xargs) for input_index in xrange(len(self.inputs)):