Commit graph

20 commits

Author SHA1 Message Date
Esun Kim
ab68b206b0
Refactor t2-20 (#3387) 2026-01-30 18:27:00 +00:00
David Davis
3d4cdc19fb
Add REDUCE_MIN to reduce kernel (#3113)
@tensorflow/micro

Add the REDUCE_MiN operator to the reduce kernel.
Refactor reduce kernel to decrease number of methods in tflite namespace. Add REDUCE_MIN unit tests.
Fix unit test axis data to match tensor shape.
Make Xtensa reduce kernel use reference common code for REDUCE_MIN.
Update all op resolvers.

bug=fixes #3108
2025-08-05 22:11:17 +00:00
Austin Foxley
4bcc144fc8
xtensa: Add BUILD file and workspace for nnlib_hifi4 (#2239)
The optimized kernel selection expects a lib target to be present in third_party/xtensa/nnlib_hifi4 so provide an alias there that maps to an external repository.

Provide a build file to be used as the root of the nnlib_hifi4 repository and add to WORKSPACE. No build is done using this lib yet as there is no xtensa toolchain available in bazel just yet.

BUG=None
2023-09-22 19:54:38 +00:00
Steven Toribio
e344f4b6bb
Regenerates Integration_Test and depricates AllOpsResolver (#1969)
This PR does the following: 

This cl finishes the depreciation of AllOpsResolver in TFLM and then regenerate generate_per_layer test using PythonOpsResolver instead of AllOpsResolver after adding it to the MakoTemplate. 

[command used to regenerate integration_test](https://b.corp.google.com/issues/245770006#comment1)

[doc for changes](https://docs.google.com/document/d/1vafCGaFGGBauAssAdFABtmgpiRju2V3isioZfLMgeEc/edit?resourcekey=0-pc-aJl3TPZ7NcO9RxrNsrA#)

BUG=[b/276918689](https://b.corp.google.com/issues/276918689)
2023-05-15 17:36:16 +00:00
Steven Toribio
6a1803eae7
remove usage of AllOpsResolver (#1947)
Gets rid of all references/usage of AllOpsResolver in the TFLM repo

[corresponding google3 cl](https://critique.corp.google.com/cl/528512732)

BUG=[b/280326818](https://b.corp.google.com/issues/280326818)
2023-05-03 02:07:45 +00:00
TANMAY DAS
c369762160
Block slow tests for hifi5 and hifi3z. (#1827)
We need to block the following tests as they are making the CI test pipeline to be very slow.

The following tests are taking much longed in `hifi3z`.
```
feature_provider_mock_test	20.291s
feature_provider_test	20.877s
person_detection_test	21.654s
micro_features_generator_test	33.685s
simple_features_generator_test	129.49s
```

The following tests are taking much longed in `hifi5`
```
micro_features_generator_test	11.8s
simple_features_generator_test	98.411s
pytorch_to_tflite_test	173.542s
```
BUG=http://b/273538414
2023-03-15 07:28:18 +00:00
TANMAY DAS
c4df142c4e
Remove HIFI4_INTERNAL from the code completely.
BUG=https://b.corp.google.com/issues/239852051

This PR when land on google3, will not fail any CI build (this is a experimental CL to support this : https://critique.corp.google.com/cl/492504595)
2022-12-04 10:22:05 +00:00
TANMAY DAS
680b3356d2
Change the xtensa tests to be able to run from the parent of tflm-micro/ directory.
This is a follow up PR for [1446](https://github.com/tensorflow/tflite-micro/pull/1446). Once [1446](https://github.com/tensorflow/tflite-micro/pull/1446) is merged, this pr is going to run xtensa tests from the  /opt (parent of the tflite-micro directory) and we are doing this to be consistent with our internal CI Build. 

BUG=http://b/244204467
2022-09-28 03:30:00 +00:00
Vamsi Krishna Manchala
6fdade1aed
Update TFLM examples, kernels and integration tests to clean-up the usage of ErrorReporter
This PR updates remainder of the TFLM examples, all the kernels and integration tests to remove the usage of ErrorReporter as per the changes made to the TFLM Framework API in https://github.com/tensorflow/tflite-micro/pull/1415; replaces TF_LITE_REPORT_ERROR with MicroPrintf.

BUG=http://b/192091017, http://b/245802069
2022-09-20 20:46:26 +00:00
sasapetr
07a2624796
Fix linter issues in a few files. (#1268)
* Fix linter issues in a few files.

* restore file whose source of truth is the upstream TF repo.

Co-authored-by: Advait Jain <advaitjain@google.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-21 20:47:45 +00:00
Steven Toribio
dc09835ce3
TF_LITE_MICRO_EXPECT_EQ / TF_LITE_MICRO_EXPECT_NE type checking (#1131)
* changed TF_LITE_MICRO_EXPECT_* macros to check for int type inputs using std::is_same and decltype.

* fix cpplint formatting

* more cpplint changes

* x86 compiler debug

* more x86 test debug

* debugging x86

* trying typeid instead of decltype/is_same combo

* trying typeid instead of decltype/is_same combo

* trying decltype/is_same again

* trying decltype/is_same again

* trying decltype/is_same again

* trying decltype/is_same again

* debug

* testing #error

* testing

* testing

* testing

* testing

* testing

* trying

* fixed cpplint error

* fixing github formatting presubmit error

* reverting changes

* isolated test to try changes to macro on

* Expect equal changes based on pr and bugonizer suggestions from Ting and Deqiang

* figuring out why changes don't compile

* syntax error

* syntax error

* debugging

* fixed control flow mistake

* Done with EQ macro time for NE

* wrote changes to NE based on EQ changes

* tested NE/EQ and then resotred file used for isolated testing back to what it was in main branch

* formating change for git style check presubmit

* formating change for git style check presubmit

* formating change for git style check presubmit

* refactored the parts of x86 and kernal test that weren't compatible with change. Replaced with EXPECT_NEAR equivalents using a very small epsilon

* git presubmit style formatting changes

* git presubmit style formatting changes

* git presubmit style formatting changes

* git presubmit style formatting changes

* bazel test fixes for presubmit

* change include iostream to type_traits for is_same

* changed .0.0000000001f to 1e-5f in test for to make it easier to read

* rolling back changes to all test files

* changed to EXPECT_EQ and EXPECT_NE to use std::numeric_limits<decltype(delta)>::epsilon()

* control flow fix

* control flow fix

* control flow fix

* debugging

* debugging

* debugging

* debugging

* debugging

* debugging compile error

* reverting EXPECT_NE to prev change and testing EQ seperately

* presubmit github formatting change

* reverting example to test to main

* git fromat fix for presubmit

* git fromat fix for presubmit

* changing is_same to is_floating_point to make code easier to read

* changing is_same to is_floating_point to make code easier to read

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* not using NEAR like implementation for NE due to issues with Null_ptrs used in NE test. But honestly no current test use EXPECT_NE with floats or doubles. But in case they do added error message suggestion users use EXPECT_NEAR for Float double not equals testing

* not using NEAR like implementation for NE due to issues with Null_ptrs used in NE test. But honestly no current test use EXPECT_NE with floats or doubles. But in case they do added error message suggestion users use EXPECT_NEAR for Float double not equals testing

* logic error fix for if statement

* returning test file used to test macro changes back to orginal

* changed based on cr suggestions by deqiang

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* typo in a string

* fixed all test that used nullptr's with EXPECT_NE to use EXPECT macro instead

* github style presubmit fixes

* github style presubmit fixes

* github style presubmit fixes

* fixing compiler errors non x86 and accidental change to a test file

* channing EXPECT_NE in helloworld that was reverted

* fixing presubmit

* fixing style presubmit

* fixing presubmit

* changing TF_LITE_MICRO_EXPECT to be consistent

* accidentally changed a variable name

* changing all EXPECT to EXPECT(PTR != nullptr)

* irrevlavent EXPECT macro usage

* changing one ptr != nullptr to expect(ptr)

* style fixes for presubmit

* style fixes for presubmit

* fixing file from merge conflict

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-21 00:03:29 +00:00
Ting Yan
2d31efb836
Limit pytorch to tflite convertion test to HIFI5 only (#1130) 2022-05-12 17:31:36 +00:00
Niranjan Yadla
02f0d05f5f
Pytorch to tflite conversion (#1029)
* Cadence: Pytorch(mobilenet_v2) to tflite quantized

Describved two methos to convert from pytorch to tflite
1. Using TinyNN tool
2. Using pytorch to onnx to tf(saved_model) to
tflite(float32)/tflite(int8 quantized)

* Update pytorch_to_tflite_test.cc

* Update pytorch_images_dog_jpg.cc

* Remove unnecessary space

* Change HIFI4 and HIFI4_INTERNAL #ifndef locations and apply clang-format

Co-authored-by: Ting Yan <94130036+tingyan19@users.noreply.github.com>
2022-05-11 01:41:01 +00:00
Advait Jain
76203b70ac
Disable test that takes > 5mins to run locally. (#803)
BUG=#802

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-12-17 02:26:07 +00:00
Niranjan Yadla
d8557742c5
Enable microspeech_lstm xtensa example (#780)
BUG=issue #715

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-12-13 21:14:15 -08:00
Måns Nilsson
28034b0213
Handle nullptr bias in fully_connected op (#590)
* Handle nullptr bias in fully_connected op

* Validate tensor index in GetEvalInput.
* Check for nullptr bias tensor in fully connected kernel.

Change-Id: I5d52cd0ddc40399e3ddd1b37010e9db1b2ef1876

* Update fully_connected kernel related to null bias

Adds null bias unit tests for fully connected.
Undoes changes (from first commit of the PR, this is the second commit)
in tensorflow/lite/kernels/kernel_util.* (to be done in another PR).

* Add ValidateTensorIndexing to lite/kernel/micro/kernel_util

* Fix formatting error in Bazel Build file

* small style-related changes.

* Fix the Xtensa kernels as well.

* Patch nnlib (hifi4 and hifi5) to allow null bias for fully connected.

This is groundwork towards merging https://github.com/tensorflow/tflite-micro/pull/590

BUG=#589 and http://b/205306469

* format the code.

* updates since we no longer depend on lite/kernel_utils.h

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
Co-authored-by: Advait Jain <advaitjain@google.com>
2021-11-23 00:24:37 +00:00
Advait Jain
f294072854
Fix hifi4 build with reference kernels. (#681)
The lstm kernel is only available when `OPTIMIZED_KERNEL_DIR=xtensa`.

https://github.com/tensorflow/tflite-micro/pull/643 fixed part of the build, but the xtensa lstm example was still failing with the reference kernels.

Tested that the following command passes with this change, and fails without it:
```
make -f  tensorflow/lite/micro/tools/make/Makefile TARGET=xtensa TARGET_ARCH=hifi4 XTENSA_CORE=F1_190305_swupgrade build -j8
```

BUG=http://b/204814982
2021-11-12 14:19:49 -08:00
nyadla-sys
0ab354a3a6
lstm:Cadence copyright update (#559) 2021-10-01 10:34:54 -07:00
nyadla-sys
166fd3a6ab
lstm:xtensa:update colab link and model.zip (#512)
* lstm:xtensa:update colab link and model.zip

BUG=cleanup

* small updates to the documentation.

Co-authored-by: Advait Jain <advaitjain@google.com>
Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-09-17 20:11:33 +00:00
nyadla-sys
52bd2f2c07
lstm:training micro speech lstm model (#473)
* lstm:training micro speech lstm model

Signed-off-by: Niranjan Yadla <nyadla@cadence.com>

* Updated Makefile.inc

* Removed files that should not be needed

 * The model file is directly committed into the repository (and converted
   to model.cc and model.h during the Makefile build)
 * So, we do not need model.zip in the train folder and we do not need
   model.cc and model.h either.
 * We do need bazel support for this example (removed the BUILD file).

Also, chmod -x for some of the files.

* Remove unnecessary maxdepth parameter.

* ADD LICENSE file

Co-authored-by: Advait Jain <advaitjain@google.com>
2021-09-13 16:33:15 +00:00