-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Equal() to indicate that offset1 equals first offset #189
Conversation
Codecov Report
@@ Coverage Diff @@
## master JuliaArrays/ArrayInterface.jl#189 +/- ##
==========================================
+ Coverage 83.91% 83.98% +0.06%
==========================================
Files 11 11
Lines 1610 1617 +7
==========================================
+ Hits 1351 1358 +7
Misses 259 259
Continue to review full report at Codecov.
|
Would it make sense to have |
I'd prefer not to have I'm transitioning EDIT: |
Isn't this done with If
I've been hacking on a set of |
Sorry if my comment seems off topic. It seems to me that this PR is improving upon a redundancy (or ambiguity) of |
Ha, forgot I was already special casing it. For me, it is easier not to make those changes. LV tries to zero the offsets, meaning incrementing the pointers, anyway, so w/ respect to LV, both versions should compile to the same code anway.
IMO, Under the perspective that the base pointer of a |
If these arrays are all strided, I'd rather have a single representation capable of describing any of them. |
I am happy with the current semantics, I just wanted to elliminate redundant data storage. That's also one of the motivations of the |
Neither For example, something we currently test with julia> A = zeros(3, 4, 5);
julia> A[:] = 1:60;
julia> Ap = @view(PermutedDimsArray(A,(3,1,2))[:,1:2,1])';
julia> ap_index = ArrayInterface.StrideIndex(Ap);
julia> ap_index[2,2] == 14 == Ap[2, 2]
true
julia> Ap[14]
ERROR: BoundsError: [...]
julia> parent(Ap)[14]
ERROR: BoundsError: [...] We already automatically combine the strides all the way to the most deeply nested parent, but we don't have the proper semantics here to access that buffer properly (which is why it's not part of the indexing pipeline yet).
I'm completely fine with that perspective, but it I'm not sure when we'd ever need a unique value for the
It's been a while, but in an old PR we discussed how we needed to be able to account for non-strided indexing too. We don't need to solve every corner case, but we should probably provide standard I should probably just do a small PR that provides the few
If there's a situation where we really need a unique |
Should've said julia> using ArrayInterface
julia> A = zeros(3, 4, 5);
julia> A[:] = 1:60;
julia> Ap = @view(PermutedDimsArray(A,(3,1,2))[:,1:2,1])';
julia> ap_index = ArrayInterface.StrideIndex(Ap);
julia> ap_index[2,2] == 14 == Ap[2, 2]
true
julia> unsafe_load(pointer(Ap), ap_index[2,2])
14.0 Which is close to the behavior I actually care about. "close", because of course I'm using
Mostly, it makes this easier to work with: julia> using OffsetArrays
julia> A = OffsetArray(rand(3,4), 4, 4)
3×4 OffsetArray(::Matrix{Float64}, 5:7, 5:8) with eltype Float64 with indices 5:7×5:8:
0.695104 0.0620855 0.374289 0.971638
0.889623 0.765056 0.812169 0.820055
0.693763 0.876049 0.084865 0.819834
julia> Base.axes1(A)
OffsetArrays.IdOffsetRange(values=5:7, indices=5:7)
julia> ArrayInterface.offset1(A)
static(1)
julia> ArrayInterface.offsets(A)
(5, 5) Currently, the code for index canonicalization is quite awkward, because
I'm fine with either option. |
I think using Maybe |
Looking over all of this I think it's clear I caused several issues with how I implemented It would be nice to have |
I'm closing this PR in favor of #190 |
Save a value if we cross a function boundary with
OffsetVector
s.