Fix Using "isinstance" in Loop, test=develop#28641
Merged
zhhsplendid merged 5 commits intoPaddlePaddle:developfrom Nov 17, 2020
Merged
Fix Using "isinstance" in Loop, test=develop#28641zhhsplendid merged 5 commits intoPaddlePaddle:developfrom
zhhsplendid merged 5 commits intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
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.
PR types
Bug fixes
PR changes
APIs
Describe
Fix a bug that used in PaddleGAN model which used
isinstancein a for loop (the code is located at https://github.com/PaddlePaddle/PaddleGAN/blob/32c59d5539de9182b8307d41ba7aad7de76f1c28/ppgan/models/generators/deoldify.py#L35)The reason of the bug is that the
typeof functionisinstanceis treated as a variable in loop_vars. For example, before this bug fix, if youprint(model.forward.code)for thetest_sequential_layerunittest of this PR, you will get code like below. Note thatAddAttrLayeris a type but here our code treated it as a variable.Solution: I recorded those variables in
isinstanceas types, then removed those type variables in loop_vars. Now the translated code for above example is: