Fix pylint warning in weight extract tool (#5629)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 15 Jul 2019 01:25:01 +0000 (10:25 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 15 Jul 2019 01:25:01 +0000 (10:25 +0900)
Fix pylint warning for print syntax in weight extract tool

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
tools/extract_weights_from_tflite/extract.py
tools/extract_weights_from_tflite/print_op.py

index afde08c..7559ba7 100755 (executable)
@@ -41,9 +41,9 @@ buffer_name_map = {}
 for t in tensors:
     if 'buffer' in t:
         if t['buffer'] in buffer_name_map:
-            print 'find conflict!!'
-            print t
-            print buffer_name_map
+            print('find conflict!!')
+            print(t)
+            print(buffer_name_map)
         comps = t['name'].split('/')
         names = []
         if len(comps) > 1 and comps[0] == comps[1]:
@@ -60,7 +60,8 @@ for i in range(len(j['buffers'])):
     b = j['buffers'][i]
     if 'data' in b:
         if i not in buffer_name_map:
-            print "buffer %d is not found in buffer_name_map. skip printing the buffer..."
+            print("buffer %d is not found in buffer_name_map. skip printing the buffer..."
+                  % i)
             continue
 
         filename = "%s.npy" % (buffer_name_map[i]['name'])
@@ -83,8 +84,8 @@ for i in range(len(j['buffers'])):
         elif len(shape) == 1:
             pass
         else:
-            print "Undefined length: conversion skipped. shape=", shape
+            print("Undefined length: conversion skipped. shape=", shape)
         #print shape, filename, n.shape
         np.save(filename, n)
 
-print "Done."
+print("Done.")
index 16aff97..a946b92 100755 (executable)
@@ -48,11 +48,11 @@ for o in operators:
     elif 'builtin_options_type' in o:
         # if we cannot find opcode_index, print option type instead.
         op_name = o['builtin_options_type']
-    print "Layer:", op_name
+    print("Layer:", op_name)
 
-    print "    Input shapes ---"
+    print("    Input shapes ---")
     for inp in o['inputs']:
-        print "      ", tensors[inp]['shape']
-    print "    Output shapes ---"
+        print("      ", tensors[inp]['shape'])
+    print("    Output shapes ---")
     for outp in o['outputs']:
-        print "      ", tensors[outp]['shape']
+        print("      ", tensors[outp]['shape'])