Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 1, 2024
1 parent 0a483ed commit 655ec30
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/analyses/activity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

@inline element(::Val{T}) where {T} = T

@inline function (c::Merger{seen,worldT,justActive,UnionSret,AbstractIsMixed})(
Base.@assume_effects :removable :foldable :nothrow @inline function (c::Merger{seen,worldT,justActive,UnionSret,AbstractIsMixed})(
f::Int,
) where {seen,worldT,justActive,UnionSret,AbstractIsMixed}
T = element(first(seen))
Expand Down Expand Up @@ -60,9 +60,9 @@ end
end
end

@inline forcefold(::Val{RT}) where {RT} = RT
Base.@assume_effects :removable :foldable :nothrow @inline forcefold(::Val{RT})::ActivityState where {RT} = RT

@inline function forcefold(::Val{ty}, ::Val{sty}, C::Vararg{Any,N}) where {ty,sty,N}
Base.@assume_effects :removable :foldable :nothrow @inline function forcefold(::Val{ty}, ::Val{sty}, C::Vararg{Any,N})::ActivityState where {ty,sty,N}
if sty == AnyState || sty == ty
return forcefold(Val(ty), C...)
end
Expand Down Expand Up @@ -107,25 +107,25 @@ else
@inline is_arrayorvararg_ty(::Type{Memory{T}}) where T = true
end

@inline function datatype_fieldcount(t::Type{T}) where {T}
@inline function datatype_fieldcount(t::Type{T})::Int where {T}
return Base.datatype_fieldcount(t)
end

@inline function staticInTup(::Val{T}, tup::NTuple{N,Val}) where {T,N}
Base.@assume_effects :removable :foldable :nothrow @inline function staticInTup(::Val{T}, tup::NTuple{N,Val})::Bool where {T,N}
any(ntuple(Val(N)) do i
Base.@_inline_meta
Val(T) == tup[i]
end)
end

@inline function active_reg_recur(
Base.@assume_effects :removable :foldable :nothrow @inline function active_reg_recur(
::Type{ST},
seen::Seen,
world,
::Val{justActive},
::Val{UnionSret},
::Val{AbstractIsMixed},
) where {ST,Seen,justActive,UnionSret,AbstractIsMixed}
)::ActivityState where {ST,Seen,justActive,UnionSret,AbstractIsMixed}
if ST isa Union
return forcefold(
Val(
Expand Down Expand Up @@ -163,7 +163,7 @@ end
@inline is_vararg_tup(x) = false
@inline is_vararg_tup(::Type{Tuple{Vararg{T2}}}) where {T2} = true

@inline function active_reg_inner(
Base.@assume_effects :removable :foldable :nothrow @inline function active_reg_inner(
::Type{T},
seen::ST,
world::Union{Nothing,UInt},
Expand Down Expand Up @@ -383,11 +383,11 @@ end
return ty
end

@inline @generated function active_reg_nothrow(::Type{T}, ::Val{world}) where {T,world}
Base.@assume_effects :removable :foldable :nothrow @inline @generated function active_reg_nothrow(::Type{T}, ::Val{world})::ActivityState where {T,world}
return active_reg_inner(T, (), world)
end

Base.@pure @inline function active_reg(
Base.@assume_effects :removable :foldable :nothrow @inline function active_reg(
::Type{T},
world::Union{Nothing,UInt} = nothing,
)::Bool where {T}
Expand All @@ -411,21 +411,21 @@ Base.@pure @inline function active_reg(
end
end

@inline function guaranteed_const(::Type{T}) where {T}
Base.@assume_effects :removable :foldable :nothrow @inline function guaranteed_const(::Type{T})::Bool where {T}
rt = active_reg_nothrow(T, Val(nothing))
res = rt == AnyState
return res
end

@inline function guaranteed_const_nongen(::Type{T}, world) where {T}
Base.@assume_effects :removable :foldable :nothrow @inline function guaranteed_const_nongen(::Type{T}, world)::Bool where {T}
rt = active_reg_inner(T, (), world)
res = rt == AnyState
return res
end

# check if a value is guaranteed to be not contain active[register] data
# (aka not either mixed or active)
@inline function guaranteed_nonactive(::Type{T}) where {T}
Base.@assume_effects :removable :foldable :nothrow @inline function guaranteed_nonactive(::Type{T})::Bool where {T}
rt = Enzyme.Compiler.active_reg_nothrow(T, Val(nothing))
return rt == Enzyme.Compiler.AnyState || rt == Enzyme.Compiler.DupState
end
Expand All @@ -435,10 +435,10 @@ end
Try to guess the most appropriate [`Annotation`](@ref) for arguments of type `T` passed to [`autodiff`](@ref) with a given `mode`.
"""
@inline Enzyme.guess_activity(::Type{T}, mode::Enzyme.Mode) where {T} =
Base.@assume_effects :removable :foldable :nothrow @inline Enzyme.guess_activity(::Type{T}, mode::Enzyme.Mode) where {T} =
guess_activity(T, convert(API.CDerivativeMode, mode))

@inline function Enzyme.guess_activity(::Type{T}, Mode::API.CDerivativeMode) where {T}
Base.@assume_effects :removable :foldable :nothrow @inline function Enzyme.guess_activity(::Type{T}, Mode::API.CDerivativeMode) where {T}
ActReg = active_reg_nothrow(T, Val(nothing))
if ActReg == AnyState
return Const{T}
Expand Down

0 comments on commit 655ec30

Please sign in to comment.