-
Notifications
You must be signed in to change notification settings - Fork 426
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
PyTorch Pool1d + Squeeze bug, with cpp source code insights #1054
Comments
Hi @sei-jgwohlbier, thanks for reporting this and the detailed studies you did. I was able to pinpoint the issue to a problem with the conversion to From what I can tell, this can be fixed by changing this line https://github.com/fastmachinelearning/hls4ml/blob/main/hls4ml/model/optimizer/passes/convert_to_channels_last.py#L97 from The one thing I can't quite understand is why there aren't any problems with the |
Awesome, thanks very much. Indeed my test passes with your fix. Let me know if you need me to test anything. |
@JanFSchulte do you know if anyone else has looked at this? I continue to use your patch in my version. |
Hi! Ah, no, this hasn't been fixed in the main branch yet. I'll get around to making a PR in the next few days. Thanks for reminding me! |
I ended up including the fix in this PR that also deals with fixes to the pytorch parser: #1086 |
Sorry, forgot to close. Thanks! |
Prerequisites
Please make sure to check off these prerequisites before submitting a bug report.
Quick summary
For a simple PyTorch model with a pool1d followed by a squeeze the generated code is incorrect. The correct values are present in the execution, but they are not stored correctly.
Details
Steps to Reproduce
test_pool_squeeze.py
provided below.Expected behavior
Expected passing test.
Actual behavior
The test fails. Details of generated source code behavior is provided below.
Optional
This is the test file
test_pool_squeeze.py
There is a problem with the generated
myproject.cpp
file. I have added some print statements to try to assess what is going on. The print statements are included below.Below is the output of running the compiled
myproject_test.cpp
.Note the WARNING about
layer5_out
containing leftover data. More below.The first line is the input, two channels of length 4 in channels last format.
layer2
is the output of thennet::pooling1d_cl
. I have confirmed the two values shown inlayer2
are the correct averages accounting for channels last. I.e.,Indeed, these are the two values that should appear as "predictions," but the data is not being correctly extracted.
Other notes:
layer5_t
indefines.h
is not correct. Based on the expected output I think it should betypedef nnet::array<ap_fixed<64,24>, 2*1> layer5_t;
, (2*1
not1*1
), but when I make that change the results are not correct. Thelayer5_out
warning does go away in this case.hls4ml
source.The text was updated successfully, but these errors were encountered: