As I've seen there is a numpy extension for bfloat16 in tensorflow:
This extension can be enabled by calling RegisterNumpyBfloat16
. Or at least it should. I've installed tensorflow 2.4.1 and tried to enable the extension, but I just get this error:
> tf.RegisterNumpyBfloat16()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-4f89beb80796> in <module>
----> 1 tf.RegisterNumpyBfloat16()
AttributeError: module 'tensorflow' has no attribute 'RegisterNumpyBfloat16'
Does anyone see what I do wrong? Or how can this numpy-extension be enabled?
Thank you very much
Try this:
from tensorflow.python import _pywrap_bfloat16
bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()
print(bfloat16)
# <class 'bfloat16'>
print(bfloat16(1.0))
# bfloat16(1)