mindspore.Tensor.bfloat16

View Source On Gitee
Tensor.bfloat16()[source]

Converts input tensor dtype to bfloat16.

Returns

Tensor, converted to the bfloat16 dtype.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor
>>> input_x = Tensor(np.ones([2,2]), mindspore.int32)
>>> output = input_x.bfloat16()
>>> print(output.dtype)
BFloat16