diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2022-09-26 13:31:43 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2022-10-07 16:02:07 +0100 |
commit | ba5fad356a926d5e1c6e0fe6b546a310230cc5a8 (patch) | |
tree | 10e3e127c091da90d591253fd55e8566c0b61e7a /README.md | |
parent | a0848c6edbf37034e280a670bdd2f990fdf796da (diff) | |
download | reference_model-ba5fad356a926d5e1c6e0fe6b546a310230cc5a8.tar.gz |
Add IModelRunner interface to TOSA Reference Model
* Added IModelRunner interface using pimpl idiom, which allows a user to
initialize, configure and run the model.
* Added unit tests for IModelRunner.
* Added doctest as third-party submodule.
* Added user options to specify paths for dependencies.
* Moved general func_config functions to separate utility, which removes
cxxopts dependency.
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: If42f1f82cd6dadf18911a48dcd5fa579b719aff2
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -33,6 +33,7 @@ The model includes the following git submodules: * TOSA Serialization Library * JSON for Modern C++ - 3.8.0 * Eigen 3.3.7 +* doctest 2.4.9 (When building unit tests) The model is written using C++17 and has been primarily tested on Ubuntu x86_64 18.04 LTS Linux @@ -84,12 +85,18 @@ make ``` The resulting executable will be named: -`reference_model/tosa_reference_model`. CMake only needs to be re-run -if the build environment changes (e.g., new dependencies or source -files). Code changes that do not affect these build rules can be +`reference_model/tosa_reference_model`. This executable can be disabled with +`-DBUILD_TOSA_REFERENCE_MODEL_EXECUTABLE=NO`. +A static library will also be generated by default as follows: +`reference_model/libtosa_reference_model_lib.a`. +To make this a shared library (.so) add the following option +`-DBUILD_SHARED_LIBS=YES`. + +CMake only needs to be re-run if the build environment changes (e.g., new dependencies or source +files). Code changes that do not affect these build rules can be rebuilt simply using `make`. -## Usage +## Executable Usage The inputs to the *TOSA Reference Model* consist of a FlatBuffers file containing the serialized subgraph, a JSON test descriptor that describes @@ -145,7 +152,7 @@ format into output tensors specified by "ofm_file". For example, you can generate new output .npy by: ``` bash ./build/reference_model/tosa_reference_model \ - --test_desc=examples/test_add_1x4x4x4_f32/flatbuffer-tflite/desc.json + --test_desc=examples/test_add_1x4x4x4_f32/flatbuffer-tflite/desc.json \ --ofm_file=out.npy ``` @@ -170,6 +177,22 @@ may cause small differences in output for floating-point tests and differences in quantized scaling between TensorFlow Lite and the TOSA Specification may cause differences in quantized integer tests. +## ModelRunner API + +As an alternative to the executable described above, +the model_runner.h is provided which can be used to invoke the +TOSA Reference Model easily within C++. +A sample of this class and how it can used can be found in +[model_runner_simple_sample.cpp](reference_model/samples/model_runner_simple_sample.cpp). +This sample can be compiled by adding `-DBUILD_MODEL_RUNNER_SAMPLE=YES` to the CMake command +and executed by running `./build/reference_model/model_runner_sample`. + +### ModelRunner API Unit Tests +Unit test are generated by default for the ModelRunner. +This executable can be disabled by adding`-DBUILD_TOSA_REFERENCE_MODEL_TESTS=NO` to the CMake command. +This executable can be run using +`./build/reference_model/unit_tests` and requires the submodule doctest. + ## Debugging The debugging facility can be enabled by setting a debug scope and @@ -219,7 +242,7 @@ programatically compared with output of SUTs to validate them. The test infrastructure needs installing before being used. It is recommended to create a [python virtual environment](https://docs.python.org/3/library/venv.html) -and then install the TOSA Unit Test infrastruture from the root of the +and then install the TOSA Unit Test infrastructure from the root of the reference model: ``` bash |