Paddle 【paddle.cast】转换为 unit16 时的bug

7nbnzgx9  于 2021-11-30  发布在  Java
关注(0)|答案(2)|浏览(585)

关于bfloat16的转换问题,cast后的输出应该是1,但是这里的输出是16256;
环境 paddle 2.1.0,Mac

竞品都是1:
tf: 2.5.0 Tesla T4

pytorch: 1.8.1 Tesla T4

============== 问题排查 ==============
BF16问题。见 python/paddle/fluid/framework.py 中 convert_np_dtype_to_dtype,由于numpy不支持bfloat16,代码中将np.uint16转为paddle.bfloat16

============== 解决方案 ===============

建议:可以参考tensorflow,add bfloat16 as numpy extensions, refer to:

tf bfloat16 numpy extension way: https://stackoverflow.com/questions/66354058/tensorflow-register-numpy-bfloat16-extension

tf bfloat16 numpy extension commit: tensorflow/tensorflow@24ffe9f

irlmq6kh

irlmq6kh1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

x7yiwoj4

x7yiwoj42#

Temp comments

convert_bf16_to_fp32(a.cast(X, "bfloat16"))

str::cout<<a<<std::endl;

string()

相关问题