Skip last 1by1 layer and residual connection#25
Open
fps wants to merge 1 commit intomikeoliphant:mainfrom
Open
Skip last 1by1 layer and residual connection#25fps wants to merge 1 commit intomikeoliphant:mainfrom
fps wants to merge 1 commit intomikeoliphant:mainfrom
Conversation
Owner
|
Yeah, the outputs from the last layer aren't used. Not a big performance impact, but every bit helps. I'm inclined to try to do this with a template parameter (although it is unlikely to make much performance impact). Should be able to get rid of the "arrayOutputs" matrix as well, since it is just there to catch the unused output from the last layer. |
Author
|
Here's another small optimization opportunity: NeuralAudio/NeuralAudio/WaveNet.h Line 399 in 51ba25a headArray to zero. The first WaveNetLayerT could instead use = instead of +=. This would save the zeroing. Again this could be done with a template parameter and an if constexpr(first). I have done so in my implementation:
https://github.com/fps/anna/blob/cdef14fe0b9e3bf96aef1b0b492e771071710348/include/anna/nam.hpp#L68 I'm still not beating yours though. Probably because of my (more costly) buffer handling ;) |
Owner
|
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This saves between 0.5 and 1% of cpu (relative to without this change). In my own implementation I have it as a template parameter [1][2]. But I wasn't sure how to add it to yours. I guess the 20 comparisons (one for each layer) might pale in comparison to the matrix multiplication and addition that is saved. But possibly making it a template parameter might save another small fraction of a percent :)
[1] https://github.com/fps/anna/blob/master/examples/nam_wavenet.cpp
[2] https://github.com/fps/anna/blob/master/include/anna/nam.hpp