Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ndarray/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ end

function _nda_from_julia_array(arr::Array{T,N}) where {T,N}
_struct_storage_type(T) && return _nda_from_julia_struct_array(arr)
tmp = collect(permutedims(arr, reverse(ntuple(identity, Val(N)))))
tmp = permutedims(arr, reverse(ntuple(identity, Val(N))))
return cuNumeric.nda_attach_external(tmp; shape=size(arr))
end

Expand Down
20 changes: 20 additions & 0 deletions test/array/conversion_lifetimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ end
end
end

@testset "Multidimensional conversion ownership" begin
for T in (Float32, Float64, ComplexF32, Int32), dims in ((2, 3), (2, 3, 4))
expected = reshape(T.(1:prod(dims)), dims)
source = copy(expected)
a = cuNumeric.NDArray(source)
try
# Conversion must retain its own dense buffer, with the original
# logical shape and element order, after the input is released.
fill!(source, zero(T))
source = nothing
GC.gc(true)
@test eltype(a) === T
@test size(a) == dims
@test Array(a) == expected
finally
cuNumeric.destroy!(a)
end
end
end

@testset "Singleton vector host conversion" begin
# Runtime-created singletons can use scalar futures; attached input
# vectors do not exercise the same storage representation.
Expand Down
Loading