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

NDIndex - Optionally static CartesianIndex #140

Merged
merged 12 commits into from
Apr 7, 2021
Merged

NDIndex - Optionally static CartesianIndex #140

merged 12 commits into from
Apr 7, 2021

Conversation

Tokazama
Copy link
Member

@Tokazama Tokazama commented Apr 6, 2021

While working on more indexing stuff I needed the ability to propagate static info through something like CartesianIndex. I also saw there was a variant of this sort of thing in VectorizationBase.jl, so I think it could be widely beneficial to start getting something standard in place.

Previously conversion from an integer to a cartesian index required a
call to `axes`, but offsets and the array size are acquired from the
array instead. This shouldn't make a difference in most cases, but if an
array type has optimized these methods over creation of an entire axis
it could be quicker.
@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #140 (62d70f2) into master (d65bcc0) will increase coverage by 0.21%.
The diff coverage is 83.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #140      +/-   ##
==========================================
+ Coverage   84.17%   84.38%   +0.21%     
==========================================
  Files          10       11       +1     
  Lines        1460     1531      +71     
==========================================
+ Hits         1229     1292      +63     
- Misses        231      239       +8     
Impacted Files Coverage Δ
src/ArrayInterface.jl 84.82% <ø> (+0.60%) ⬆️
src/indexing.jl 77.82% <81.03%> (-2.60%) ⬇️
src/ndindex.jl 85.36% <85.36%> (ø)
src/stridelayout.jl 88.15% <0.00%> (+0.43%) ⬆️
src/ranges.jl 92.08% <0.00%> (+1.25%) ⬆️
src/size.jl 82.92% <0.00%> (+2.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d65bcc0...62d70f2. Read the comment docs.

Copy link
Collaborator

@chriselrod chriselrod left a comment

Choose a reason for hiding this comment

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

Seems fine, but I realize now that I VectorizationBase/LoopVectorization shouldn't need this anymore.
Once upon a time, ranges all round-tripped through static_first(r):static_last(r), so I needed static CartesianIndex to preserve statically sized CartesianIndices.
Now it uses LoopVectorization.canonicalize_range instead.

@Tokazama
Copy link
Member Author

Tokazama commented Apr 7, 2021

It's not necessarily something we absolutely can't live without, but it also gives you the nice guarantee that you have a bunch of Ints and/or StaticInts.

@Tokazama Tokazama merged commit cd6e5d2 into master Apr 7, 2021
@Tokazama Tokazama deleted the cartesian branch April 11, 2021 00:49
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