关于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
2条答案
按热度按时间irlmq6kh1#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~
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 API,FAQ,Github Issue and AI community to get the answer.Have a nice day!
x7yiwoj42#
Temp comments
convert_bf16_to_fp32(a.cast(X, "bfloat16"))
str::cout<<a<<std::endl;
string()