Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / mkldnn_plugin / mkldnn_node.h
index fe71c66..b3060f8 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -43,6 +43,7 @@ enum Type {
     Lrn,
     Pooling,
     FullyConnected,
+    FullyConnected_Activation,
     SoftMax,
     Split,
     Concatenation,
@@ -60,8 +61,10 @@ enum Type {
     Copy,
     MemoryOutput,
     MemoryInput,
-    LSTMCell,
-    RNN
+    RNNCell,
+    RNNSeq,
+    Quantize,
+    BinaryConvolution
 };
 
 static Type TypeFromName(const std::string type) {
@@ -78,6 +81,8 @@ static Type TypeFromName(const std::string type) {
             { "Logistic", Activation },
             { "TanH", Activation },
             { "ReLU6", Activation },
+            { "Exp", Activation },
+            { "Not", Activation },
             { "Activation", Activation },
             { "ScaleShift", Depthwise },
             { "PReLU", Depthwise },
@@ -105,8 +110,14 @@ static Type TypeFromName(const std::string type) {
             { "Flatten", Flatten },
             { "Permute", Permute },
             { "Copy", Copy },
-            { "LSTMCell", LSTMCell },
-            { "RNN", RNN },
+            { "LSTMCell", RNNCell },
+            { "GRUCell", RNNCell },
+            { "RNNCell", RNNCell },
+            { "LSTMSequence", RNNSeq },
+            { "GRUSequence", RNNSeq },
+            { "RNNSequence", RNNSeq },
+            { "Quantize", Quantize },
+            { "BinaryConvolution", BinaryConvolution },
             { "MemoryInput", MemoryInput},  // for construction from name ctor, arbitrary name is used
             { "Memory", MemoryOutput },  // for construction from layer ctor
     };
@@ -152,7 +163,7 @@ public:
 
     ~MKLDNNNode() override = default;
 
-    void addEdge(const MKLDNNEdgeWeakPtr& edge, size_t pIndex, size_t cIndex, bool insertChildIndex = false);
+    void addEdge(const MKLDNNEdgeWeakPtr& edge);
     void removeEdge(const MKLDNNEdgeWeakPtr& edge);
 
     virtual void cleanup();
@@ -169,6 +180,8 @@ public:
     const MKLDNNEdgePtr getParentEdgeAt(size_t idx) const;
     virtual const MKLDNNEdgePtr getChildEdgeAt(size_t idx) const;
 
+    const std::vector<MKLDNNEdgePtr> getParentEdgesAtPort(size_t idx) const;
+    const std::vector<MKLDNNEdgePtr> getChildEdgesAtPort(size_t idx) const;
 
     bool isDropped() {
         return (isEdgesEmpty(childEdges) && isEdgesEmpty(parentEdges));
@@ -190,6 +203,8 @@ public:
         mergedWith.push_back(merge);
     }
 
+    void addOriginalLayer(const InferenceEngine::CNNLayerPtr &layer);
+
     const std::vector <MKLDNNNodePtr> &getMergeWith() {
         return mergedWith;
     }
@@ -202,6 +217,10 @@ public:
         return name;
     }
 
+    const std::string getOriginalLayers() const {
+        return originalLayers;
+    }
+
     Type getType() const {
         return type;
     }
@@ -309,17 +328,19 @@ public:
         THROW_IE_EXCEPTION << "Primitive descriptor was not found for node " << getName() << ".";
     }
 
-    static void invertVectorCopyUtoI(const InferenceEngine::PropertyVector<unsigned int>& src, std::vector<int>& dst) {
+    static void invertVectorCopyUtoI(const InferenceEngine::PropertyVector<unsigned int>& src, std::vector<ptrdiff_t>& dst) {
         dst.clear();
         for (int i = 1; i <= src.size(); i++) {
-            dst.push_back(static_cast<int>(src[src.size() - i]));
+            dst.push_back(static_cast<ptrdiff_t>(src[src.size() - i]));
         }
     }
 
+    std::vector<MKLDNNDims> inDims;
+
+
 protected:
     // TODO: It is necessary only in order to avoid modifications of cnnLayers and original topology
     std::vector<MKLDNNDims> outDims;
-    std::vector<MKLDNNDims> inDims;
     void setType(Type type) {
         this->type = type;
     }
@@ -331,6 +352,8 @@ protected:
     virtual MKLDNNMemoryDesc getSrcMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx);
     virtual MKLDNNMemoryDesc getDstMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx);
 
+    virtual std::shared_ptr<mkldnn::primitive_attr> initPrimitiveAttr() const { return nullptr; }
+
     typedef std::function<MKLDNNMemoryDesc (mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx)>
             GetPrimitiveMemoryFormatFunc;
     std::vector<GetPrimitiveMemoryFormatFunc> internalBlobDesc;
@@ -339,6 +362,8 @@ protected:
     std::vector <MKLDNNNodePtr> mergedWith;
     std::vector <impl_desc_type> implPriorities;
 
+    std::string originalLayers;  // contains names of the original layers separated by comma
+
     MKLDNNNode(const InferenceEngine::CNNLayerPtr& layer, const mkldnn::engine& eng);
 
     int selectedPrimitiveDescriptorIndex = -1;