Skip to content

Commit

Permalink
copy in constructor (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
jariji authored Sep 5, 2024
1 parent d8978bd commit 7bec32c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ROCArray{T}(xs::AbstractArray{S,N}) where {T,N,S} = ROCArray{T,N}(xs)
(::Type{ROCArray{T,N} where T})(x::AbstractArray{S,N}) where {S,N} = ROCArray{S,N}(x)

# idempotency
ROCArray{T,N}(xs::ROCArray{T,N}) where {T,N} = xs
ROCArray{T,N}(xs::ROCArray{T,N}) where {T,N} = copy(xs)

## conversions

Expand Down
9 changes: 9 additions & 0 deletions test/rocarray/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
@test x.buf[].mem isa B
end

@testset "Constructor" begin
x = ROCArray([1.0])
y = ROCArray(x)
# Constructor doesn't just return its argument.
@test y !== x
# But is still equal.
@test y == x
end

@testset "ones/zeros" begin
x = @inferred AMDGPU.ones(4, 3)
@test x isa ROCArray
Expand Down

0 comments on commit 7bec32c

Please sign in to comment.