Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
perf: be conservative while fusing activation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Aug 14, 2024
1 parent fed6eac commit ae92df9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions src/impl/activation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,4 @@ fast_act(f::F) where {F} = f

CRC.@non_differentiable fast_act(::Any...)

for act in (:sigmoid_fast, :swish, :lisht, :tanh_fast, :tanh)
@eval Traits.fuse_cpu_activation(::typeof($act)) = True()
end

end
2 changes: 1 addition & 1 deletion src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function activation_has_rrule(::F, ::Type{T}) where {F, T}
end

# Which activations can be fused into a single kernel
for act in (:identity, :(NNlib.relu), :abs, :abs2, :(NNlib.tanh_fast))
for act in (:identity, :(NNlib.relu), :abs, :abs2)
@eval fuse_cpu_activation(::typeof($act)) = True()
end
fuse_cpu_activation(::F) where {F} = False()
Expand Down

0 comments on commit ae92df9

Please sign in to comment.