Commit graph

60 commits

Author SHA1 Message Date
suleshahid
1e74475fde
Update Flatbuffer version to 2.0.6 and generate schema local. (#1374) 2022-08-25 18:01:35 +00:00
Pauline Sho
f8baced726
Support custom ops on TFLM Python interpreter (#1302)
* Support custom ops on TFLM Python interpreter

BUG=b/236154921

* code style
2022-08-02 23:44:12 +00:00
Pauline Sho
c478145e83
Fix Python interpreter destructor bug and disable invoke exception (#1254)
BUG=b/239225101

In the current Python interpreter, we do Py_DECREF(model_) in the body destructor of
InterpreterWrapper, which will be called first before member variables' destructors. This causes
an issue because destructing the MicroInterpreter (namely FreeSubgraphs) relies on some parts of
model_. This means that when the destructor of MicroInterpreter is called, the model may have
already been released, causing a segfault.

We can bypass this by not using a unique pointer for MicroInterpreter, and simply delete
interpreter_ before we call Py_DECREF(model_).

BUG=b/238459185

Some error codes are expected, such as cycles_until_run in the circular buffer op. The interpreter
wrapper shouldn't throw any exception in Python when invoke returns an error.
2022-07-15 22:12:21 +00:00
TANMAY DAS
0e825b99b3
Removed a simple typo. (#1247)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-12 23:57:25 +00:00
deqiangc
24c08505df
Fix to tflite_size (#1248)
1. Make variable name c-style following python style guide
2. Move file IO out of convert_tflite_to_html function. File io make
testing this function hard
3. Avoid file write in test and other complaints discovered in importing
   to internal

BUG=discovery these when importing
2022-07-08 21:55:20 +00:00
deqiangc
b45edd7086
Update documentation for tflite-size (#1238)
Since the html is not directly renderable by github, insert a png
to show the tool's output.

Also beautify the output slightly: calls out the number is for size
explicitly.

BUG=
2022-07-06 14:48:21 +00:00
deqiangc
2cd28c7fbc
A tool to visualize tflite file with size info in html format (#1215)
* A tool to visualize tflite file with size info in html format

* remove redundant build target

* Add main to tflite_size and this allows the following usage:

bazel run flatbuffer_size -- input.tflite output.html

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-30 18:28:52 +00:00
Pauline Sho
82f441328b
Disable ubsan for interpreter_test (#1185)
Asan and msan are already disabled, ubsan should be as well but was
initially undetected because ubsan tests are already disabled on GitHub
CI. This was caught during the internal sync.

BUG=b/234879912
2022-06-06 21:40:17 +00:00
Pauline Sho
569b80df95
Move model generation to each test in Python interpreter test (#1183)
BUG=b/234883019
2022-06-06 18:14:23 +00:00
Pauline Sho
90d62ab628
Implement Python interpreter for TFLM (#1147)
* First pass working with float input/output

* Numpy buffer input works. Got a sine graph for hello world output.

Copyright notice

* Remove static references

* Output tensors work

* Output tensors work

* bazel test works

bazel test tensorflow/lite/micro/tools:interpreter_test
--test_output=all

* Successfully built extension with Python setuptools

cd tensorflow/lite/micro/tools/interpreter_pypi
python -m build
pip install dist/example_tflm_interpreter_psho-0.0.3-cp39-cp39-linux_x86_64.whl --force-reinstall
python tests/test-interpreter.py

TestPyPi:
pip uninstall example-tflm-interpreter-psho
python -m twine upload --repository testpypi dist/example-tflm-interpreter-psho-0.0.3.tar.gz
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple example-tflm-interpreter-psho==0.0.3
python tests/test-interpreter.py

* Refactored some

* Cleaned for production and tested with conv model

* Fixed formatting

* Fixed numpy header issue for Docker. Need to fix double registration issue that's somehow only present in Docker.

* Test fix with changes in ci.yml

* Added sudo

* Added nomsan and noasan tags to python test

* Added -layering-check, used py_library instead of py_binary to generate conv model, added micro namespace

* Removed extra debug code

* Added new tests

* Changed reinterpret_steal to cast

* Addressed PR comments

* size log refactor (#1156)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Addressed PR and review comments

* adding documentation to log_binary* workflows. (#1161)

* Automated binary size log update (#1160)

* Create an allocator to manage persistent arena (#1174)

* Create an allocator to manage persistent arena

This PR corresponds to internal cl/452380512.

Create an allocator to manage persistent arena.
This is another step towards the feature of enabling the client to
have two separate memory arenas.

BUG=https://b/226971240

* Manually patch due to Makefile difference

* Fix virtual environment when building Vela for Arm Ethos-U (#1177)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Removed print statement

Co-authored-by: jwithers <jpwithers@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: TFLM-bot <tflm-github-bot@google.com>
Co-authored-by: deqiangc <86809673+deqiangc@users.noreply.github.com>
Co-authored-by: Måns Nilsson <mans.nilsson@arm.com>
2022-06-03 19:09:54 +00:00