feat: add model reshape support to high-level API#182
Merged
rahulchaphalkar merged 2 commits intointel:mainfrom Jan 8, 2026
Merged
feat: add model reshape support to high-level API#182rahulchaphalkar merged 2 commits intointel:mainfrom
rahulchaphalkar merged 2 commits intointel:mainfrom
Conversation
Contributor
|
Thanks for the PR and a review! I will take a look at this soon, took a while to see this as I'm just returning from a year end break. |
rahulchaphalkar
requested changes
Jan 6, 2026
Contributor
rahulchaphalkar
left a comment
There was a problem hiding this comment.
Looks good, a minor change requested and seems good to go after that. Thanks.
Contributor
|
Can you rebase main, I have updated the workflow file to fix the failure, it should pass now. |
Implements five methods in the Model struct to enable model reshaping after loading, which is required for dynamic batching and changing input image resolutions. Changes: - Added Model::reshape, reshape_single_input, reshape_input_by_name, reshape_by_port_indexes, and reshape_by_ports. - Updated PartialShape internals to pub(crate) to allow Model to access the underlying C struct for FFI calls. - Added Node::as_ptr() helper to expose the internal port pointer. - Added a new integration test suite (tests/reshape.rs) using the AlexNet fixture to verify the FFI bridge logic. This bridges the gap between the low-level sys crate and the ergonomic high-level API. Signed-off-by: khengari77 <khengari77@gmail.com>
Signed-off-by: khengari77 <khengari77@gmail.com>
6c79a21 to
4dbd919
Compare
rahulchaphalkar
approved these changes
Jan 8, 2026
Contributor
rahulchaphalkar
left a comment
There was a problem hiding this comment.
Looks good, thanks for the contribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
This PR implements high-level, safe Rust bindings for the OpenVINO model reshape functionality. Currently, the
openvinocrate lacks a way to reshape models after they are loaded, which is a prerequisite for use cases involving dynamic batching or variable image resolutions.This contribution bridges the gap between the low-level
openvino-sysFFI and the ergonomicopenvinocrate by adding five core reshape methods to theModelstruct.Related Issue
Closes #181
Changes
crates/openvino/src/model.rs:reshape: Enables name-to-PartialShapemapping for multi-input models.reshape_single_input: An ergonomic helper for the common single-input model use case.reshape_input_by_name: Targets a specific input port by its name string.reshape_by_port_indexes: Enables index-based reshaping.reshape_by_ports: EnablesNode/Port-based reshaping.crates/openvino/src/partial_shape.rs:c_structtopub(crate). This allows themodelmodule to pass the underlyingov_partial_shape_tto FFI calls while keeping it hidden from the end-user.crates/openvino/src/node.rs:pub(crate) fn as_ptr()helper to expose the internalov_output_const_port_tpointer required forov_model_reshape_by_ports.crates/openvino/tests/reshape.rs:alexnetfixture to verify that all five reshape variants correctly communicate with the OpenVINO C++ runtime and that model state updates correctly (includingis_dynamicchecks).Testing and Compliance
cargo test -p openvino --test reshapecargo fmt --all