提交 ed27a3be 编写于 作者: T tensor-tang

add some log info

上级 44002846
...@@ -100,6 +100,7 @@ public: ...@@ -100,6 +100,7 @@ public:
if (cnt_ == act.value->getElementCnt()) { if (cnt_ == act.value->getElementCnt()) {
return; return;
} }
VLOG(MKLDNN_BASE) << getName() << " reset mkldnn forward";
cnt_ = act.value->getElementCnt(); cnt_ = act.value->getElementCnt();
stream_.reset(new MKLDNNStream()); stream_.reset(new MKLDNNStream());
auto eng = CPUEngine::Instance().getEngine(); auto eng = CPUEngine::Instance().getEngine();
...@@ -110,7 +111,6 @@ public: ...@@ -110,7 +111,6 @@ public:
float alpha = getAlpha(); float alpha = getAlpha();
float beta = getBeta(); float beta = getBeta();
/// forward
pipelineFwd_.clear(); pipelineFwd_.clear();
val_ = std::dynamic_pointer_cast<MKLDNNMatrix>(act.value); val_ = std::dynamic_pointer_cast<MKLDNNMatrix>(act.value);
if (val_ == nullptr) { if (val_ == nullptr) {
...@@ -152,6 +152,7 @@ public: ...@@ -152,6 +152,7 @@ public:
if (!needResetBwd_) { if (!needResetBwd_) {
return; return;
} }
VLOG(MKLDNN_BASE) << getName() << " reset mkldnn backward";
needResetBwd_ = false; needResetBwd_ = false;
mkldnn::algorithm algo = getAlgo(this->getName()); mkldnn::algorithm algo = getAlgo(this->getName());
float alpha = getBwdAlpha(); float alpha = getBwdAlpha();
......
...@@ -64,7 +64,7 @@ bool MKLDNNConvLayer::init(const LayerMap& layerMap, ...@@ -64,7 +64,7 @@ bool MKLDNNConvLayer::init(const LayerMap& layerMap,
// create biases // create biases
if (biasParameter_.get() != NULL) { if (biasParameter_.get() != NULL) {
biases_ = std::unique_ptr<Weight>(new Weight(1, oc_, biasParameter_)); biases_ = std::unique_ptr<Weight>(new Weight(1, oc_, biasParameter_, 0));
} }
return true; return true;
} }
...@@ -535,7 +535,7 @@ void MKLDNNConvLayer::resetWgtValBwdData( ...@@ -535,7 +535,7 @@ void MKLDNNConvLayer::resetWgtValBwdData(
} else { } else {
wgtValBwdData_ = wgtVal_; wgtValBwdData_ = wgtVal_;
} }
VLOG(MKLDNN_FMTS) << "weight value format for backward data" VLOG(MKLDNN_FMTS) << "weight value format for backward data: "
<< wgtValBwdData_->getFormat(); << wgtValBwdData_->getFormat();
} }
......
...@@ -49,7 +49,7 @@ bool MKLDNNFcLayer::init(const LayerMap& layerMap, ...@@ -49,7 +49,7 @@ bool MKLDNNFcLayer::init(const LayerMap& layerMap,
// create biases // create biases
if (biasParameter_.get() != NULL) { if (biasParameter_.get() != NULL) {
biases_ = std::unique_ptr<Weight>(new Weight(1, oc_, biasParameter_)); biases_ = std::unique_ptr<Weight>(new Weight(1, oc_, biasParameter_, 0));
} }
return true; return true;
} }
...@@ -161,9 +161,16 @@ void MKLDNNFcLayer::resetInValue(MKLDNNMatrixPtr& in) { ...@@ -161,9 +161,16 @@ void MKLDNNFcLayer::resetInValue(MKLDNNMatrixPtr& in) {
void MKLDNNFcLayer::resetWgtBiasValue(MKLDNNMatrixPtr& wgt, void MKLDNNFcLayer::resetWgtBiasValue(MKLDNNMatrixPtr& wgt,
MKLDNNMatrixPtr& bias) { MKLDNNMatrixPtr& bias) {
format wgtFmt = format::oihw;
if (inVal_->getFormat() == format::nChw8c) {
wgtFmt = format::oIhw8i;
} else if (inVal_->getFormat() == format::nChw16c) {
wgtFmt = format::oIhw16i;
}
wgt = MKLDNNMatrix::create( wgt = MKLDNNMatrix::create(
weight_->getW(), {oc_, ic_, ih_, iw_}, format::oihw, engine_); weight_->getW(), {oc_, ic_, ih_, iw_}, wgtFmt, engine_);
wgt->downSpatial(); wgt->downSpatial();
VLOG(MKLDNN_FMTS) << "Weight value format: " << wgt->getFormat();
bias = (biases_ && biases_->getW()) bias = (biases_ && biases_->getW())
? MKLDNNMatrix::create(biases_->getW(), {oc_}, format::x, engine_) ? MKLDNNMatrix::create(biases_->getW(), {oc_}, format::x, engine_)
......
...@@ -115,6 +115,7 @@ public: ...@@ -115,6 +115,7 @@ public:
copySeqInfoToOutputs(); copySeqInfoToOutputs();
size_t elemenCnt = inputLayers_[0]->getOutput().value->getElementCnt(); size_t elemenCnt = inputLayers_[0]->getOutput().value->getElementCnt();
if (inputElemenCnt_ != elemenCnt) { if (inputElemenCnt_ != elemenCnt) {
VLOG(MKLDNN_BASE) << getName() << " reset mkldnn forward";
// reset when input total sizes changed, not only the batchsize // reset when input total sizes changed, not only the batchsize
inputElemenCnt_ = elemenCnt; inputElemenCnt_ = elemenCnt;
reshape(bs_, ic_, ih_, iw_, oc_, oh_, ow_); reshape(bs_, ic_, ih_, iw_, oc_, oh_, ow_);
...@@ -142,6 +143,7 @@ public: ...@@ -142,6 +143,7 @@ public:
void backward(const UpdateCallback& callback) override { void backward(const UpdateCallback& callback) override {
if (needResetBwd_) { if (needResetBwd_) {
VLOG(MKLDNN_BASE) << getName() << " reset mkldnn backward";
resetBwd(pipelineBwd_, inGrad_, wgtGrad_, biasGrad_, outGrad_); resetBwd(pipelineBwd_, inGrad_, wgtGrad_, biasGrad_, outGrad_);
needResetBwd_ = false; needResetBwd_ = false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册