Remove extra checks from loop#9288
Conversation
Changes improve time complexity.
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
prabhukaliamoorthi
left a comment
There was a problem hiding this comment.
Thanks for the change.
This loop is not critical to performance so I won't duplicate the loop to reduce comparisons.
|
@prabhukaliamoorthi I'm glad that you saw duplication of codebase. This was a trump sorry 😄 . Any way there is a general solution to move common parts to new function. Should I do it? I'm asking cause not clear how you calculate performance and what is critical? I calculate performance by by time complexity. |
|
In general the loop you are optimizing is executed once for each token in the text. That particular code takes 1 - 2% of the overall inference time when profiled on an Android device. So optimizing it would not make a noticeable difference to the inference time. In such situation I prefer readability over performance. |
|
Should I move code duplication to a function? You might want suggest a name to improve readability. I'm Vladimir Spirin. I as a part of open-source community want to be reviewed by other developers. Current code base have to be improved. Our code base mentioned at public news and I we should keep good code quality. |
|
Sorry for the delayed reply. I need to move couple of internal changes to the github repo. So I am delaying this cl. One other thing is all the tests should pass. |
Description
Loop with 2 conditions inside replaced with 3 loops without such conditions inside.
Type of change
Changes improve time complexity.
Note: Please delete options that are not relevant.
Tests
Is any performance tests required?
Test Configuration:
Checklist