[nnpkg_tools] gen_golden.py can run on tensorflow 2.0 (#8778)
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Wed, 6 Nov 2019 04:26:10 +0000 (13:26 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 6 Nov 2019 04:26:10 +0000 (13:26 +0900)
`tf.contrib.framework.get_placeholders` is replaced with own implementation.
`gen_golden.py` can run on tensorflow 2.0.

Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
tools/nnpackage_tool/gen_golden/README.md
tools/nnpackage_tool/gen_golden/gen_golden.py [changed mode: 0644->0755]

index d24202f..8e1ae97 100644 (file)
@@ -5,8 +5,7 @@ It generates random inputs and run tensorflow, then save input and output in our
 
 ## Prerequisite
 
-Install tensorflow 1.x. It is tested with tensorflow 1.14.
-TensorFlow 2.x will not work since `contrib` is removed.
+Install tensorflow >= 1.12. It is tested with tensorflow 1.13, 1.14 and 2.0.
 
 ## Usage
 
old mode 100644 (file)
new mode 100755 (executable)
index d1e7bec..d79fddc
@@ -37,19 +37,14 @@ if __name__ == '__main__':
         tf.import_graph_def(graph_def, name='')
 
     # identify inputs and outputs
-    inputs = []
-    inputs = [t for t in tf.contrib.framework.get_placeholders(graph)]
-
     ops = graph.get_operations()
+    inputs = [op.outputs[0] for op in ops if op.type == "Placeholder"]
     uses = {}
-
     for op in ops:
         uses[op.name] = 0
-
     for op in ops:
         for producer in op.inputs:
             uses[producer.name.replace(':0', '')] = int(uses.get(producer.name, 0)) + 1
-
     output_names = [k for k, v in uses.items() if v == 0]
 
     # gen random input and run