fix recurrent_grad tmp variable@GRAD don't exsit in VariableScope #37061
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
Others
Describe
Fix recurrent_grad tmp variable@GRAD don't exsit in VariableScope
背景
在seq2seq模型上开启新执行器的时候,发现RNN的一个OP报了错误:一个临时变量不存在VariableScope中。最后定位到了recurrent_grad op出现了问题。recurrent_grad这个Op实现的时候支持输入的临时变量GRAD不存在scope中。如果不存在,那么就会进行特殊处理。但是新执行器在执行前进行变量check,同时进行id映射。就导致了Op里面的特殊判断没有作用。
修改方式,在新执行器的 build_variable_map 中进行了一个特判,如果是 enforce_exist,才是检测不存在直接报错。如果enforce_exist=False,那么不存在的话直接跳过这个变量。