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

TF Lite unit (kernel) tests CMake build fix #51406

Closed

Conversation

madaosik
Copy link
Contributor

The recent changes in the TF Lite kernel tests architecture were reflected in Bazel build system but not in CMake, leading to runtime failure when built using this platform.

This change updates the TF Lite kernel tests CMake build configuration and adds a minor check for easier future debugging.

@google-ml-butler google-ml-butler bot added the size:M CL Change Size: Medium label Aug 10, 2021
@google-cla
Copy link

google-cla bot commented Aug 10, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Aug 10, 2021
@madaosik
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Aug 10, 2021
@abattery abattery requested a review from terryheo August 10, 2021 09:17
@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label Aug 10, 2021
@gbaned gbaned self-assigned this Aug 10, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Aug 10, 2021
@gbaned gbaned added the comp:lite TF Lite related issues label Aug 18, 2021
@madaosik madaosik force-pushed the tflite-kernel-tests-cmake-build-fix branch from d31edf9 to 44f505f Compare September 29, 2021 08:59
@@ -29,6 +29,8 @@ constexpr char KernelTestDelegateProviders::kUseSimpleAllocator[];

KernelTestDelegateProviders::KernelTestDelegateProviders()
: delegate_list_util_(&params_) {
TFLITE_TOOLS_CHECK(delegate_list_util_.GetCount() > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that the test could run without any delegate providers. So, this check could fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to run the test without any delegate provider. It is compulsory, though, to have at least DefaultExecutionProvider instance available acting as a "dummy delegate" providing the common parameters and flags. Without it the test fails during runtime based on the missing "help" parameter (as described here). I admit, nevertheless, that the error message was rather misleading, so I updated it in the latest commit.


set(DELEGATE_PROVIDERS
${DELEGATE_PROVIDERS_SUPP}
${TFLITE_SOURCE_DIR}/tools/delegates/coreml_delegate_provider.cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some delegate providers are only compilable on certain platforms, e.g., the CoreML delegate might be only compilable for iOS with certain flags as shown by https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/tools/delegates/BUILD#L132-L153 when using Bazel. So, we might need additional CMake rules to build these delegate providers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. Also NNAPI delegate should available only for Android

Copy link
Contributor Author

@madaosik madaosik Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let me put it another way. The tensorflow/lite/CMakeLists.txt provides various options using which the NNAPI, GPU and XNNPACK delegates can be enabled/disabled. As the user can toggle these options even after the configure phase is finished, it is required to have them in the DELEGATE_PROVIDERS list. Conversely and admittedly, the delegates not mentioned in the root CMakeLists (Hexagon, External, GPU) are irrelevant and therefore were removed in the latest commit.

@@ -157,6 +157,9 @@ class ProvidedDelegateList {
return CreateAllRankedDelegates(*params_);
}

// Returns the count of referenced delegates in providers_ variable
const int GetCount();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might simply inline the implementation here? Btw, if the change to tensorflow/lite/kernels/test_delegate_providers.cc were dropped, this function would be no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation has been inlined in the latest commit. The answer is yes. However I would suggest keeping it for the reasons discussed above.

@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label Oct 3, 2021
Copy link
Contributor

@multiverse-tf multiverse-tf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overall looks good to me. But I'd like to wait for @terryheo's approval as he is the owner of TFLite CMake support.

@@ -68,27 +85,34 @@ if(NOT _TFLITE_ENABLE_NNAPI)
${TFLITE_SOURCE_DIR}/nnapi/nnapi_util.cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to keep "if(NOT _TFLITE_ENABLE_NNAPI)" here?

@madaosik madaosik closed this Oct 11, 2021
PR Queue automation moved this from Assigned Reviewer to Closed/Rejected Oct 11, 2021
@madaosik
Copy link
Contributor Author

Merged already as part of #52110.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:lite TF Lite related issues size:M CL Change Size: Medium
Projects
PR Queue
  
Closed/Rejected
Development

Successfully merging this pull request may close these issues.

None yet

5 participants