Publishing 2019 R1 content
[platform/upstream/dldt.git] / model-optimizer / mo / front / common / partial_infer / reshape.py
index ae61602..bb752a4 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.
@@ -30,6 +30,10 @@ def tf_reshape_shape_infer(node):
     input_shape = node.in_node(0).shape
     reshape_output = node.in_node(1).value if len(node.in_nodes()) > 1 else node.dim
 
+    # In case if Reshape operation was created with two inputs and dim attr wasn't set, we set in automatically
+    if not node.has_valid('dim'):
+        node['dim'] = reshape_output.copy()
+
     if node.in_node(0).shape is None:
         return None
 
@@ -68,8 +72,4 @@ def tf_reshape_shape_infer(node):
 
     output_shape = int64_array(output_shape)
 
-    # In case if Reshape operation was created with two inputs and dim attr wasn't set, we set in automatically
-    if not node.has_valid('dim'):
-        node['dim'] = output_shape
-
     return output_shape