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

Fix GlobalPooling1D Layers #399

Merged
merged 6 commits into from
Oct 7, 2021
Merged

Fix GlobalPooling1D Layers #399

merged 6 commits into from
Oct 7, 2021

Conversation

jmduarte
Copy link
Member

@jmduarte jmduarte commented Sep 21, 2021

Address #398

Test script (to be turned into a real test): https://gist.github.com/jmduarte/99aee1eee92524ad3b1dbf5c5a863296

Changes to do:

  • Fix parsing of configuration for GlobalPooling1D layers
  • Add global_pooling1d_cl io_stream HLS implementation
  • Add global_pooling1d_cl io_parallel HLS implementation
  • Add testing module

@jmitrevs

@jmitrevs
Copy link
Contributor

jmitrevs commented Oct 3, 2021

One issue discovered while creating the tests is that io_stream GlobalAveragePooling has a tendency to overflow when doing the sum. Unlike the io_parallel implementation, it does not use a wider accumulator size. I am trying to see what is the best way to fix this.

@jmitrevs
Copy link
Contributor

jmitrevs commented Oct 3, 2021

I added a test (and also an include of nnet_dense.h in nn_conv_stream.h). For the average overflow issue, one can manually increase the bit width of the layer (as done in test_globalpooling1d.py). I am not sure if it is better to automatically choose a wider width, but #327 made me wonder if it was best to leave it for the user. Let me know what you think we should do.

@jmduarte jmduarte requested a review from thesps October 5, 2021 04:44
@jmduarte
Copy link
Member Author

jmduarte commented Oct 5, 2021

@thesps if you could review this, that'd be great. I think it's ready, except for perhaps creating an optimizer that would set accum_t for io_stream (mimicking the way it's currently handed in the HLS for io_parallel):

ap_fixed<W + ceillog2(N), I + ceillog2(N)> tmp = 0;

Copy link
Contributor

@thesps thesps left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me now! On the point about setting the accumulator type - the automated setting of the accumulator type would be a good follow up, but I think what we have here is already good enough to merge since the type can be configured properly in any case.

I just changed the directory name that the test writes to from hls4ml_... to hls4mlprj... like the other tests. It's partly convention, but also writing rm -r hls4ml* to clean up after running locally makes me nervous 😅

@thesps thesps merged commit e804cfc into master Oct 7, 2021
thesps added a commit that referenced this pull request Oct 7, 2021
* add global_pooling1d_cl

* io_parallel global_pooling1d_cl

* add globalpooling1d testing; add missing include in nnet_conv_stream.h

* update test

* Update test_globalpooling1d.py

* Change project directory name

Co-authored-by: Jovan Mitrevski <[email protected]>
Co-authored-by: Sioni Summers <[email protected]>
@thesps thesps mentioned this pull request Oct 7, 2021
@jmduarte jmduarte deleted the global_pooling1d_fix branch November 2, 2022 02:33
calad0i pushed a commit to calad0i/hls4ml that referenced this pull request Jul 1, 2023
* add global_pooling1d_cl

* io_parallel global_pooling1d_cl

* add globalpooling1d testing; add missing include in nnet_conv_stream.h

* update test

* Update test_globalpooling1d.py

* Change project directory name

Co-authored-by: Jovan Mitrevski <[email protected]>
Co-authored-by: Sioni Summers <[email protected]>
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