Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented strides for AbstractArray subtypes #30429

Closed
wants to merge 2 commits into from

Conversation

raghav9-97
Copy link
Contributor

Fixes #29705

@mbauman
Copy link
Member

mbauman commented Dec 18, 2018

Thanks for the contribution! We should probably make the documentation of strides a bit more clear — it doesn't give you the multipliers you need to compute a linear index, but rather it defines how to find a given location in memory as an offset from a base pointer.

This means that, for example strides(view(rand(10), 1:2:10)') should be (1, 2) and not (1,1). It also means that we cannot support strides on Diagonal as its memory layout does not conform to the StridedArray interface.

See https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-strided-arrays-1 for a bit more detail — but probably still not quite enough.

Copy link
Member

@mbauman mbauman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define strides(::AdjOrTrans) in terms of the strides of its parent, and remove the strides definition for Diagonal

@raghav9-97
Copy link
Contributor Author

raghav9-97 commented Dec 18, 2018

@mbauman If i am correctly understanding strides

A = rand(3,5)

strides(A) should generate (1,3) and strides(A') will generate (1,5) or will it generate (3,1) just as similar to PermuteDimsArray(A, (2,1))?

@mbauman
Copy link
Member

mbauman commented Dec 18, 2018

It's even simpler than that — you just want to reverse the strides of the parent. Oh my, now that I write that out, it's sounding very familiar to me…

Yup, shucks. #29135. I have a really bad habit of submitting PRs and then forgetting all about them.

@raghav9-97
Copy link
Contributor Author

raghav9-97 commented Dec 18, 2018

@mbauman Haha!! You've already implemented it way before than me?Should I continue working on this?Also should I split the function for StridedMatrix and StridedVector as you did?

@ViralBShah
Copy link
Member

@mbauman Should we merge your old PR, or should @raghav9-97 prepare this one to be merged?

@raghav9-97 raghav9-97 closed this Jan 7, 2019
@raghav9-97 raghav9-97 deleted the strides branch January 7, 2019 14:41
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.

3 participants