Skip to content

Commit 852bd0c

Browse files
committed
Add a jl convenience function.
1 parent 8bebc17 commit 852bd0c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/reference.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module JLArrays
77

8-
export JLArray
8+
export JLArray, jl
99

1010
using GPUArrays
1111

@@ -196,6 +196,9 @@ JLArray(A::AbstractArray{T,N}) where {T,N} = JLArray{T,N}(A)
196196
# idempotency
197197
JLArray{T,N}(xs::JLArray{T,N}) where {T,N} = xs
198198

199+
jl(xs) = adapt(JLArray, xs)
200+
Adapt.adapt_storage(::Type{JLArray}, xs::AbstractArray) = convert(JLArray, xs)
201+
199202

200203
## conversions
201204

test/runtests.jl

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ include("testsuite.jl")
44

55
@testset "JLArray" begin
66
using GPUArrays.JLArrays
7+
8+
jl([1])
9+
710
JLArrays.allowscalar(false)
811
TestSuite.test(JLArray)
912
end

0 commit comments

Comments
 (0)