Skip to content

Can't call tensor.data_ptr() with torch_directml on DML device #425

@SmartWashingMachine

Description

@SmartWashingMachine

When a tensor is moved / initially placed in the DML device it seems the data pointer can't be read. Instead it throws the error:
RuntimeError: Cannot access data pointer of Tensor that doesn't have storage

Is there a way around this? I'm hoping to use the data pointer to pre-allocate inputs and outputs and use ONNX Runtime's IO Binding API with DirectML.

Basic code snippet to reproduce:

import torch
import torch_directml
dml = torch_directml.device(0)

x = torch.tensor([1, 2]).to(dml)
print(x.data_ptr())

Metadata

Metadata

Assignees

No one assigned

    Labels

    pytorch-directmlIssues in PyTorch when using its DirectML backend

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions