-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Model] Fix cached buffer allocation and fix dynamic shape in Phi3v #3082
Conversation
This PR fixes the cached buffer allocation for larger new images and supports dynamic shapes in the vision encoder.
Hi @MasterJH5574 , could you take a look, thanks. |
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.
Overall looks good! Thank you @mengshyu, Just left one minor nit.
cpp/support/vlm_utils.h
Outdated
void CalculateResizeShape(tvm::runtime::NDArray image_data, std::string model_type, | ||
int& target_height, int& target_width); | ||
/*! | ||
* \brief Calculate the padding height and width for an image based on the input data and model | ||
* type. \param image_data The input image data as a TVM NDArray. \param model_type The type of the | ||
* model influencing the padding parameters (e.g., phi3v). \param pad_height Reference to the | ||
* variable where the calculated padding height will be stored. \param pad_width Reference to the | ||
* variable where the calculated padding width will be stored. | ||
*/ | ||
void CalculatePadShape(tvm::runtime::NDArray image_data, std::string model_type, int& pad_height, | ||
int& pad_width); | ||
|
||
/*! | ||
* \brief Calculate the cropping height and width for an image based on the input data and model | ||
* type. \param image_data The input image data as a TVM NDArray. \param model_type The type of the | ||
* model influencing the cropping parameters (e.g., phi3v). \param crop_height Reference to the | ||
* variable where the calculated cropping height will be stored. \param crop_width Reference to the | ||
* variable where the calculated cropping width will be stored. | ||
*/ | ||
void CalculateCropShape(tvm::runtime::NDArray image_data, std::string model_type, int& crop_height, | ||
int& crop_width); |
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.
A minor nit for convention: let's avoid passing mutable reference and instead pass pointers for functions here. For example,
void CalculateCropShape(tvm::runtime::NDArray image_data, std::string model_type, int* crop_height,
int* crop_width);
This PR fixes the cached buffer allocation for larger new images and supports dynamic shapes in the vision encoder.