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

[Filter/TFLite] Fix delegates deleter usage @open sesame 12/17 16:37 #3617

Merged

Conversation

jvuillaumier
Copy link

Hello,
This change is a proposal to fix a crash visible on TFLite filter using external delegate - same issue is also present for other delegates except NNAPI that uses appropriate unique_ptr declaration.
XNNPACK, NNAPI and external delegate deletion has been verified. Could not verify GPU delegate as it is not available on my setup.
Thank you

On pipeline stop, crash in TFLite filter may be seen with some
delegates with log signature:

Setting pipeline to NULL ...
free(): invalid pointer

Pipeline termination procedure is then aborted.

TFlite delegates shall be released by specific deleter, provided
by their respective interface.
TFLite filter implementation manages delegates instance with
smart pointers for automatic disposal when interpreter goes out of
of scope.

Care should be taken to bind relevant delegate deleter to the
smart pointer, otherwise trivial deleter is used for the managed
pointer which may crash.

Signed-off-by: Julien Vuillaumier julien.vuillaumier@nxp.com


Self evaluation:

  1. Build test: [ ]Passed [ ]Failed [*]Skipped
  2. Run test: [*]Passed [ ]Failed []Skipped

SSAT test suite passed.

@taos-ci
Copy link
Collaborator

taos-ci commented Dec 16, 2021

📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #3617. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://nnstreamer.mooo.com/.

Copy link
Member

@anyj0527 anyj0527 left a comment

Choose a reason for hiding this comment

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

Great thanks! I tested the supported delegates including GPU delegate on Android device.
LGTM ✔

@@ -197,10 +197,16 @@ class TFLiteInterpreter
/** @brief cache input and output tensor ptr before invoke */
int cacheInOutTensorPtr ();

/** @brief set delegate for the tflite interpreter */
void setDelegate (TfLiteDelegate *delegate)
/** @brief get delegate for the tflite interpreter */
Copy link
Member

Choose a reason for hiding this comment

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

May be a minor typo here.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the comment - typo fixed in updated patchset

@anyj0527 anyj0527 changed the title [Filter/TFLite] Fix delegates deleter usage [Filter/TFLite] Fix delegates deleter usage @open sesame 12/17 16:37 Dec 17, 2021
Copy link
Collaborator

@taos-ci taos-ci left a comment

Choose a reason for hiding this comment

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

@jvuillaumier, 💯 All CI checkers are successfully verified. Thanks.

On pipeline stop, crash in TFLite filter may be seen with some
delegates with log signature:

Setting pipeline to NULL ...
free(): invalid pointer

Pipeline termination procedure is then aborted.

TFlite delegates shall be released by specific deleter, provided
by their respective interface.
TFLite filter implementation manages delegates instance with
smart pointers for automatic disposal when interpreter goes out of
of scope.

Care should be taken to bind relevant delegate deleter to the
smart pointer, otherwise trivial deleter is used for the managed
pointer which may crash.

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
@jvuillaumier jvuillaumier force-pushed the tflite-delegate-delete-correction branch from 4787226 to 308da67 Compare December 17, 2021 08:42
Copy link
Collaborator

@taos-ci taos-ci left a comment

Choose a reason for hiding this comment

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

@jvuillaumier, 💯 All CI checkers are successfully verified. Thanks.

Copy link
Member

@myungjoo myungjoo left a comment

Choose a reason for hiding this comment

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

LGTM

@jaeyun-jung jaeyun-jung merged commit 8155d79 into nnstreamer:main Dec 21, 2021
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.

None yet

5 participants