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

fixed wrong runtime shape inference for BatchNorm1dToQuantScaleBias #465

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

green-cabbage
Copy link

Fixed issue where the output shape of class BatchNorm1dToQuantScaleBias was giving an unexpected shape of [1, input_dim, batch_dim, input_dim] instead of [batch_dim, input_dim].

The issue came from the fact that the class ultimately had a default value of runtime_shape = (1, -1, 1, 1) when it should be runtime_shape = (1, -1) .

We had runtime_shape = (1, -1, 1, 1) because class BatchNorm1dToQuantScaleBias wasn't properly passing down the runtime_shape parameter to class ScaleBias . That issue has been also fixed.

Original issue from #450

Copy link
Collaborator

@Giuseppe5 Giuseppe5 left a comment

Choose a reason for hiding this comment

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

Hi,
Thanks for following up on your issue and opening this PR.
We are in the process of better defining how to contribute to Brevitas, and recently we added some guidelines regarding how to add new tests.

Would you be able to add some tests regarding this PR?
For example, checking the output shapes for different types of input (either 2D or 3D).

Let me know if there is something not clear.

Giuseppe

@@ -97,7 +97,7 @@ def __init__(
super(BatchNorm1dToQuantScaleBias, self).__init__(
num_features,
bias=True,
runtime_shape=(1, -1, 1),
runtime_shape=(1, -1),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this has to stay as it was before, i.e. (1, -1, 1).
The reason is that BatchNorm1d is supposed to handle both 2D and 3D inputs. In case you need specifically to use a 2D input, you could always specify the runtime shape when instantiating the class.

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing. I haven't really made any serious test cases before, so this will take some time (since I would have to read all the prerequisites), but I could definitely make some drafts.

Copy link
Author

Choose a reason for hiding this comment

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

I have also made the changes that you requested in my dev branch, but how do I update the pull request? Do I start another pull request? Thank you

Copy link
Collaborator

Choose a reason for hiding this comment

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

Every change, including commits, that you do in your dev branch will be automatically added to this PR, so when you have the tests, just add them to the same dev branch

…m (1,-1) to (1, -1, 1), as requested by the maintainer of brevitas branch
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