Skip to content

Commit d2c019a

Browse files
Tests of mapreducethen
1 parent 54b201e commit d2c019a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/vmapreducethen.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Assorted tests; TODO: systematic
2+
xx = rand(ntuple(_ -> 3, 4)...);
3+
@timev R = vmapreducethen(abs2, +, , xx, dims=(2,4))
4+
@timev R2 = .√mapreduce(abs2, +, xx, dims=(2,4))
5+
R R2
6+
7+
XX = rand(ntuple(_ -> 5, 4)...);
8+
@benchmark vmapreducethen(abs2, +, , $XX, dims=(2,4))
9+
@benchmark .√mapreduce(abs2, +, XX, dims=(2,4))
10+
11+
@benchmark vnorm3($x1, 2.0)
12+
@benchmark vnorm($x1, 1.5)
13+
@benchmark vnorm3($x1, 1.5)
14+
15+
16+
@benchmark vnorm($x1, 2.0)
17+
@benchmark norm($x1, 1.5)
18+
@benchmark vnorm($x1, 1)
19+
@benchmark vnorm2($x1, 1.5)
20+
21+
vmean(x1, dims=(2,4))
22+
@benchmark vmean($lpds, dims=(1,2))
23+
@benchmark mean($lpds, dims=(1,2))
24+
25+
@benchmark veuclidean($x1, $x2)
26+
@benchmark norm($x1 .- $x2)
27+
@benchmark euclidean($x1, $x2)
28+
@test euclidean(x1, x2, dims=(2,4)) veuclidean(x1, x2, dims=(2,4))
29+
@benchmark veuclidean($x1, $x2, dims=(2,4))
30+
@benchmark euclidean($x1, $x2, dims=(2,4))
31+
32+
YY = rand(1:100, 3,3,3,3);
33+
xxx = rand(3,3,3,3);
34+
35+
@benchmark vmapreducethen(abs2, +, abs2, $YY, dims=(2,4))
36+
@benchmark vmapreducethen(abs2, +, abs2, $xxx, dims=(2,4))
37+
38+
abs2.(mapreduce(abs2, +, YY, dims=(2,4))) == vmapreducethen(abs2, +, abs2, YY, dims=(2,4))
39+
40+
@code_warntype _vmapreducethen!(abs2, +, abs2, zero, R, xxx, (static(2), static(4)))
41+
42+
x1 = rand(5,5,5,5);
43+
x2 = rand(5,5,5,5);
44+
x3 = rand(5,5,5,5);
45+
@benchmark vmapreducethen(+, +, abs2, $x1, $x2, $x3)
46+
@benchmark abs2(mapreduce(+, +, $x1, $x2, $x3))
47+
@test abs2(mapreduce(+, +, x1, x2, x3)) vmapreducethen(+, +, abs2, x1, x2, x3)
48+
49+
@benchmark vmapreducethen(+, +, abs2, $x1, $x2, $x3, dims=(2,4))
50+
@benchmark abs2.(mapreduce(+, +, $x1, $x2, $x3, dims=(2,4)))

0 commit comments

Comments
 (0)