dotnet / dotnet/TorchSharp

No way to copy a tensor from gpu to cpu to pre allocated array.

Open
#1,388 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.9k
Forks
228
PR merge metrics
No merged PRs in 30d

Description

Doesnt appear to be any way to transfer a result tensor in to an existing cpu float array. Below requires new memory allocation.

var cpuResult = gpuResult.cpu();
float[] result = cpuResult.data().ToArray();

If this is part of a loop, this is a lot of wasted memory allocation and time! Below is how libraries normally do things. eg. CUDA.

float[] cpuResult ..... (pre allocated further up)
gpuResult.CopyToHost(cpuResult);

Maybe I missed this CopyTo because its kinda essential for any gpu type library (?!)

Is this project maintained?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.