diff --git a/apps/microtvm/arduino/example_project/project.ino b/apps/microtvm/arduino/example_project/project.ino index 291625309fd0..74b596245624 100644 --- a/apps/microtvm/arduino/example_project/project.ino +++ b/apps/microtvm/arduino/example_project/project.ino @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include "src/model.h" void setup() { diff --git a/apps/microtvm/arduino/example_project/src/model.c b/apps/microtvm/arduino/example_project/src/model.c index 3268e5961bc9..7acb06fa89af 100644 --- a/apps/microtvm/arduino/example_project/src/model.c +++ b/apps/microtvm/arduino/example_project/src/model.c @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #ifndef TVM_IMPLEMENTATION_ARDUINO #define TVM_IMPLEMENTATION_ARDUINO diff --git a/apps/microtvm/arduino/example_project/src/model.h b/apps/microtvm/arduino/example_project/src/model.h index be1bd5415e77..489adff0da53 100644 --- a/apps/microtvm/arduino/example_project/src/model.h +++ b/apps/microtvm/arduino/example_project/src/model.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #ifndef IMPLEMENTATION_H_ #define IMPLEMENTATION_H_ diff --git a/apps/microtvm/arduino/host_driven/project.ino b/apps/microtvm/arduino/host_driven/project.ino index 5bf13b57243e..34537d4e205f 100644 --- a/apps/microtvm/arduino/host_driven/project.ino +++ b/apps/microtvm/arduino/host_driven/project.ino @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include "src/standalone_crt/include/tvm/runtime/crt/microtvm_rpc_server.h" #include "src/standalone_crt/include/tvm/runtime/crt/logging.h" #include "src/model.h" diff --git a/apps/microtvm/arduino/host_driven/src/model.c b/apps/microtvm/arduino/host_driven/src/model.c index 5d6512e7e5d3..5b87deb526d5 100644 --- a/apps/microtvm/arduino/host_driven/src/model.c +++ b/apps/microtvm/arduino/host_driven/src/model.c @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #ifndef TVM_IMPLEMENTATION_ARDUINO #define TVM_IMPLEMENTATION_ARDUINO @@ -10,13 +29,16 @@ // Blink code for debugging purposes void TVMPlatformAbort(tvm_crt_error_t error) { for (;;) { - for (int i = 0; i < 4; i++) { - digitalWrite(LED_BUILTIN, HIGH); - delay(250); - digitalWrite(LED_BUILTIN, LOW); - delay(250); - } - delay(1000); +#ifdef LED_BUILTIN + digitalWrite(LED_BUILTIN, HIGH); + delay(250); + digitalWrite(LED_BUILTIN, LOW); + delay(250); + digitalWrite(LED_BUILTIN, HIGH); + delay(250); + digitalWrite(LED_BUILTIN, LOW); + delay(750); +#endif } } diff --git a/apps/microtvm/arduino/host_driven/src/model.h b/apps/microtvm/arduino/host_driven/src/model.h index 136b17c061cd..edc83e5123f8 100644 --- a/apps/microtvm/arduino/host_driven/src/model.h +++ b/apps/microtvm/arduino/host_driven/src/model.h @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #ifndef IMPLEMENTATION_H_ #define IMPLEMENTATION_H_ diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 44088cec2064..7297bab6405d 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import collections import functools import json diff --git a/apps/microtvm/arduino/template_project/tests/test_arduino_microtvm_api_server.py b/apps/microtvm/arduino/template_project/tests/test_arduino_microtvm_api_server.py index a316af35aacb..3dd3688fe5b4 100644 --- a/apps/microtvm/arduino/template_project/tests/test_arduino_microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/tests/test_arduino_microtvm_api_server.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from unittest import mock from pathlib import Path import sys @@ -13,11 +30,6 @@ class TestGenerateProject: DEFAULT_OPTIONS = {"arduino_cli_cmd": "arduino-cli", "arduino_board": "nano33ble"} - def test_print_c_array(self): - handler = microtvm_api_server.Handler() - c_arr = handler._print_c_array([1, 32, 32, 3]) - assert c_arr == "{1, 32, 32, 3}" - def _set_pathlib_path_exists(self, value): with mock.patch.object(Path, "exists") as mock_exists: mock_exists.return_value = value diff --git a/tests/lint/check_file_type.py b/tests/lint/check_file_type.py index 01447ac6183f..f20b3d4afbcf 100644 --- a/tests/lint/check_file_type.py +++ b/tests/lint/check_file_type.py @@ -82,6 +82,8 @@ "cl", # zephyr config file "conf", + # arduino sketch file + "ino", } # List of file names allowed @@ -129,10 +131,10 @@ # pytest config "pytest.ini", # microTVM tests - "tests/micro/zephyr/testdata/digit-2.jpg", - "tests/micro/zephyr/testdata/digit-9.jpg", - "tests/micro/zephyr/testdata/mnist-8.onnx", - "tests/micro/zephyr/testdata/ic_sample_fp32_8.npy", + "tests/micro/testdata/digit-2.jpg", + "tests/micro/testdata/digit-9.jpg", + "tests/micro/testdata/mnist-8.onnx", + "tests/micro/testdata/yes_no.tflite", # microTVM Zephyr runtime "apps/microtvm/zephyr/template_project/CMakeLists.txt.template", "apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-arm", diff --git a/tests/lint/rat-excludes b/tests/lint/rat-excludes index 5f0445134dea..3dff79c565ce 100644 --- a/tests/lint/rat-excludes +++ b/tests/lint/rat-excludes @@ -20,6 +20,9 @@ .*\.interp .*\.tokens +# microTVM test data files +testdata + # Generated modules .*\.egg-info .*gen_modules diff --git a/tests/micro/arduino/conftest.py b/tests/micro/arduino/conftest.py index a4ab46dceafb..f4e27d1458e3 100644 --- a/tests/micro/arduino/conftest.py +++ b/tests/micro/arduino/conftest.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import datetime import pathlib diff --git a/tests/micro/arduino/test_arduino_rpc_server.py b/tests/micro/arduino/test_arduino_rpc_server.py index 0b5ba07b8b33..eee4a5623cff 100644 --- a/tests/micro/arduino/test_arduino_rpc_server.py +++ b/tests/micro/arduino/test_arduino_rpc_server.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import datetime import os import pathlib @@ -165,17 +182,18 @@ def test_onnx(platform, arduino_cli_cmd, tvm_debug, workspace_dir): build_config = {"debug": tvm_debug} # Load test images. - this_dir = os.path.dirname(__file__) - digit_2 = Image.open(f"{this_dir}/testdata/digit-2.jpg").resize((28, 28)) + this_dir = pathlib.Path(os.path.dirname(__file__)) + testdata_dir = this_dir.parent / "testdata" + digit_2 = Image.open(testdata_dir / "digit-2.jpg").resize((28, 28)) digit_2 = np.asarray(digit_2).astype("float32") digit_2 = np.expand_dims(digit_2, axis=0) - digit_9 = Image.open(f"{this_dir}/testdata/digit-9.jpg").resize((28, 28)) + digit_9 = Image.open(testdata_dir / "digit-9.jpg").resize((28, 28)) digit_9 = np.asarray(digit_9).astype("float32") digit_9 = np.expand_dims(digit_9, axis=0) # Load ONNX model and convert to Relay. - onnx_model = onnx.load(f"{this_dir}/testdata/mnist-8.onnx") + onnx_model = onnx.load(testdata_dir / "mnist-8.onnx") shape = {"Input3": (1, 1, 28, 28)} relay_mod, params = relay.frontend.from_onnx(onnx_model, shape=shape, freeze_params=True) relay_mod = relay.transform.DynamicToStatic()(relay_mod) diff --git a/tests/micro/arduino/test_arduino_workflow.py b/tests/micro/arduino/test_arduino_workflow.py index bece4cb2be52..fddb47c8267c 100644 --- a/tests/micro/arduino/test_arduino_workflow.py +++ b/tests/micro/arduino/test_arduino_workflow.py @@ -1,5 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + import datetime -import os import pathlib import shutil import sys @@ -52,11 +68,11 @@ def _generate_project(arduino_board, arduino_cli_cmd, workspace_dir, mod, build_ # We MUST pass workspace_dir, not project_dir, or the workspace will be dereferenced too soon @pytest.fixture(scope="module") def project(platform, arduino_cli_cmd, tvm_debug, workspace_dir): - current_dir = os.path.dirname(__file__) + this_dir = pathlib.Path(__file__).parent model, arduino_board = conftest.PLATFORMS[platform] build_config = {"debug": tvm_debug} - with open(f"{current_dir}/testdata/yes_no.tflite", "rb") as f: + with open(this_dir.parent / "testdata" / "yes_no.tflite", "rb") as f: tflite_model_buf = f.read() tflite_model = tflite.Model.GetRootAsModel(tflite_model_buf, 0) mod, params = relay.frontend.from_tflite(tflite_model) @@ -70,16 +86,26 @@ def project(platform, arduino_cli_cmd, tvm_debug, workspace_dir): return _generate_project(arduino_board, arduino_cli_cmd, workspace_dir, mod, build_config) +def _get_directory_elements(directory): + return set(f.name for f in directory.iterdir()) + + def test_project_folder_structure(project_dir, project): - assert set(["microtvm_api_server.py", "project.ino", "src"]).issubset(os.listdir(project_dir)) + assert set(["microtvm_api_server.py", "project.ino", "src"]).issubset( + _get_directory_elements(project_dir) + ) source_dir = project_dir / "src" - assert set(os.listdir(source_dir)) == set(["model", "standalone_crt", "model.c", "model.h"]) + assert _get_directory_elements(source_dir) == set( + ["model", "standalone_crt", "model.c", "model.h"] + ) def test_project_model_integrity(project_dir, project): model_dir = project_dir / "src" / "model" - assert set(os.listdir(model_dir)) == set(["default_lib0.c", "default_lib1.c", "model.tar"]) + assert _get_directory_elements(model_dir) == set( + ["default_lib0.c", "default_lib1.c", "model.tar"] + ) def test_model_header_templating(project_dir, project): @@ -106,14 +132,16 @@ def test_import_rerouting(project_dir, project): # like a user would @pytest.fixture(scope="module") def modified_project(project_dir, project): - testdata_dir = pathlib.Path(os.path.dirname(__file__)) / "testdata" + this_dir = pathlib.Path(__file__).parent + micro_testdata_dir = this_dir.parent / "testdata" + arduino_testdata_dir = this_dir / "testdata" - shutil.copy2(testdata_dir / "project.ino", project_dir / "project.ino") + shutil.copy2(arduino_testdata_dir / "project.ino", project_dir / "project.ino") project_data_dir = project_dir / "src" / "data" project_data_dir.mkdir() for sample in ["yes.c", "no.c", "silence.c", "unknown.c"]: - shutil.copy2(testdata_dir / sample, project_data_dir / sample) + shutil.copy2(micro_testdata_dir / sample, project_data_dir / sample) return project diff --git a/tests/micro/arduino/testdata/project.ino b/tests/micro/arduino/testdata/project.ino index 175062e297b9..ebd1c5e0e650 100644 --- a/tests/micro/arduino/testdata/project.ino +++ b/tests/micro/arduino/testdata/project.ino @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include "src/model.h" #include "src/data/yes.c" #include "src/data/no.c" diff --git a/tests/micro/arduino/testdata/digit-2.jpg b/tests/micro/testdata/digit-2.jpg similarity index 100% rename from tests/micro/arduino/testdata/digit-2.jpg rename to tests/micro/testdata/digit-2.jpg diff --git a/tests/micro/arduino/testdata/digit-9.jpg b/tests/micro/testdata/digit-9.jpg similarity index 100% rename from tests/micro/arduino/testdata/digit-9.jpg rename to tests/micro/testdata/digit-9.jpg diff --git a/tests/micro/arduino/testdata/mnist-8.onnx b/tests/micro/testdata/mnist-8.onnx similarity index 100% rename from tests/micro/arduino/testdata/mnist-8.onnx rename to tests/micro/testdata/mnist-8.onnx diff --git a/tests/micro/arduino/testdata/no.c b/tests/micro/testdata/no.c similarity index 99% rename from tests/micro/arduino/testdata/no.c rename to tests/micro/testdata/no.c index ee2f07a8d99a..a3bd78a5328d 100644 --- a/tests/micro/arduino/testdata/no.c +++ b/tests/micro/testdata/no.c @@ -1,3 +1,7 @@ +/* + * This work is a derivative of "Speech Commands V2" by Google, used under CC BY 4.0. + */ + static const char input_no[1960] = { 0x80, 0x80, 0x80, 0xc5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, diff --git a/tests/micro/arduino/testdata/silence.c b/tests/micro/testdata/silence.c similarity index 99% rename from tests/micro/arduino/testdata/silence.c rename to tests/micro/testdata/silence.c index bf756399157a..bc26efa70e4f 100644 --- a/tests/micro/arduino/testdata/silence.c +++ b/tests/micro/testdata/silence.c @@ -1,3 +1,7 @@ +/* + * This work is a derivative of "Speech Commands V2" by Google, used under CC BY 4.0. + */ + static const char input_silence[1960] = { 0x23, 0x17, 0xe0, 0x3, 0x9, 0xe7, 0xe7, 0xdb, 0xcf, 0xc5, 0xe0, 0xdb, 0xc5, 0xcf, 0xef, 0xcf, 0xcf, 0xdb, 0xef, 0xdb, 0xe7, 0xc5, 0x5, 0x3, 0xfc, 0xe7, 0xf6, 0xdb, 0xcf, 0xe7, 0x9, 0xef, diff --git a/tests/micro/arduino/testdata/unknown.c b/tests/micro/testdata/unknown.c similarity index 99% rename from tests/micro/arduino/testdata/unknown.c rename to tests/micro/testdata/unknown.c index 2aef2dbcb62e..6e4df3d20b49 100644 --- a/tests/micro/arduino/testdata/unknown.c +++ b/tests/micro/testdata/unknown.c @@ -1,3 +1,7 @@ +/* + * This work is a derivative of "Speech Commands V2" by Google, used under CC BY 4.0. + */ + static const char input_unknown[1960] = { 0x78, 0x66, 0x7a, 0x63, 0x78, 0x62, 0x6d, 0x52, 0x58, 0x19, 0x0, 0xcf, 0x80, 0x80, 0x80, 0x80, 0xcf, 0xc5, 0xc5, 0xc5, 0x80, 0x80, 0x80, 0xc5, 0xc5, 0xe7, 0xe0, 0x80, 0x80, 0xc5, 0x80, 0xcf, diff --git a/tests/micro/arduino/testdata/yes.c b/tests/micro/testdata/yes.c similarity index 99% rename from tests/micro/arduino/testdata/yes.c rename to tests/micro/testdata/yes.c index 9b500624bff0..ec18f20e46cf 100644 --- a/tests/micro/arduino/testdata/yes.c +++ b/tests/micro/testdata/yes.c @@ -1,3 +1,7 @@ +/* + * This work is a derivative of "Speech Commands V2" by Google, used under CC BY 4.0. + */ + static const char input_yes[1960] = { 0x7c, 0x66, 0x79, 0x65, 0x7d, 0x67, 0x7c, 0x67, 0x7c, 0x66, 0x7c, 0x67, 0x7c, 0x67, 0x7d, 0x66, 0x7c, 0x67, 0x7d, 0x66, 0x7c, 0x67, 0x7d, 0x66, 0x7c, 0x67, 0x7d, 0x67, 0x7d, 0x67, 0x7d, 0x67, diff --git a/tests/micro/arduino/testdata/yes_no.tflite b/tests/micro/testdata/yes_no.tflite similarity index 100% rename from tests/micro/arduino/testdata/yes_no.tflite rename to tests/micro/testdata/yes_no.tflite diff --git a/tests/micro/zephyr/test_zephyr.py b/tests/micro/zephyr/test_zephyr.py index b84a15225f7a..013ebcd2e97b 100644 --- a/tests/micro/zephyr/test_zephyr.py +++ b/tests/micro/zephyr/test_zephyr.py @@ -231,18 +231,18 @@ def test_onnx(temp_dir, platform, west_cmd, skip_build, tvm_debug): model, zephyr_board = PLATFORMS[platform] build_config = {"skip_build": skip_build, "debug": tvm_debug} - # Load test images. - this_dir = os.path.dirname(__file__) - digit_2 = Image.open(f"{this_dir}/testdata/digit-2.jpg").resize((28, 28)) + this_dir = pathlib.Path(os.path.dirname(__file__)) + testdata_dir = this_dir.parent / "testdata" + digit_2 = Image.open(testdata_dir / "digit-2.jpg").resize((28, 28)) digit_2 = np.asarray(digit_2).astype("float32") digit_2 = np.expand_dims(digit_2, axis=0) - digit_9 = Image.open(f"{this_dir}/testdata/digit-9.jpg").resize((28, 28)) + digit_9 = Image.open(testdata_dir / "digit-9.jpg").resize((28, 28)) digit_9 = np.asarray(digit_9).astype("float32") digit_9 = np.expand_dims(digit_9, axis=0) # Load ONNX model and convert to Relay. - onnx_model = onnx.load(f"{this_dir}/testdata/mnist-8.onnx") + onnx_model = onnx.load(testdata_dir / "mnist-8.onnx") shape = {"Input3": (1, 1, 28, 28)} relay_mod, params = relay.frontend.from_onnx(onnx_model, shape=shape, freeze_params=True) relay_mod = relay.transform.DynamicToStatic()(relay_mod) diff --git a/tests/micro/zephyr/testdata/digit-2.jpg b/tests/micro/zephyr/testdata/digit-2.jpg deleted file mode 100644 index b709a206b8d7..000000000000 Binary files a/tests/micro/zephyr/testdata/digit-2.jpg and /dev/null differ diff --git a/tests/micro/zephyr/testdata/digit-9.jpg b/tests/micro/zephyr/testdata/digit-9.jpg deleted file mode 100644 index 6ce9cde3b322..000000000000 Binary files a/tests/micro/zephyr/testdata/digit-9.jpg and /dev/null differ diff --git a/tests/micro/zephyr/testdata/mnist-8.onnx b/tests/micro/zephyr/testdata/mnist-8.onnx deleted file mode 100644 index fc1a3f733c6e..000000000000 Binary files a/tests/micro/zephyr/testdata/mnist-8.onnx and /dev/null differ