Skip to content

Support symbols in arrays #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
26 changes: 26 additions & 0 deletions test/rocarray/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ end

# Can use in HIP libraries.
@test Array(xd * xd) ≈ Array(x * x)

# symbols and tuples thereof
let a = ROCArray([:a])
b = unsafe_wrap(ROCArray, pointer(a), 1; lock=false)
@test typeof(b) <: ROCArray{Symbol,1}
@test size(b) == (1,)
end
let a = ROCArray([(:a,:b)])
b = unsafe_wrap(ROCArray, pointer(a), 1; lock=false)
@test typeof(b) <: ROCArray{Tuple{Symbol,Symbol},1}
@test size(b) == (1,)
end
end

@testset "Multiple wraps of the same array" begin
Expand Down Expand Up @@ -217,6 +229,20 @@ end
@test Array(dtarget) == target
end

@testset "symbols" begin
function pass_symbol(x, name)
i = name == :var ? 1 : 2
x[i] = true
return nothing
end
x = ROCArray([false, false])
@roc pass_symbol(x, :var)
@test Array(x) == [true, false]
@roc pass_symbol(x, :not_var)
@test Array(x) == [true, true]
end
end

include("sorting.jl")
include("reverse.jl")

Expand Down