Change type restrictions in cuTENSOR operations #2356
Merged
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.
This PR migrates the type restrictions for the cutensor operations from the definitions of
*operation*_execute!
andplan_*operation*
to the constructor of theCuTensorDescriptor
.This implementation makes it such that custom types, which wrap
CuArray
objects can specialize just theCuTensorDescriptor
constructor while still being able to re-use most of the codebase.Some questions/remarks I am still having:
Note that the current implementation changes the
CuTensorDescriptor
function quite drastically, in order to expose the internal constructor. I could think of alternative ways to achieve this goal as well by renaming the inner constructor to_CuTensorDescriptor
, which handles only the finalizer etc.This change allows cuTENSOR to work almost trivially with
StridedCuArray
s as well. I played around with this a bit, and the only issue that shows up by changingDenseCuArray
toStridedCuArray
is that the data alignment can no longer be guaranteed. I have to admit that I do not have enough experience with this myself, but simply changingalignment=sizeof(eltype(A))
seems to work. Does anyone know if there are any issues associated with this approach? Should I be mindful of severe performance pitfalls?I have not added this because of these reasons, but if anyone can reassure me that this is fine, I can open up a different PR for implementing
StridedCuArray
as well.Any suggestions are definitely more than welcome.