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

Fixed unlinking the shared memory region on non-Android platform #48475

Merged

Conversation

robert-kalmar
Copy link
Contributor

Current implementation does not unlink the shared memory region for non-Android platforms.

@google-ml-butler google-ml-butler bot added the size:S CL Change Size: Small label Apr 12, 2021
@google-cla google-cla bot added the cla: yes label Apr 12, 2021
@gbaned gbaned self-assigned this Apr 12, 2021
@gbaned gbaned added the comp:lite TF Lite related issues label Apr 12, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Apr 12, 2021
@gbaned gbaned requested a review from abattery April 12, 2021 15:20
@gbaned gbaned added the awaiting review Pull request awaiting review label Apr 22, 2021
@abattery abattery requested review from miaowang14 and removed request for abattery April 22, 2021 21:52
@abattery
Copy link
Contributor

@miaowang14 could you review this PR?

@abattery abattery added the TFLiteNNAPIDelegate For issues related to TFLite NNAPI Delegate label Apr 22, 2021
tensorflow/lite/nnapi/nnapi_implementation.cc Show resolved Hide resolved
// Each call to ASharedMemory_create produces a unique memory space, hence
// name should not be used to create the shared memory file, otherwise
// name should not be unique, otherwise

Choose a reason for hiding this comment

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

"should be unique"?

Also, could you reformat this section?

tensorflow/lite/delegates/nnapi/nnapi_delegate.cc Outdated Show resolved Hide resolved
#else
// Each call to ASharedMemory_create produces a unique memory space, hence
// name should not be used to create the shared memory file, otherwise
// two calls to create memory regions using the same 'name', will collide.

Choose a reason for hiding this comment

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

maybe just simplify these comments to something like "Find a unique file name"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, what about this one:
// For non-Android platforms ASharedMemory_create needs unique name to
// create a shared memory object (see nnapi_implementation.cc).

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Apr 27, 2021
Copy link

@miaowang14 miaowang14 left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Apr 27, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Apr 27, 2021
@gbaned gbaned removed the awaiting review Pull request awaiting review label Apr 28, 2021
// create a shared memory object (see nnapi_implementation.cc).
char shm_name_buffer[L_tmpnam];
if (tmpnam(shm_name_buffer) == nullptr) {
throw new std::runtime_error("NN Memory failed");

Choose a reason for hiding this comment

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

The exception here is causing problems and blocking the merge.

Could you remove the exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The exception is removed.

@gbaned gbaned removed the ready to pull PR ready for merge process label Apr 30, 2021
@gbaned
Copy link
Contributor

gbaned commented May 3, 2021

@robert-kalmar Can you please check @miaowang14's comments and keep us posted ? Thanks!

@gbaned gbaned added the stat:awaiting response Status - Awaiting response from author label May 3, 2021
@gbaned
Copy link
Contributor

gbaned commented May 10, 2021

@robert-kalmar Any update on this PR? Please. Thanks!

@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label May 10, 2021
@google-ml-butler google-ml-butler bot added the ready to pull PR ready for merge process label May 10, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label May 10, 2021
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process stat:awaiting response Status - Awaiting response from author labels May 11, 2021
@@ -185,6 +185,9 @@ class NNMemory {
size_t byte_size_ = 0;
uint8_t* data_ptr_ = nullptr;
ANeuralNetworksMemory* nn_memory_handle_ = nullptr;
#ifndef __ANDROID__
std::string shm_region_name;

Choose a reason for hiding this comment

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

hmm, ClangTidy is complaining about the class field variable name, which blocks auto-merger.

Could you change it to "shm_region_name_" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I renamed the variable.

@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label May 14, 2021
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels May 18, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label May 18, 2021
@copybara-service copybara-service bot merged commit 2eb5ed7 into tensorflow:master May 20, 2021
PR Queue automation moved this from Approved by Reviewer to Merged May 20, 2021
@robert-kalmar robert-kalmar deleted the shmem-unlink-for-non-adroid branch May 21, 2021 09:04
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 ready to pull PR ready for merge process size:S CL Change Size: Small TFLiteNNAPIDelegate For issues related to TFLite NNAPI Delegate
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

5 participants