diff --git a/tests/pkg_tensorflow-lite/Makefile b/tests/pkg_tensorflow-lite/Makefile new file mode 100644 index 0000000000..41e7d7b884 --- /dev/null +++ b/tests/pkg_tensorflow-lite/Makefile @@ -0,0 +1,11 @@ +# Ensure minimal size by default +DEVELHELP ?= 0 + +include ../Makefile.tests_common + +EXAMPLE ?= hello_world + +USEPKG += tensorflow-lite +USEMODULE += tensorflow-lite-$(EXAMPLE) + +include $(RIOTBASE)/Makefile.include diff --git a/tests/pkg_tensorflow-lite/README.md b/tests/pkg_tensorflow-lite/README.md new file mode 100644 index 0000000000..9d4e754631 --- /dev/null +++ b/tests/pkg_tensorflow-lite/README.md @@ -0,0 +1,60 @@ +TensorFlow Lite sample application +================================== + +This application is taken as-is from the hello-world sample +application of TensorFlow Lite for microcontrollers. + +The original code is +[available on GitHub](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/micro/examples/hello_world). + +This application simply replicates a `sine` function from a trained model. + +To get started with TensorFlow Lite on microcontrollers, please refer to +[this page](https://www.tensorflow.org/lite/microcontrollers). + +Usage +----- + +Simply run the application on the board of your choice using: + + make BOARD= -C tests/pkg_tensorflow-lite flash term + +Then type 's' to start the application. + +Expected result +--------------- + +The application prints the values of the `sine` function: +``` +x_value: 1.0*2^-127, y_value: 1.9783614*2^-8 + +x_value: 1.2566366*2^-2, y_value: 1.3910355*2^-2 + +x_value: 1.2566366*2^-1, y_value: 1.1282844*2^-1 + +x_value: 1.8849551*2^-1, y_value: 1.5455950*2^-1 + +x_value: 1.2566366*2^0, y_value: 1.8238020*2^-1 + +x_value: 1.5707957*2^0, y_value: 1.8701699*2^-1 + +x_value: 1.8849551*2^0, y_value: 1.8547139*2^-1 + +x_value: 1.995567*2^1, y_value: 1.4683149*2^-1 + +x_value: 1.2566366*2^1, y_value: 1.1128282*2^-1 + +x_value: 1.4137159*2^1, y_value: 1.819164*2^-2 + +x_value: 1.5707957*2^1, y_value: -1.2364758*2^-5 + +x_value: 1.7278753*2^1, y_value: -1.6074185*2^-2 + +x_value: 1.8849551*2^1, y_value: -1.2982997*2^-1 + +x_value: 1.210171*2^2, y_value: -1.7928901*2^-1 + +x_value: 1.995567*2^2, y_value: -1.46367*2^0 + +x_value: 1.1780966*2^2, y_value: -1.46367*2^0 +``` diff --git a/tests/pkg_tensorflow-lite/main.cpp b/tests/pkg_tensorflow-lite/main.cpp new file mode 100644 index 0000000000..c467df5b53 --- /dev/null +++ b/tests/pkg_tensorflow-lite/main.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * + * @file + * @brief TensorFlow Lite test application + * + * @author Alexandre Abadie + */ + +/* Provide an Arduino-Like API to be able to easily reuse the code from + upstream examples */ +void setup(); +void loop(); + +int main(int argc, char* argv[]) +{ + (void)argc; + (void)argv; + + setup(); + + while (true) { + loop(); + } +} diff --git a/tests/pkg_tensorflow-lite/tests/01-run.py b/tests/pkg_tensorflow-lite/tests/01-run.py new file mode 100755 index 0000000000..9eca580148 --- /dev/null +++ b/tests/pkg_tensorflow-lite/tests/01-run.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import sys +from testrunner import run + + +def testfunc(child): + pass + + +if __name__ == "__main__": + sys.exit(run(testfunc))