-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy patharraypartition_gpu.jl
More file actions
28 lines (22 loc) · 832 Bytes
/
arraypartition_gpu.jl
File metadata and controls
28 lines (22 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using RecursiveArrayTools, ArrayInterface, CUDA, Test
CUDA.allowscalar(false)
# Test indexing with colon
a = (CUDA.zeros(5), CUDA.zeros(5))
pA = ArrayPartition(a)
pA[:, :]
# Indexing with boolean masks does not work yet
mask = pA .> 0
# pA[mask]
# Test recursive filling is done using GPU kernels and not scalar indexing
RecursiveArrayTools.recursivefill!(pA, true)
@test all(pA .== true)
# Test that regular filling is done using GPU kernels and not scalar indexing
fill!(pA, false)
@test all(pA .== false)
a = ArrayPartition(([1.0f0] |> cu, [2.0f0] |> cu, [3.0f0] |> cu))
b = ArrayPartition(([0.0f0] |> cu, [0.0f0] |> cu, [0.0f0] |> cu))
@. a + b
x = ArrayPartition((CUDA.zeros(2),CUDA.zeros(2)))
@test ArrayInterface.zeromatrix(x) isa CuMatrix
@test size(ArrayInterface.zeromatrix(x)) == (4,4)
@test maximum(abs, x) == 0f0