KomputeProject / kompute

General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
http://kompute.cc/
Apache License 2.0
1.97k stars 151 forks source link

Expose CopyRegions for tensor copy operations #329

Open Crydsch opened 1 year ago

Crydsch commented 1 year ago

Hey, in my current project I have the need to only copy parts of a tensor to/from the device. I also found your Issue #24 regarding this.

So I had a go at it!

I extended the kp::OpTensorSyncDevice by a vector of copyRegions and added function overloads all the way up to Sequence.eval(). I made sure that the overload only add functionality and still copy the entire tensor per default. Additionally there is now a Test, showcasing the approach. All very experimental at this stage..

Open questions are:

I'd like to know what you think of this approach. If you are interested I can work on this an turn it into a PR.

Crydsch commented 1 year ago

Hey, i had some time and took another look into this. I initially thought i had to add a special template function to pass the regions, but since noticed that this is not really necessary (although much nicer).

But in principle the functionality could be added as a new operation class. This could be done entirely in user code just by deriving from OpBase.

The only necessary change to enable this is to expose the copy region in the tensor class. So changed my approach for this PR and added the required function overloads.

I'll push another PR then with the new operations. PS: To see if the CI runs successfully with this change I enabled the TestOpTensorSync, not sure why it was disabled. If you want to keep it disabled, I'll remove the commit again.