-
Notifications
You must be signed in to change notification settings - Fork 35
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 ReinterpretArrays to supported array types #72
Conversation
cc @tkf |
I think it'd be nice to have some multi-dim test cases. Especially with |
@KristofferC The nightly failure is due to the change in |
Yes |
Can you please clarify what you mean? It looks like vload and vstore are restricted to 1-dimensional arrays. |
Lines 161 to 162 in b19dcde
Lines 282 to 287 in b19dcde
Since we are now going to allow |
@tkf - I apologize, I'm not entirely clear on how the indexing notation works. I can load/store normal and reinterpret 1-d arrays, but not sure how multidimensional should work.
|
I was thinking something like x = reinterpret(Float64, view(zeros(UInt8, 64, 8), :, 1:2:8))
x[VecRange{4}(1), 1] can be tested now.
This sounds like a bug to me (maybe a pre-existing one triggered by this PR). |
Actually, this is nothing to do with this PR. It's fixed in #73. |
I added ReinterpretArrays to the supported contiguous array types. I think it should just work?
3f3cd8d
to
1c179dd
Compare
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
==========================================
+ Coverage 82.23% 82.96% +0.73%
==========================================
Files 5 5
Lines 653 681 +28
==========================================
+ Hits 537 565 +28
Misses 116 116
Continue to review full report at Codecov.
|
Rebased onto master and added the multidimensional tests. Had to add |
src/arrayops.jl
Outdated
Base.@propagate_inbounds _pointer(arr::Base.ReinterpretArray, i, I) = | ||
pointer(arr, LinearIndices(arr)[i, I...]) | ||
Base.@propagate_inbounds _pointer(arr::Base.ReinterpretArray, i, I::Tuple{}) = | ||
pointer(arr, i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to merge them with above methods using Union{Array,Base.ReinterpretArray}
and Union{Base.FastContiguousSubArray,Base.ReinterpretArray}
.
Hmm, I don't understand why an ambiguity would exist. They should be equivalent expressions in Julia right? It's confused between:
It seems that it may not be doing multiple dispatch correctly? This is on Julia 1.5.1 |
Hmm... That's unfortunate. I guess using julia> f(::Union{Int32,Int64}, ::Tuple{}) = 1;
julia> f(::Int32, ::Any) = 2;
julia> f(::Int64, ::Any) = 3;
julia> f
f (generic function with 3 methods)
julia> f(1, ())
ERROR: MethodError: f(::Int64, ::Tuple{}) is ambiguous. Candidates:
f(::Int64, ::Any) in Main at REPL[20]:1
f(::Union{Int32, Int64}, ::Tuple{}) in Main at REPL[18]:1
Possible fix, define
f(::Int64, ::Tuple{}) I guess it's better to keep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is no API guarantee that reinterpret
returns a ReinterpretArray
(although I doubt Base
would change it) and to be very explicit about the type of the variables, I think it's a good idea to add type assertions.
Other than these minor points, the PR looks good to me.
Co-authored-by: Takafumi Arakaki <takafumi.a@gmail.com>
Co-authored-by: Takafumi Arakaki <takafumi.a@gmail.com>
Do you think the PR can be merged? |
I added ReinterpretArrays to the supported contiguous array types. I think it should just work?