Skip to content

torch-directml: tensor from meta device. #477

@lshqqytiger

Description

@lshqqytiger

PyTorch does not allow to copy data from meta device.
image
But DirectML device allows it.

Python 3.10.11 | packaged by Anaconda, Inc. | (main, Apr 20 2023, 18:56:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch, torch_directml
>>> device = torch_directml.device()
>>> ten = torch.randn(4, dtype=torch.float32)
>>> ten
tensor([ 0.9687,  0.3756,  2.0894, -0.4535])
>>> ten.to("meta")
tensor(..., device='meta', size=(4,))
>>> ten.to("meta").to("cpu")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: Cannot copy out of meta tensor; no data!
>>> ten.to("meta").to(device)
tensor([0., 0., 0., 0.], device='privateuseone:0') # <-- this behavior does not make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pytorch-directmlIssues in PyTorch when using its DirectML backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions