-
Notifications
You must be signed in to change notification settings - Fork 28
Update bindings to v2024.4.0 #144
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
Conversation
This consists of using intel#142: ``` $ cargo xtask update 2024.4.0 $ cargo xtask codegen $ cargo test ``` The follow-on commits resolve the errors introduced by this update.
This change is an effort avoid missing new enum variants if they are added to OpenVINO's C headers. As it stands now, new variants could be missed until runtime, when the enum code can't be parsed and the library panics. Instead, this change generates a Rust `enum` for each C `enum` so that missing variants become a compile time error; if we update the bindings but don't handle these, we see a compile-time error.
The `openvino` crate depended on the previous constants generated by `bindgen`. This change uses the new Rust `enum`s instead, creating `From` and `Into` implementations to go between the Rust and C versions. Why not just pass through the `openvino_sys` enum as-is? The only real issue currently is documentation: the C headers start documentation with `<!` which seems a bit weird. I've also fixed up a few grammar problems in the documentation. But one day we may indeed be able to just reuse these types.
It wasn't clear to me why the function and the struct were kept in different places so I moved them together. I also added a `Version::parts` function.
Any test using `ElementType::U8` will cause problems when run on older versions of the library. This change manually ignores tests that depend on this by detecting the library version. For `Tensor`'s doc test, I chose to use a type not affected by the breaking change to keep things consistent.
See b2bdfb0 for the rationale for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of Nits, and String related feedback.
| let mut parts = version.parts(); | ||
| let year: usize = parts.next().unwrap().parse().unwrap(); | ||
| let minor: usize = parts.next().unwrap().parse().unwrap(); | ||
| year <= 2024 || (year == 2024 && minor < 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abrown Realized this half hour too late - this needs to be year < 2024 ||, was testing new version again and it skipped this test for 2024.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, yeah, that's right. I'll fix it.
@rahulchaphalkar pointed out that the first part of this check should filter out pre-2024 releases; fixes an issue in intel#144.
@rahulchaphalkar pointed out that the first part of this check should filter out pre-2024 releases; fixes an issue in #144.
This uses #142 (not included here) to update the OpenVINO C headers to their latest version and generate Rust bindings for them. While doing this I discovered #143, which results in a breaking change to the bindings; since the
ov_element_type_evariants now have different values, users get wrong byte sizes (and out-of-bounds access to tensor memory viaTensor::get_*) if using these bindings with an implementation of OpenVINO older than 2024.2.0.Along the way, this fixes up how we generate C enums, now as Rust enums in order to see compile-time errors when new variants are introduced. The majority of the changes are due to propagating this change throughout the crates.
Closes #143, closes #20.