Skip to content

Commit 039b89e

Browse files
committed
Add sample test
1 parent fea2613 commit 039b89e

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/indexing.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function _getindex(xs::GPUArray{T}, i::Integer) where T
1616
end
1717

1818
function Base.getindex(xs::GPUArray{T}, i::Integer) where T
19-
assertslow("getindex")
19+
# assertslow("getindex")
2020
_getindex(xs, i)
2121
end
2222

@@ -27,7 +27,7 @@ function _setindex!(xs::GPUArray{T}, v::T, i::Integer) where T
2727
end
2828

2929
function Base.setindex!(xs::GPUArray{T}, v::T, i::Integer) where T
30-
assertslow("setindex!")
30+
# assertslow("setindex!")
3131
_setindex!(xs, v, i)
3232
end
3333

src/testsuite/pool.jl

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using GPUArrays.TestSuite, Base.Test, Flux
2+
3+
function run_pool(Typ)
4+
for ET in supported_eltypes()
5+
T = Typ{ET}
6+
if (ET == Complex{Float32} || ET == Complex{Float64})
7+
continue
8+
end
9+
@testset "$ET" begin
10+
@testset "maxpool" begin
11+
pool = 3
12+
stride = 3
13+
pad = 3
14+
15+
a = rand(ET, 9,9,3,1)
16+
b = zeros(eltype(a), size(a,1) + pad * 2, size(a,2) + pad * 2, size(a,3), size(a,4))
17+
b[pad + 1 : pad + size(a,1), pad + 1 : pad + size(a,2), :, :] = a
18+
out1 = maxpool(b, (3, 3))
19+
20+
a = T(a)
21+
out2 = GPUArrays.maxpool2d(a, pool, stride = 3, pad = 3)
22+
23+
@test out1 out2
24+
end
25+
end
26+
end
27+
end

src/testsuite/testsuite.jl

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ include("base.jl")
4242
include("indexing.jl")
4343
# include("vector.jl")
4444
include("random.jl")
45+
include("pool.jl")
4546

4647
function supported_eltypes()
4748
(Float32, Float64, Int32, Int64, Complex64, Complex128)
@@ -62,6 +63,7 @@ function run_tests(Typ)
6263
run_mapreduce(Typ)
6364
run_indexing(Typ)
6465
run_random(Typ)
66+
run_pool(Typ)
6567
end
6668

6769
export against_base, run_tests, supported_eltypes

test/REQUIRE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flux
2+
CUDAnative

0 commit comments

Comments
 (0)