Skip to content

Conversation

@xuxinyi389
Copy link
Contributor

@xuxinyi389 xuxinyi389 commented May 21, 2024

PR Category

Others

PR Types

Bug fixes

Description

card-73263

修复paddle.median新开发“min”模式中的cast error。
example:

import paddle
input = paddle.to_tensor(data=[1, 4, 6])
result = paddle.median(mode='min', x=input, axis=0)

报错:TypeError: (InvalidType) Type promotion only support calculations between floating-point numbers and between complex and real numbers. But got different data type x: int64, y: float32.(at/paddle/paddle/phi/common/type_promotion.h:159)

min模式中并未对out_tensor做强制cast,但当输入x的dtype为整形时,在后面对nan的处理逻辑中报错如上。为了保持输入输出dtype的一致性,PR并为将out_tensor强制cast为float。而是根据整形数据不可能含有nan,对其做特殊逻辑判断。

@paddle-bot
Copy link

paddle-bot bot commented May 21, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@zhwesky2010
Copy link
Contributor

zhwesky2010 commented May 22, 2024

注:该问题在 #64444 中由原升级median的同学开展进一步修复

@zhwesky2010 zhwesky2010 changed the title fix cast error of paddle.median [Not Merge] fix cast error of paddle.median May 22, 2024
@xuxinyi389 xuxinyi389 closed this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants