From 386bb1fecec48234082ece5374e899a267676545 Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Mon, 23 Oct 2017 14:59:44 +0800 Subject: [PATCH] fix crash on ds2 --- paddle/gserver/layers/MKLDNNLayer.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/gserver/layers/MKLDNNLayer.h b/paddle/gserver/layers/MKLDNNLayer.h index 9b54c95b55c..2c21a5b2aae 100644 --- a/paddle/gserver/layers/MKLDNNLayer.h +++ b/paddle/gserver/layers/MKLDNNLayer.h @@ -339,9 +339,13 @@ private: * clear all grad */ void clearGrads() { - output_.grad->zeroMem(); + if (output_.grad) { + output_.grad->zeroMem(); + } for (size_t i = 0; i < outputOtherDevice_.size(); i++) { - outputOtherDevice_[i].grad->zeroMem(); + if (outputOtherDevice_[i].grad) { + outputOtherDevice_[i].grad->zeroMem(); + } } } -- GitLab