Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Check the contiguous of DLTensor when wrapping it to Array#30

Open
songjhaha wants to merge 2 commits intop-zubieta:mainfrom
songjhaha:songjhaha/check-contiguous
Open

Check the contiguous of DLTensor when wrapping it to Array#30
songjhaha wants to merge 2 commits intop-zubieta:mainfrom
songjhaha:songjhaha/check-contiguous

Conversation

@songjhaha
Copy link

As described in #29

An array is not col_major doesn't means it's row_major, it could be non-contiguous, so throw an error here if the contiguous check didn't pass. (maybe we could copy the data with the information of strides, and wrap a new Array, but not a efficient way)

@p-zubieta
Copy link
Owner

Sorry for the delay here. I'm a bit hesitant about to handle this, I would ideally want to return views with something like wrap(View, x, to_dlpack) and error with the default wrap method (the last past being what you are introducing here).

@songjhaha
Copy link
Author

@pabloferz, thanks for the discussion, I'm considering some similar question these days.

But I think wrapping a subarray could be a bit difficult here if we only have the information from the dltensor. Because we need to firstly wrap the parent array of the subarray, then compute the indices which could return the correct subarray.

Also, in some cases this problem could be complex. For example, dltensor is some transposed ndarray, like transposing a 3D tensor with permutation (2, 1, 3). I'm not sure subarray could handle this situation.😔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments