Skip to content

Commit cb9116f

Browse files
author
hhsecond
committed
more tests
1 parent bd049f1 commit cb9116f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,25 @@ def test_run_onnxdl_model(self):
141141
con.modelrun("onnx_model", ["input"], ["output"])
142142
outtensor = con.tensorget("output")
143143
self.assertTrue(np.allclose(outtensor, [4.0]))
144+
145+
def test_run_pytorch_model(self):
146+
model_path = os.path.join(MODEL_DIR, 'pt-minimal.pt')
147+
ptmodel = load_model(model_path)
148+
con = self.get_client()
149+
con.modelset("pt_model", Backend.torch, Device.cpu, ptmodel)
150+
con.tensorset('a', [2, 3, 2, 3], shape=(2, 2), dtype=DType.float)
151+
con.tensorset('b', [2, 3, 2, 3], shape=(2, 2), dtype=DType.float)
152+
con.modelrun("pt_model", ["a", "b"], "output")
153+
output = con.tensorget('output', as_numpy=False)
154+
self.assertTrue(np.allclose(output.value, [4, 6, 4, 6]))
155+
156+
def test_run_tflite_model(self):
157+
model_path = os.path.join(MODEL_DIR, 'mnist_model_quant.tflite')
158+
tflmodel = load_model(model_path)
159+
con = self.get_client()
160+
con.modelset("tfl_model", Backend.tflite, Device.cpu, tflmodel)
161+
img = np.random.random((1, 1, 28, 28)).astype(np.float)
162+
con.tensorset('img', img)
163+
con.modelrun("tfl_model", "img", ["output1", "output2"])
164+
output = con.tensorget('output1')
165+
self.assertTrue(np.allclose(output, [8]))
3.13 MB
Binary file not shown.

0 commit comments

Comments
 (0)