No way to copy a tensor from gpu to cpu to pre allocated array.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- machine-learning
Research direction
Start by tracing the tensor transfer path used by gpuResult.cpu() and cpuResult.data().ToArray(), then inspect the existing host-copy APIs. Done means a GPU result can be copied into a caller-provided preallocated float array without allocating a new array, with coverage for the supported copy behavior.
Written by the indexing model from the issue text.
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<float>().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?
- Dominant language
- C#
- Stars
- 1.9k
- Forks
- 228
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/TorchSharp
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
dotnet/TorchSharp#1574 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
dotnet/TorchSharp#1567 ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
dotnet/TorchSharp#1557 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dotnet/TorchSharp#1545 · 1 reaction ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
dotnet/TorchSharp#1541 ·
All issues in dotnet/TorchSharp
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·