-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
reinterpret-like behavior on a SubArray? #16652
Comments
I doubt that it's usually valid to attempt to reinterpret a SubArray, as it is likely assuming quite a bit about how the underlying array is arranged in memory. |
You'd need |
I don't think this is really that important. |
Also worth noting that |
The following script fails due to lack of A = rand(Complex128, 3, 3, 2)
Av = view(A, :, :, 1)
B = rand(3,3)
C = zeros(Complex128, 3,3)
A_mul_B!(C, Av, B) with error ERROR: LoadError: MethodError: no method matching reinterpret(::Type{Float64}, ::SubArray{Complex{Float64},2,Array{Complex{Float64},3},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Tuple{Int64,Int64})
Closest candidates are:
reinterpret(::Type{T}, !Matched::Array{S,N} where N, ::Tuple{Vararg{Int64,N}}) where {N, S, T} at array.jl:143
reinterpret(::Type{T}, !Matched::Base.ReshapedArray, ::Tuple{Vararg{Int64,N}} where N) where T at reshapedarray.jl:171
reinterpret(::Type{T}, !Matched::SparseMatrixCSC{Tv,Ti}, ::Tuple{Vararg{Int64,N}}) where {T, Tv, Ti, N} at sparse/sparsematrix.jl:210
...
Stacktrace:
[1] A_mul_B!(::Array{Complex{Float64},2}, ::SubArray{Complex{Float64},2,Array{Complex{Float64},3},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Array{Float64,2}) at ./linalg/matmul.jl:154
[2] include_from_node1(::String) at ./loading.jl:552
[3] include(::String) at ./sysimg.jl:14
[4] process_options(::Base.JLOptions) at ./client.jl:305
[5] _start() at ./client.jl:371
while loading /tmp/tmp.jl, in expression starting on line 7 Some of the Blas wrappers try to reinterpret a complex array as real to do complex time real multiplicataion. |
I've been playing with
sub
a lot lately with a use-case around flipping between a "memory buffer" (Vector{UInt8}) and arrays, and find myself running into cases where I essentially want to do something like:in the second case, it being easier to just deal with a specific sub-region.
I wonder if we could possibly have a SubArray constructor like:
but maybe that would be weird because you're not sure if
dims
would apply to the parent array or as it would be interpreted byT
.Maybe we could just allow
reinterpret
on aSubArray
?I also realize that I may have just not thought long enough about this and am over-thinking it here.
The text was updated successfully, but these errors were encountered: