Skip to content

Commit 09798ea

Browse files
committed
hacky fix for inner max reduction
1 parent 088795c commit 09798ea

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.70"
4+
version = "0.12.71"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
@@ -32,5 +32,5 @@ Static = "0.2, 0.3"
3232
StrideArraysCore = "0.2"
3333
ThreadingUtilities = "0.4.5"
3434
UnPack = "1"
35-
VectorizationBase = "0.21.1"
35+
VectorizationBase = "0.21.3"
3636
julia = "1.5"

test/outer_reductions.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
function reg_term(omega, B = size(omega,2); alpha=0.01)
2+
reg = 0.0
3+
for b in 1:B
4+
t = maximum(@views omega[:, b]) - omega[b,b]
5+
reg += t
6+
end
7+
return alpha*reg
8+
end
9+
10+
function reg_term_turbo(omega, B = size(omega,2); alpha=0.01)
11+
reg = 0.0
12+
@turbo for b in 1:B
13+
m = -Inf
14+
for i in axes(omega,1)
15+
m = max(m, omega[i,b])
16+
end
17+
t = m - omega[b,b]
18+
reg += t
19+
end
20+
return alpha*reg
21+
end
122

223
function awmean_lv(x::AbstractArray{T1}, σ::AbstractArray{T2}) where {T1<:Number,T2<:Number}
324
n = length(x)
@@ -114,5 +135,8 @@ end
114135
for n 1:20, k 1:5
115136
test_logℒ(n,k)
116137
end
138+
omega = rand(87,87);
139+
@test reg_term(omega) reg_term_turbo(omega)
140+
117141
end
118142

0 commit comments

Comments
 (0)