Skip to content

[Tosa] : Use output type for bias for creating tosa.conv #4252

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

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

Conversation

sahas3
Copy link
Member

@sahas3 sahas3 commented Jul 2, 2025

For ConvolutionLayer initialized without bias, a zero tensor for bias is created when converting to tosa.conv2d as the op always expects a bias tensor. This zero tensor was always initialized to be fp32 irrespective of what the input/weights type were. This leads to a validation error since bias type (fp32) didn't match with output of conv (fp16) when the input/weight are of fp16 type.

@sahas3 sahas3 requested a review from sjarus July 2, 2025 16:04
@sahas3
Copy link
Member Author

sahas3 commented Jul 2, 2025

The nightly build failures are unrelated and seems to be failing for all recent CIs. @sjarus, please let me know if there's any concern with merging this change after approval. Thanks!

@sahas3 sahas3 marked this pull request as draft July 3, 2025 12:27
@sahas3
Copy link
Member Author

sahas3 commented Jul 3, 2025

Converting to draft as I found some other failures when trying different integer type inputs, will look into those failures and possible add fixes in this same PR.

Copy link
Collaborator

@sjarus sjarus left a comment

Choose a reason for hiding this comment

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

Nice catch, thanks @sahas3 !

@sahas3 sahas3 changed the title [Tosa] : Use input type for bias for creating tosa.conv [Tosa] : Use output type for bias for creating tosa.conv Jul 8, 2025
@sahas3 sahas3 marked this pull request as ready for review July 8, 2025 18:35
@sahas3 sahas3 requested a review from sjarus July 8, 2025 18:35
@sahas3
Copy link
Member Author

sahas3 commented Jul 8, 2025

Nice catch, thanks @sahas3 !

Thanks @sjarus. However, I had to make some changes on top of what you had already reviewed to handle some edge cases captured in the changes in the basic.mlir file. Sorry for the inconvenience, but please can you take another look when you have a chance? Thanks!

Copy link
Collaborator

@sjarus sjarus left a comment

Choose a reason for hiding this comment

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

This is quite extensive in terms of introducing new capability around quantized type coverage. Thanks so much.

cc: @eric-k256 @justin-ngo-arm

@sahas3
Copy link
Member Author

sahas3 commented Jul 9, 2025

This is quite extensive in terms of introducing new capability around quantized type coverage. Thanks so much.

Thank you, appreciate the kind words.

@sahas3 sahas3 enabled auto-merge (squash) July 9, 2025 17:07
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