[nnc] Fix importer test (#2457)
authorАндрей Шедько/AI Tools Lab /SRR/Assistant Engineer/삼성전자 <a.shedko@partner.samsung.com>
Fri, 30 Nov 2018 12:09:04 +0000 (15:09 +0300)
committerEfimov Alexander/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Fri, 30 Nov 2018 12:09:04 +0000 (15:09 +0300)
Fixed exit code in importer test, added a version check so that the test
is not run on older TF

Signed-off-by: Andrei Shedko <a.shedko@partner.samsung.com>
contrib/nnc/unittests/tflite_frontend/test_data/gen_test.py

index 43a2486..bc9cb6a 100755 (executable)
@@ -2,10 +2,13 @@
 import numpy as np
 import sys
 try:
+    from distutils.version import LooseVersion, StrictVersion
     import tensorflow as tf
+
+    if (LooseVersion(tf.VERSION) < LooseVersion("1.11.0")): raise (Exception("Wrong Version"))
 except:
-    print("!! Tensorflow not installed, tflite frontend test not generated", file=sys.stderr)
-    exit(999)
+    print("!! Tensorflow v 1.11 not installed, tflite frontend test not generated", file=sys.stderr)
+    exit(1)
 
 resDir = sys.argv[1]
 if resDir[-1]!="/": resDir +="/"
@@ -22,8 +25,6 @@ out0 = tf.identity(Y, name="out")
 # Filter the input image.
 with tf.Session() as sess:
     out = sess.run(out0, feed_dict = {"input:0": np.ones((1, 28, 28, 1)).astype(np.float32)})
-    # print(sess.graph_def)
-
     frozen_graphdef = tf.graph_util.convert_variables_to_constants(
         sess, sess.graph_def, ["out"])
     tflite_model = tf.contrib.lite.TocoConverter(