Expose CopyRegions for tensor copy operations #329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 copyRegionsand 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:
kp::CopyRegion
which takes offsets and size in number of elements instead of bytes?This would ease usage and fit nicely with kompute's higher level functions.
I suggest just clamping the region to the tensor size in the
kp::OpTensorSyncDevice
constructor.With a warning of course..
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.