[Python] Converting Pytorch bfloat16 tensors to numpy throws TypeError

Discussão em 'Python' iniciado por Stack, Agosto 21, 2025.

  1. Stack

    Stack Membro Participativo

    When you try to convert a Torch bfloat16 tensor to a numpy array, it throws a TypeError:

    import torch

    x = torch.Tensor([0]).to(torch.bfloat16)
    x.numpy() # TypeError: Got unsupported ScalarType BFloat16

    import numpy as np
    np.array(x) # same error


    Is there a work-around to make this conversion?

    Continue reading...

Compartilhe esta Página