Refactor OpenVINO backend: move and clean up parameter handling#240
Open
zhaixuejun1993 wants to merge 7 commits into
Open
Refactor OpenVINO backend: move and clean up parameter handling#240zhaixuejun1993 wants to merge 7 commits into
zhaixuejun1993 wants to merge 7 commits into
Conversation
… argsort_descend() sorted_descend() is_permuted() permute()
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.
This pull request refactors and extends the OpenVINO decoder integration in
ggml-decoder.cppand its header to improve maintainability, flexibility, and support for dynamic dimension inference. The main changes include introducing new utility methods for tensor shape/stride/type queries, significantly refactoring dynamic dimension inference to use a centralized mapping, and simplifying model input handling.API Extensions and Refactoring:
Added new virtual methods to
GgmlOvDecoderfor querying input/output tensor shapes, strides, type sizes, block sizes, and dynamic dimension information, making the decoder interface more expressive and modular. (ggml-decoder.cpp,ggml-decoder.h) [1] [2] [3] [4]Refactored the handling of model inputs and extra inputs to use a simplified and more flexible structure, reducing code duplication and improving clarity. (
ggml-decoder.cpp) [1] [2] [3]Dynamic Dimension Inference Improvements:
compute_node_dynamic_dimslogic to use a centralizeddynamic_dim_infer_map(from the newopenvino/op_table.h), replacing the large switch statement with a more maintainable and extensible approach. This makes it easier to add or modify dynamic dimension inference rules for new ops. (ggml-decoder.cpp) [1] [2] [3] [4]Cleanup and Dependency Management:
openvino/op_table.hdependency, ensuring only necessary headers are included. (ggml-decoder.cpp) [1] [2]These changes collectively improve the decoder’s extensibility and maintainability, especially for handling dynamic shapes and new operations.This pull request refactors how model inputs and extra inputs are handled in the GGML-to-OpenVINO translation layer, improving type safety and code clarity. Instead of storing model inputs and extra inputs as generic OpenVINO nodes, the code now uses explicit structures (
ModelInputInfoandModelExtraInputInfo) to describe their properties. This change also centralizes the logic for creating OpenVINO parameters and constants, and updates related interfaces and usages throughout the codebase. Additionally, the codebase is cleaned up with improved documentation and removal of unused utilities.Key changes:
Refactoring of Model Input Handling:
Replaces storage of model inputs and extra inputs from
std::shared_ptr<ov::Node>to new structuresModelInputInfoandModelExtraInputInfo, providing explicit type and shape information. (ggml-decoder.h,openvino/decoder.h,ggml-decoder.cpp, [1] [2] [3] [4] [5] [6] [7]Updates the
get_model_inputs()andget_model_extra_inputs()interfaces to return the new info structures, and removes the now-unnecessaryget_model_extra_input_values()method. (ggml-decoder.h,openvino/decoder.h, [1] [2]Centralized Parameter and Constant Creation:
create_parameterandcreate_extra_inputto consistently create OpenVINO parameter and constant nodes from the new info structures. Updates the translation session to use these helpers when constructing the OpenVINO model. (openvino/translate_session.cpp, [1] [2]API and Utility Improvements:
get_ov_input_tensorto use the newModelExtraInputInfostructure for constructing input tensors. (utils.cpp, ggml/src/ggml-openvino/utils.cppL840-R843)openvino/translate_session.h,openvino/utils.h, [1] [2] [3]Cleanup and Removal of Unused Code:
getCurrentTime,non_cont_dim, and various template utilities fromutils.cppandutils.h. (utils.cpp,utils.h, [1] [2]Minor Fixes:
mulmat.cppto use the correct input processing function. (mulmat.cpp, ggml/src/ggml-openvino/openvino/op/mulmat.cppL36-R37)ggml-decoder.cpp, ggml/src/ggml-openvino/ggml-decoder.cppL28)## OverviewAdditional information
Requirements