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

Remove height and width from default shapes pre-configuration #1104

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

mvafin
Copy link
Contributor

@mvafin mvafin commented Jan 8, 2025

What does this PR do?

Fixes #1070 as it was merged with changes that will not work because height and width are pre-configured. After this change dummy input generators will use height and width from defaults of __init__.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment on lines 665 to 672
input_shapes = {}
for input_name in DEFAULT_DUMMY_SHAPES.keys():
if input_name in ["height", "width"]:
# use H and W from generator defaults
continue
input_shapes[input_name] = (
kwargs_shapes[input_name] if input_name in kwargs_shapes else DEFAULT_DUMMY_SHAPES[input_name]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this entire part is unnecessary and could/should be removed, as we already have the default shapes in each input generator signature. This part enforces the values in DEFAULT_DUMMY_SHAPES on all model inputs generators, restricting model-specific export optimizations (like reducing input dimensions for a dynamic axis to lower export memory requirements). It also populates input shapes with irrelevant shapes.
@echarlaix wdyt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I feel that it may be dangerous to remove it now as it was there for a long time and some models may rely on it. As for height and weight the impact is much less, because not many models receive image in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will merge for now and follow up with a PR investigating the possibility of its removal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mvafin

@IlyasMoutawwakil IlyasMoutawwakil merged commit 190ae87 into huggingface:main Jan 9, 2025
22 checks passed
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.

3 participants