Skip to content

Commit 7bec32c

Browse files
authored
copy in constructor (#669)
1 parent d8978bd commit 7bec32c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/array.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ ROCArray{T}(xs::AbstractArray{S,N}) where {T,N,S} = ROCArray{T,N}(xs)
118118
(::Type{ROCArray{T,N} where T})(x::AbstractArray{S,N}) where {S,N} = ROCArray{S,N}(x)
119119

120120
# idempotency
121-
ROCArray{T,N}(xs::ROCArray{T,N}) where {T,N} = xs
121+
ROCArray{T,N}(xs::ROCArray{T,N}) where {T,N} = copy(xs)
122122

123123
## conversions
124124

test/rocarray/base.jl

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
@test x.buf[].mem isa B
1111
end
1212

13+
@testset "Constructor" begin
14+
x = ROCArray([1.0])
15+
y = ROCArray(x)
16+
# Constructor doesn't just return its argument.
17+
@test y !== x
18+
# But is still equal.
19+
@test y == x
20+
end
21+
1322
@testset "ones/zeros" begin
1423
x = @inferred AMDGPU.ones(4, 3)
1524
@test x isa ROCArray

0 commit comments

Comments
 (0)