Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / mkldnn_plugin / nodes / mkldnn_depthwise_node.cpp
index 6b1097a..03e4473 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -35,6 +35,11 @@ void MKLDNNDepthwiseNode::getSupportedDescriptors() {
 
     auto parentOutDims = getParentEdgeAt(0)->getDims();
 
+    if (getParentEdges().size() != 1)
+        THROW_IE_EXCEPTION << "Cannot create layer " << getName() << ": Incorrect number of inputs!";
+    if (parentOutDims != getChildEdgeAt(0)->getDims())
+        THROW_IE_EXCEPTION << "Cannot create layer " << getName() << ": Incorrect dimensions!";
+
     SizeVector weightDims = { (long unsigned int)parentOutDims[1] };
     MKLDNNDims blocked_weightDims(weightDims);
 
@@ -76,7 +81,7 @@ void MKLDNNDepthwiseNode::createPrimitive() {
 
     if (isBroadcast()) {
         float broadcastValue = static_cast<float*>(internalBlobMemory[0]->GetData())[0];
-        int blbSize = internalBlobMemory[0]->GetPrimitiveDescriptor().desc().data.dims[0];
+        size_t blbSize = internalBlobMemory[0]->GetPrimitiveDescriptor().desc().data.dims[0];
         for (int i = 1; i < blbSize && realWeightSize != blbSize; i++) {
             static_cast<float*>(internalBlobMemory[0]->GetData())[i] = broadcastValue;
         }
@@ -88,6 +93,15 @@ void MKLDNNDepthwiseNode::createPrimitive() {
                 static_cast<float*>(internalBlobMemory[1]->GetData())[i] = broadcastValue;
             }
         }
+    } else {
+        size_t blbSize = internalBlobMemory[0]->GetPrimitiveDescriptor().desc().data.dims[0];
+        if (realWeightSize != blbSize)
+            THROW_IE_EXCEPTION << "Cannot create layer " << getName() << ": Incorrect weights!";
+        if (isWithBiases()) {
+            blbSize = internalBlobMemory[1]->GetPrimitiveDescriptor().desc().data.dims[0];
+            if (realBiasSize != blbSize)
+                THROW_IE_EXCEPTION << "Cannot create layer " << getName() << ": Incorrect biases!";
+        }
     }
 
     if (isWithBiases()) {