Skip to content

TorchTensor deepcopy raises error when dtype is not float32 #1831

@igamenovoer

Description

@igamenovoer

Initial Checks

  • I have read and followed the docs and still think this is a bug

Description

when calling copy.deepcopy() over TorchTensor, it fails when tensor.dtype != torch.float32.
The problem is that TorchTensor.new_empty() will create a float32 tensor no matter what, regardless of self.dtype
image

Example Code

import torch
from docarray.typing.tensor.torch_tensor import TorchTensor
import copy

x = TorchTensor(torch.randn(2,3))
y = copy.deepcopy(x)    # this works

xx = TorchTensor(torch.randint(0,100,(2,3)))
yy = copy.deepcopy(xx)  # RuntimeError: Expected a Storage of type float or an UntypedStorage, but got type Long for argument 1 'storage'

Python, DocArray & OS Version

0.39.1

Affected Components

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy