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

Use new API calls for OpenVino #1084

Merged
merged 5 commits into from
Jun 30, 2024
Merged

Conversation

tuxbotix
Copy link
Contributor

Why? What?

Use the changed API for creating a tensor. How-To taken from their commit: intel/openvino-rs@b6eacef

Fixes #1083

ToDo / Known Issues

Ideas for Next Iterations (Not This PR)

  • Add a 'smoke test' for the Object Detector to catch OpenVino setup, etc issues (Hopefully, the CI will also catch these?)

How to Test

./pepsi run should build for webots and launch properly.

@oleflb
Copy link
Contributor

oleflb commented Jun 29, 2024

unfortunately this requires cloning..., opened some issues over at openvino

@tuxbotix
Copy link
Contributor Author

tuxbotix commented Jun 29, 2024

I think the reason to yank is the 0.7.1, 0.7.0 releases have memory leaks and segfaults (caused by this and some other cases). Most of the 0.7.2 release is on fixing memory leaks and other memory issues -> https://github.com/intel/openvino-rs/releases/tag/v0.7.2 . While I'm not a fan of yanking a release, I can't blame them for doing this as the listed problems are quite serious.

The cost of copying is also discussed in the change of API (second link in my issue). IMHO a slightly less performant (copy is with memcpy, and aligned memory) library is better than a library that might segfault. Based on their discussions, they'll push a fix at a later time, but we don't know when will that happen.

Additionally, we can change the cycler's architecture to keep the tensor as part of the state and load the input image directly into it instead of the scratchpad.

@oleflb
Copy link
Contributor

oleflb commented Jun 29, 2024

No, not possible since the Tensor does not impl Send :(

@oleflb oleflb self-assigned this Jun 29, 2024
@tuxbotix
Copy link
Contributor Author

Ouch! 😬 That's bad 😞.
I'll try to setup a benchmark today if I can to see the impact of the copy and some alternative we could try.

Based on the notes by the authors, they would need to touch a lot of code to get the lifetime information right to create a tensor from a pointer and ensure safety.

@oleflb
Copy link
Contributor

oleflb commented Jun 29, 2024

For now we can just remove the scratchpad and create the Tensor in the cycle function. you can use get_data_mut to create a mutable f32 slice that you can pass to the load_into_scratchpad function.

@tuxbotix tuxbotix force-pushed the fix_openvino_broken_api branch from 375aec3 to 5ce3554 Compare June 29, 2024 21:07
@oleflb
Copy link
Contributor

oleflb commented Jun 29, 2024

Yes, feel free to remove the trait. I'd say we merge this state with the allocation.

Copy link
Contributor

@oleflb oleflb left a comment

Choose a reason for hiding this comment

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

thank you for fixing :)

@tuxbotix tuxbotix added this pull request to the merge queue Jun 30, 2024
@tuxbotix
Copy link
Contributor Author

And thank you for integrating all of this and catching the things I missed!!

Merged via the queue into HULKs:main with commit a4f9895 Jun 30, 2024
25 checks passed
@tuxbotix tuxbotix deleted the fix_openvino_broken_api branch June 30, 2024 15:00
oleflb pushed a commit to oleflb/hulk that referenced this pull request Jul 15, 2024
* Use new API calls

* Fix some mistakes

* Remove scratchpad state, directly fill the tensor instead (for now)

* Remove manually specifying generics

* Remove AsBytes trait
oleflb pushed a commit that referenced this pull request Sep 30, 2024
* Use new API calls

* Fix some mistakes

* Remove scratchpad state, directly fill the tensor instead (for now)

* Remove manually specifying generics

* Remove AsBytes trait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

openvino-rs 0.7.1 is yanked, new version has breaking changes
2 participants