Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(bazel): always build with TF_LITE_STATIC_MEMORY #2945

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

rkuester
Copy link
Contributor

Add TF_LITE_STATIC_MEMORY to the defines set globally for TFLM builds in
Bazel. TFLM always builds with this set in Make, and it appears to have
been an oversight that it wasn't set during Bazel builds. Not having it
set in Bazel caused some unit tests to pass under Bazel that failed
under Make.

At the same time, add -fno-exceptions. This flag is also always set in
Make builds. Without it, setting TF_LITE_STATIC_MEMORY breaks the build.
TF_LITE_STATIC_MEMORY triggers TF_LITE_REMOVE_VIRTUAL_DELETE in
t/l/m/compatibility.h, which makes operator delete private in certain
classes. When exceptions are enabled, a placement new with those classes
is allowed to throw an exception, and operator delete is implicitly
called during the unwind. The build breaks because operator delete can't
be called if it's private. Disabling exceptions eliminates the unwind
code that calls operator delete implicitly, and thus the build succeeds.

In any case, -fno-exceptions should have been used in Bazel builds,
matching the flags used in Make and the no-exceptions design requirement
of the TFLM project.

BUG=#2636

Add TF_LITE_STATIC_MEMORY to the defines set globally for TFLM builds in
Bazel. TFLM always builds with this set in Make, and it appears to have
been an oversight that it wasn't set during Bazel builds. Not having it
set in Bazel caused some unit tests to pass under Bazel that failed
under Make.

At the same time, add -fno-exceptions. This flag is also always set in
Make builds. Without it, setting TF_LITE_STATIC_MEMORY breaks the build.
TF_LITE_STATIC_MEMORY triggers TF_LITE_REMOVE_VIRTUAL_DELETE in
t/l/m/compatibility.h, which makes operator delete private in certain
classes. When exceptions are enabled, a placement new with those classes
is allowed to throw an exception, and operator delete is implicitly
called during the unwind. The build breaks because operator delete can't
be called if it's private. Disabling exceptions eliminates the unwind
code that calls operator delete implicitly, and thus the build succeeds.

In any case, -fno-exceptions should have been used in Bazel builds,
matching the flags used in Make and the no-exceptions design requirement
of the TFLM project.
@rkuester rkuester requested a review from a team as a code owner November 27, 2024 19:53
@rkuester rkuester requested a review from suleshahid November 27, 2024 19:54
@rkuester rkuester marked this pull request as draft November 27, 2024 20:23
rkuester added a commit to rkuester/tflite-micro that referenced this pull request Nov 28, 2024
Remove the test that incorrectly asserts the output tensor is
initially all zeros. The tensor is allocated from a shared memory
arena, and its initial state is not guaranteed to be zero. This
test eventually failed due to variations in memory allocation
during build and runtime; see the failed checks in tensorflow#2945.

BUG=tensorflow#2636
mergify bot pushed a commit that referenced this pull request Dec 2, 2024
…2946)

Remove the test that incorrectly asserts the output tensor is
initially all zeros. The tensor is allocated from a shared memory
arena, and its initial state is not guaranteed to be zero. This
test eventually failed due to variations in memory allocation
during build and runtime; see the failed checks in #2945.

BUG=#2636
@rkuester rkuester marked this pull request as ready for review December 2, 2024 19:55
@mergify mergify bot merged commit bff601a into tensorflow:main Dec 3, 2024
92 of 93 checks passed
@rkuester rkuester deleted the feat-compression branch December 4, 2024 01:42
@rkuester rkuester restored the feat-compression branch December 4, 2024 01:42
@rkuester rkuester deleted the feat-compression branch December 4, 2024 01:51
mergify bot pushed a commit that referenced this pull request Dec 5, 2024
Fixes unused import and a required dep for hexdump. Also adds docstring for .bzl file. These changes are needed for some internal checks.

Additionally, temporarily reverts #2945, to help with internal fix.

BUG=quick fix
mergify bot pushed a commit that referenced this pull request Dec 6, 2024
Re enabling static memory for bazel builds, see #2945.

BUG=static mem for bazel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants