1
- function test_broadcasting (Typ )
1
+ function test_broadcasting (AT )
2
2
@testset " broadcast" begin
3
- broadcasting (Typ )
4
- vec3 (Typ )
3
+ broadcasting (AT )
4
+ vec3 (AT )
5
5
end
6
6
end
7
7
@@ -29,24 +29,24 @@ function test_kernel(a::T, b) where T
29
29
return c
30
30
end
31
31
32
- function broadcasting (Typ )
32
+ function broadcasting (AT )
33
33
for ET in supported_eltypes ()
34
34
N = 10
35
35
@testset " broadcast $ET " begin
36
36
@testset " RefValue" begin
37
37
cidx = rand (1 : Int (N), 2 * N)
38
- gidx = Typ (cidx)
38
+ gidx = AT (cidx)
39
39
cy = rand (ET, 2 * N)
40
- gy = Typ (cy)
40
+ gy = AT (cy)
41
41
cres = fill (zero (ET), size (cidx))
42
- gres = Typ (cres)
42
+ gres = AT (cres)
43
43
gres .= test_idx .(gidx, Base. RefValue (gy))
44
44
cres .= test_idx .(cidx, Base. RefValue (cy))
45
45
@test Array (gres) == cres
46
46
end
47
47
48
48
@testset " Tuple" begin
49
- @test compare (Typ , rand (ET, 3 , N), rand (ET, 3 , N), rand (ET, N), rand (ET, N), rand (ET, N)) do out, arr, a, b, c
49
+ @test compare (AT , rand (ET, 3 , N), rand (ET, 3 , N), rand (ET, N), rand (ET, N), rand (ET, N)) do out, arr, a, b, c
50
50
broadcast! (out, arr, (a, b, c)) do xx, yy
51
51
xx + first (yy)
52
52
end
@@ -55,38 +55,38 @@ function broadcasting(Typ)
55
55
56
56
# ###########
57
57
# issue #27
58
- @test compare ((a, b)-> a .+ b, Typ , rand (ET, 4 , 5 , 3 ), rand (ET, 1 , 5 , 3 ))
59
- @test compare ((a, b)-> a .+ b, Typ , rand (ET, 4 , 5 , 3 ), rand (ET, 1 , 5 , 1 ))
58
+ @test compare ((a, b)-> a .+ b, AT , rand (ET, 4 , 5 , 3 ), rand (ET, 1 , 5 , 3 ))
59
+ @test compare ((a, b)-> a .+ b, AT , rand (ET, 4 , 5 , 3 ), rand (ET, 1 , 5 , 1 ))
60
60
61
61
# ###########
62
62
# issue #22
63
63
dim = (32 , 32 )
64
- @test compare (Typ , rand (ET, dim), rand (ET, dim), rand (ET, dim)) do tmp, a1, a2
64
+ @test compare (AT , rand (ET, dim), rand (ET, dim), rand (ET, dim)) do tmp, a1, a2
65
65
tmp .= a1 .+ a2 .* ET (2 )
66
66
end
67
67
68
68
# ###########
69
69
# issue #21
70
70
if ET in (Float32, Float64)
71
- @test compare ((a1, a2)-> muladd .(ET (2 ), a1, a2), Typ , rand (ET, dim), rand (ET, dim))
71
+ @test compare ((a1, a2)-> muladd .(ET (2 ), a1, a2), AT , rand (ET, dim), rand (ET, dim))
72
72
# ########
73
73
# issue #41
74
74
# The first issue is likely https://github.com/JuliaLang/julia/issues/22255
75
75
# since GPUArrays adds some arguments to the function, it becomes longer longer, hitting the 12
76
76
# so this wont fix for now
77
- @test compare (Typ , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do a1, a2, a3, a4, a5, a6
77
+ @test compare (AT , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do a1, a2, a3, a4, a5, a6
78
78
@. a1 = a2 + (1.2 ) * ((1.3 )* a3 + (1.4 )* a4 + (1.5 )* a5 + (1.6 )* a6)
79
79
end
80
80
81
- @test compare (Typ , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do u, uprev, duprev, ku
81
+ @test compare (AT , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do u, uprev, duprev, ku
82
82
fract = ET (1 // 2 )
83
83
dt = ET (1.4 )
84
84
dt2 = dt^ 2
85
85
@. u = uprev + dt* duprev + dt2* (fract* ku)
86
86
end
87
- @test compare ((x) -> (- ). (x), Typ , rand (ET, 2 , 3 ))
87
+ @test compare ((x) -> (- ). (x), AT , rand (ET, 2 , 3 ))
88
88
89
- @test compare (Typ , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do utilde, gA, k1, k2, k3, k4
89
+ @test compare (AT , rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim), rand (ET, dim)) do utilde, gA, k1, k2, k3, k4
90
90
btilde1 = ET (1 )
91
91
btilde2 = ET (1 )
92
92
btilde3 = ET (1 )
@@ -96,37 +96,37 @@ function broadcasting(Typ)
96
96
end
97
97
end
98
98
99
- @test compare ((x) -> fill! (x, 1 ), Typ , rand (ET, 3 ,3 ))
100
- @test compare ((x, y) -> map (+ , x, y), Typ , rand (ET, 2 , 3 ), rand (ET, 2 , 3 ))
99
+ @test compare ((x) -> fill! (x, 1 ), AT , rand (ET, 3 ,3 ))
100
+ @test compare ((x, y) -> map (+ , x, y), AT , rand (ET, 2 , 3 ), rand (ET, 2 , 3 ))
101
101
102
- @test compare ((x) -> 2 x, Typ , rand (ET, 2 , 3 ))
103
- @test compare ((x, y) -> x .+ y, Typ , rand (ET, 2 , 3 ), rand (ET, 1 , 3 ))
104
- @test compare ((z, x, y) -> z .= x .+ y, Typ , rand (ET, 2 , 3 ), rand (ET, 2 , 3 ), rand (ET, 2 ))
102
+ @test compare ((x) -> 2 x, AT , rand (ET, 2 , 3 ))
103
+ @test compare ((x, y) -> x .+ y, AT , rand (ET, 2 , 3 ), rand (ET, 1 , 3 ))
104
+ @test compare ((z, x, y) -> z .= x .+ y, AT , rand (ET, 2 , 3 ), rand (ET, 2 , 3 ), rand (ET, 2 ))
105
105
106
- @test compare (A -> A .= identity .(ET (10 )), Typ , rand (ET, 40 , 40 ))
107
- @test compare (A -> test_kernel .(A, ET (10 )), Typ , rand (ET, 40 , 40 ))
108
- @test compare (A -> A .* ET (10 ), Typ , rand (ET, 40 , 40 ))
109
- @test compare ((A, B) -> A .* B, Typ , rand (ET, 40 , 40 ), rand (ET, 40 , 40 ))
110
- @test compare ((A, B) -> A .* B .+ ET (10 ), Typ , rand (ET, 40 , 40 ), rand (ET, 40 , 40 ))
106
+ @test compare (A -> A .= identity .(ET (10 )), AT , rand (ET, 40 , 40 ))
107
+ @test compare (A -> test_kernel .(A, ET (10 )), AT , rand (ET, 40 , 40 ))
108
+ @test compare (A -> A .* ET (10 ), AT , rand (ET, 40 , 40 ))
109
+ @test compare ((A, B) -> A .* B, AT , rand (ET, 40 , 40 ), rand (ET, 40 , 40 ))
110
+ @test compare ((A, B) -> A .* B .+ ET (10 ), AT , rand (ET, 40 , 40 ), rand (ET, 40 , 40 ))
111
111
end
112
112
end
113
113
end
114
114
115
- function vec3 (Typ )
115
+ function vec3 (AT )
116
116
@testset " vec 3" begin
117
117
N = 20
118
118
119
119
xc = map (x-> ntuple (i-> rand (Float32), Val (3 )), 1 : N)
120
120
yc = map (x-> ntuple (i-> rand (Float32), Val (3 )), 1 : N)
121
121
122
- x = Typ (xc)
123
- y = Typ (yc)
122
+ x = AT (xc)
123
+ y = AT (yc)
124
124
125
125
res1c = fill (0f0 , N)
126
126
res2c = similar (xc)
127
127
128
- res1 = Typ (res1c)
129
- res2 = Typ (res2c)
128
+ res1 = AT (res1c)
129
+ res2 = AT (res2c)
130
130
131
131
res1 .= testv3_1 .(x, y)
132
132
res1c .= testv3_1 .(xc, yc)
0 commit comments