Advait Jain 4dadd12623 Move schema version into micro_interpreter.h
This is a first (somewhat non-intuitive) step towards being able to use
clang as part of the github CI system.

The benefits of this refactor are that we avoid a dependency into
tensorflow/core which reduces the number of files that need to be
downloaded as part of a bazel build from a TFLM CI docker image.

The tflite schema version has been unchanged since at-least Oct 2018
(when tflite was moved out of tensorflow/contrib).

Progress towards preventing a repeat of https://github.com/tensorflow/tensorflow/issues/46415
2021-01-15 11:17:42 -08:00
..
2020-06-24 10:33:35 +01:00
2020-04-08 13:53:31 +02:00
2020-06-22 09:38:10 +02:00

The aim of this application is to provide a quick way to test different networks.

It contains one testcase and a default network model (network_model.h), default input data (input_data.h) and default expected output data (expected_output_data.h). The header files were created using the xxd command.

The default model is a single MaxPool2D operator, with an input shape of {1, 4, 4, 1} and an output shape of {1, 2, 2, 1}.

In order to use another model, input data, or expected output data, simply specify the path to the new header files when running make as seen below.

The variables in the specified header files (array and array length) needs to have the same name and type as the ones in the default header files. The include guards also needs to be the same. When swapping out the network model, it is likely that the memory allocated by the interpreter needs to be increased to fit the new model. This is done by using the ARENA_SIZE option when running make.

make -f tensorflow/lite/micro/tools/make/Makefile network_tester_test \
                  NETWORK_MODEL=path/to/network_model.h \
                  INPUT_DATA=path/to/input_data.h \
                  OUTPUT_DATA=path/to/expected_output_data.h \
                  ARENA_SIZE=<tensor arena size in bytes> \
                  NUM_BYTES_TO_PRINT=<number of bytes to print> \
                  COMPARE_OUTPUT_DATA=no

NETWORK_MODEL: The path to the network model header.
INPUT_DATA: The path to the input data.
OUTPUT_DATA: The path to the expected output data.
ARENA_SIZE: The size of the memory to be allocated (in bytes) by the interpreter.
NUM_BYTES_TO_PRINT: The number of bytes of the output data to print.
If set to 0, all bytes of the output are printed.
COMPARE_OUTPUT_DATA: If set to "no" the output data is not compared to the expected output data. This could be useful e.g. if the execution time needs to be minimized, or there is no expected output data. If omitted, the output data is compared to the expected output. NUM_INFERENCES: Define how many inferences that are made. Defaults to 1. \

The output is printed in JSON format using printf: num_of_outputs: 1 output_begin [ { "dims": [4,1,2,2,1], "data_address": "0x000000", "data":"0x06,0x08,0x0e,0x10" }] output_end

If there are multiple output tensors, the output will look like this: num_of_outputs: 2 output_begin [ { "dims": [4,1,2,2,1], "data_address": "0x000000", "data":"0x06,0x08,0x0e,0x10" }, { "dims": [4,1,2,2,1], "data_address": "0x111111", "data":"0x06,0x08,0x0e,0x10" }] output_end