Skip to content

Commit cd09e2f

Browse files
committed
Fix sub_materialize for GPU arrays
1 parent 3687e2c commit cd09e2f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "1.11.1"
4+
version = "1.12.0"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
@@ -17,6 +17,7 @@ ArrayLayoutsSparseArraysExt = "SparseArrays"
1717
Aqua = "0.8"
1818
FillArrays = "1.2.1"
1919
Infinities = "0.1"
20+
JLArrays = "0.2"
2021
LinearAlgebra = "1"
2122
Quaternions = "0.7"
2223
Random = "1"
@@ -29,6 +30,7 @@ julia = "1.10"
2930
[extras]
3031
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3132
Infinities = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
33+
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
3234
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
3335
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3436
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -37,4 +39,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3739
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3840

3941
[targets]
40-
test = ["Aqua", "Infinities", "Quaternions", "Random", "StableRNGs", "SparseArrays", "StaticArrays", "Test"]
42+
test = ["Aqua", "Infinities", "JLArrays", "Quaternions", "Random", "StableRNGs", "SparseArrays", "StaticArrays", "Test"]

src/ArrayLayouts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ include("triangular.jl")
126126
include("factorizations.jl")
127127

128128
# Extend this function if you're only looking to dispatch on the axes
129-
@inline sub_materialize_axes(V, _) = Array(V)
129+
@inline sub_materialize_axes(V, _) = copyto!(similar(V), V)
130130
@inline sub_materialize(_, V, ax) = sub_materialize_axes(V, ax)
131131
@inline sub_materialize(L, V) = sub_materialize(L, V, axes(V))
132132
@inline sub_materialize(V::SubArray) = sub_materialize(MemoryLayout(V), V)

test/test_layouts.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestLayouts
22

3-
using ArrayLayouts, LinearAlgebra, FillArrays, Test
3+
using ArrayLayouts, LinearAlgebra, FillArrays, JLArrays, Test
44
import ArrayLayouts: MemoryLayout, DenseRowMajor, DenseColumnMajor, StridedLayout,
55
ConjLayout, RowMajor, ColumnMajor, UnitStride,
66
SymmetricLayout, HermitianLayout, UpperTriangularLayout,
@@ -404,6 +404,16 @@ struct FooNumber <: Number end
404404
@test ArrayLayouts.mul((1:11)', F) isa AbstractMatrix{Int}
405405
end
406406

407+
@testset "GPUArrays/JLArrays" begin
408+
A = jl(randn(5,5))
409+
@test MemoryLayout(A) == DenseColumnMajor()
410+
@test ArrayLayouts.layout_getindex(A,1:3,1:3) == A[1:3,1:3]
411+
@test ArrayLayouts.layout_getindex(A,1:3,1:3) isa JLArray{Float64}
412+
V = view(A,1:3,1:3)
413+
@test ArrayLayouts.sub_materialize(V) == A[1:3,1:3]
414+
@test ArrayLayouts.sub_materialize(V) isa JLArray{Float64}
415+
end
416+
407417
@testset "Triangular col/rowsupport" begin
408418
A = randn(5,5)
409419
@test colsupport(UpperTriangular(A),3) Base.OneTo(3)

0 commit comments

Comments
 (0)