Skip to content

Commit 2778c16

Browse files
authored
Tflite test fix (#73)
Fix tflite test - use a specific input instead of an arbitrary input tensor
1 parent 3dd2d5d commit 2778c16

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __exit__(self, *args):
2727

2828

2929
MODEL_DIR = os.path.dirname(os.path.abspath(__file__)) + "/testdata"
30+
TENSOR_DIR = MODEL_DIR
3031
script = r"""
3132
def bar(a, b):
3233
return a + b
@@ -411,11 +412,14 @@ def test_run_tflite_model(self):
411412
tflmodel = load_model(model_path)
412413
con = self.get_client()
413414
con.modelstore("tfl_model", "tflite", "cpu", tflmodel)
414-
img = np.random.random((1, 1, 28, 28)).astype(np.float32)
415+
416+
input_path = os.path.join(TENSOR_DIR, "one.raw")
417+
with open(input_path, 'rb') as f:
418+
img = np.frombuffer(f.read(), dtype=np.float32)
415419
con.tensorset("img", img)
416420
con.modelexecute("tfl_model", ["img"], ["output1", "output2"])
417421
output = con.tensorget("output1")
418-
self.assertTrue(np.allclose(output, [8]))
422+
self.assertEqual(output, [1])
419423

420424
# AI.MODELRUN is deprecated by AI.MODELEXECUTE
421425
def test_deprecated_modelrun(self):

test/testdata/one.raw

3.06 KB
Binary file not shown.

0 commit comments

Comments
 (0)