Publishing 2019 R1 content
[platform/upstream/dldt.git] / model-optimizer / extensions / middle / NormalizeFullyConnected.py
index 9452486..991f816 100644 (file)
@@ -1,5 +1,5 @@
 """
- Copyright (c) 2018 Intel Corporation
+ Copyright (c) 2018-2019 Intel Corporation
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  limitations under the License.
 """
 
-import networkx as nx
 import numpy as np
 
+from mo.graph.graph import Graph
 from mo.middle.replacement import MiddleReplacementPattern
 from mo.ops.op import Op
 from mo.ops.reshape import Reshape
 
 
 class NormalizeFullyConnected(MiddleReplacementPattern):
-    enabled = False
+    enabled = True
+    graph_condition = [lambda graph: graph.graph['fw'] == 'onnx']
+
+    def run_after(self):
+        from extensions.middle.GemmToFullyConnected import GemmToFullyConnected
+        return [GemmToFullyConnected]
+
+    def run_before(self):
+        from extensions.middle.pass_separator import MiddleFinish
+        return [MiddleFinish]
 
     def pattern(self):
         return dict(
@@ -33,7 +42,7 @@ class NormalizeFullyConnected(MiddleReplacementPattern):
             edges=[('fc', 'fc_output')],
         )
 
-    def replace_pattern(self, graph: nx.MultiDiGraph, match: dict):
+    def replace_pattern(self, graph: Graph, match: dict):
         """
             This pass normalize FC layer
             Example: