Skip to content

Tensor.Load when tensor is on CUDA fails #1174

@shaltielshmid

Description

@shaltielshmid

When trying to load the contents of a Tensor from a stream, if the tensor isn't located on the CPU then the loading will fail. The reason seems to be located here, since the .to() method returns a new tensor when the tensor is copied to a new device.

Sample code:

var tensor1 = torch.rand(10, device: torch.CUDA);

// Save to memory stream
using var ms = new MemoryStream();
tensor1.Save(new BinaryWriter(ms, Encoding.UTF8, true));

ms.Position = 0;
tensor1.Load(new BinaryReader(ms));

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