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

[Model] Fix cached buffer allocation and fix dynamic shape in Phi3v #3082

Merged
merged 2 commits into from
Jan 5, 2025

Conversation

mengshyu
Copy link
Contributor

@mengshyu mengshyu commented Jan 3, 2025

This PR fixes the cached buffer allocation for larger new images and supports dynamic shapes in the vision encoder.

This PR fixes the cached buffer allocation for larger new images
and supports dynamic shapes in the vision encoder.
@mengshyu
Copy link
Contributor Author

mengshyu commented Jan 3, 2025

Hi @MasterJH5574 , could you take a look, thanks.

Copy link
Member

@MasterJH5574 MasterJH5574 left a 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.

Comment on lines 23 to 43
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);
Copy link
Member

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);

@MasterJH5574 MasterJH5574 merged commit 6059763 into mlc-ai:main Jan 5, 2025
2 checks passed
@mengshyu mengshyu deleted the 1230-phi3v branch January 5, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants