From 8349eb4fa25176662bac72b836c4fb6ff7b220e3 Mon Sep 17 00:00:00 2001 From: Wang Yanzhang Date: Fri, 9 Feb 2018 15:04:38 -0500 Subject: [PATCH] fix: batch norm weights tensor to Dense --- .../scala/com/intel/analytics/bigdl/nn/mkldnn/Linear.scala | 4 ++-- .../analytics/bigdl/nn/mkldnn/SpatialBatchNormalization.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/Linear.scala b/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/Linear.scala index d7a512b851f..cb88293b7fb 100644 --- a/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/Linear.scala +++ b/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/Linear.scala @@ -151,7 +151,7 @@ class Linear[T: ClassTag]( primitive } - var _shouldConvert: Boolean = true + var _shouldConvert: Boolean = false def shouldConvert: Boolean = _shouldConvert def setShouldConvert(v: Boolean): this.type = { _shouldConvert = v @@ -683,7 +683,7 @@ class Linear[T: ClassTag]( if (gradOutputReorderPrim != 0) { if (gradOutput.getTensorType == DenseType && gradOutputPtr != 0) { - MklDnn.MemoryReleaseDataHandle(weight.storage().array().asInstanceOf[Array[Float]], + MklDnn.MemoryReleaseDataHandle(gradOutput.storage().array().asInstanceOf[Array[Float]], gradOutputPtr) } } diff --git a/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/SpatialBatchNormalization.scala b/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/SpatialBatchNormalization.scala index cce136d28ac..534acf9581d 100644 --- a/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/SpatialBatchNormalization.scala +++ b/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/mkldnn/SpatialBatchNormalization.scala @@ -417,7 +417,7 @@ class SpatialBatchNormalization[T: ClassTag]( // in mkl dnn, the weight and bias should be all in the same array private def createParams(initWeight: Tensor[T], initBias: Tensor[T]): Tensor[T] = { val weightAndBias: Tensor[T] = if (affine) { - MklDnnTensor[T](Array(2 * nOutput)) + Tensor[T](Array(2 * nOutput)) } else { null }