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 the bug in expand_v2 op.
Paddle框架在编译期使用-1表示未知维度值,如batch size的值。expand_v2 OP使用-1表示保持相应维度地维度值不变。例如,b = expand(a, shape=[4, -1, 2]), 假设a.shape = [2, 3, 2], 则b.shape = [4, 3, 2]。
当expand的shape参数列表中包含var是,例如,c = expand(a, shape=[temp_var, 3, 2])是,expand在编译期会将expand OP的expand_shape属性var对应的值设置为-1, 上例中expand_shape的属性值为[-1, 3, 2]。那么编译期c.shape = [2, 3, 2]。
当temp_var表示未知维度值时,和期望的结果不符,期望的结果是c.shape = [-1, 3, 2]。
本pr在编译器将temp_var对应的维度值设置为-1,表示编译期未知维度,解决上述问题。