modify to complex template types in reduce_sum OP #33164
Merged
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
Others
PR changes
OPs
Describe
本PR将reduce_sum Op 的复数类型从complex64/128 替换为 complex<float/double> 模板类型。
由于模板类型中 从complex 转换为 实数类型 是explicit的,且原 IdentityFunctor 中不会改变数据类型,因此在编译过程中会遇到
paddle::platform::complex<float> to float,paddle::platform::complex<float> to int64等类似的类型转换失败的报错内容。(注: 由于原来的complex64 和complex128 类型 可以隐式地转为实数类型,因此即使 IdentityFunctor 中不会修改数据类型,编译仍可通过,但这种隐式转换会在不注意的时候导致虚部数据丢失)
报错的地方如下
为了解决这个问题,本PR需要在IdentityFunctor中显示地指定数据类型转换, 主要修改了如下2个地方。
修改前:
修改后:
修改前:
修改后: