Skip to content

Commit 254546f

Browse files
committed
ifelse unroll
1 parent d21444a commit 254546f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.163"
4+
version = "0.12.164"
55

66

77
[deps]

ext/ForwardDiffExt.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ end
157157
end
158158
end
159159

160-
@generated function ifelse(
161-
m::AbstractMask,
160+
@generated function _ifelse(
161+
m::Union{AbstractMask,VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}},
162162
x::ForwardDiff.Dual{TAG,V,P},
163163
y::ForwardDiff.Dual{TAG,V,P}
164164
) where {TAG,V,P}
@@ -171,8 +171,8 @@ end
171171
ForwardDiff.Dual{$TAG}(z, ForwardDiff.Partials(p))
172172
end
173173
end
174-
@generated function ifelse(
175-
m::AbstractMask,
174+
@generated function _ifelse(
175+
m::Union{AbstractMask,VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}},
176176
x::Number,
177177
y::ForwardDiff.Dual{TAG,V,P}
178178
) where {TAG,V,P}
@@ -184,8 +184,8 @@ end
184184
ForwardDiff.Dual{$TAG}(z, ForwardDiff.Partials(p))
185185
end
186186
end
187-
@generated function ifelse(
188-
m::AbstractMask,
187+
@generated function _ifelse(
188+
m::Union{AbstractMask,VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}},
189189
x::ForwardDiff.Dual{TAG,V,P},
190190
y::Number
191191
) where {TAG,V,P}
@@ -197,6 +197,14 @@ end
197197
ForwardDiff.Dual{$TAG}(z, ForwardDiff.Partials(p))
198198
end
199199
end
200+
@inline ifelse(m::AbstractMask, x::ForwardDiff.Dual, y::Number) = _ifelse(m, x, y)
201+
@inline ifelse(m::AbstractMask, x::ForwardDiff.Dual, y::ForwardDiff.Dual) = _ifelse(m, x, y)
202+
@inline ifelse(m::AbstractMask, y::Number, x::ForwardDiff.Dual) = _ifelse(m, y, x)
203+
204+
@inline ifelse(m::VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}, x::ForwardDiff.Dual, y::Number) = _ifelse(m, x, y)
205+
@inline ifelse(m::VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}, x::ForwardDiff.Dual, y::ForwardDiff.Dual) = _ifelse(m, x, y)
206+
@inline ifelse(m::VecUnroll{<:Any,<:Any,Bit,<:AbstractMask}, y::Number, x::ForwardDiff.Dual) = _ifelse(m, y, x)
207+
200208
@inline function SLEEFPirates.softplus(x::ForwardDiff.Dual{TAG}) where {TAG}
201209
val = ForwardDiff.value(x)
202210
expx = exp(val)

src/reconstruct_loopset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Base.promote_rule(
2727
::Type{UpperBoundedInteger{N,T}},
2828
::Type{T}
2929
) where {N,T<:Base.BitInteger} = T
30-
Base.convert(::Type{T}, i::UpperBoundedInteger) where {T<:Number} =
30+
Base.convert(::Type{T}, i::UpperBoundedInteger) where {T<:Integer} =
3131
convert(T, i.i)
3232
Base.convert(
3333
::Type{UpperBoundedInteger{N,T}},

0 commit comments

Comments
 (0)