From 0de0d0eff1813adda1ae45d3a9f3bf511b525a9b Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <yamanu@xilinx.com> Date: Wed, 16 Oct 2019 17:50:26 +0100 Subject: [PATCH] [Test] fix LFC io buf names, handle redownload better --- tests/test_basic_onnx_exec.py | 7 +++++-- tests/test_brevitas_export.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_basic_onnx_exec.py b/tests/test_basic_onnx_exec.py index 0bc05628a..9fa596fbb 100644 --- a/tests/test_basic_onnx_exec.py +++ b/tests/test_basic_onnx_exec.py @@ -15,6 +15,10 @@ mnist_onnx_local_dir = "/tmp/mnist_onnx" def test_mnist_onnx_download_extract_run(): + try: + os.remove("/tmp/" + mnist_onnx_filename) + except OSError: + pass dl_ret = wget.download(mnist_onnx_url_base + "/" + mnist_onnx_filename, out="/tmp") shutil.unpack_archive(dl_ret, mnist_onnx_local_dir) with open(mnist_onnx_local_dir + "/mnist/model.onnx", "rb") as f: @@ -32,8 +36,7 @@ def test_mnist_onnx_download_extract_run(): input_dict = {"Input3": np_helper.to_array(input_tensor)} output_dict = oxe.execute_onnx(model, input_dict) assert np.isclose( - np_helper.to_array(output_tensor), output_dict["Plus214_Output_0"], - atol=1e-3 + np_helper.to_array(output_tensor), output_dict["Plus214_Output_0"], atol=1e-3 ).all() # remove the downloaded model and extracted files os.remove(dl_ret) diff --git a/tests/test_brevitas_export.py b/tests/test_brevitas_export.py index ea5287025..0a55992cd 100644 --- a/tests/test_brevitas_export.py +++ b/tests/test_brevitas_export.py @@ -121,6 +121,10 @@ def test_brevitas_to_onnx_export_and_exec(): lfc.load_state_dict(checkpoint["state_dict"]) bo.export_finn_onnx(lfc, (1, 1, 28, 28), export_onnx_path) model = onnx.load(export_onnx_path) + try: + os.remove("/tmp/" + mnist_onnx_filename) + except OSError: + pass dl_ret = wget.download(mnist_onnx_url_base + "/" + mnist_onnx_filename, out="/tmp") shutil.unpack_archive(dl_ret, mnist_onnx_local_dir) # load one of the test vectors -- GitLab