Skip to content

Commit bc0a63e

Browse files
authored
Merge pull request #63 from JuliaGPU/vc/norecurse_sin
don't recuse into functions like Base.sin
2 parents f81d8e1 + e35f214 commit bc0a63e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/backends/cpu.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,25 @@ end
179179

180180
generate_overdubs(CPUCtx)
181181

182+
# Don't recurse into these functions
183+
const cpufuns = (:cos, :cospi, :sin, :sinpi, :tan,
184+
:acos, :asin, :atan,
185+
:cosh, :sinh, :tanh,
186+
:acosh, :asinh, :atanh,
187+
:log, :log10, :log1p, :log2,
188+
:exp, :exp2, :exp10, :expm1, :ldexp,
189+
:isfinite, :isinf, :isnan, :signbit,
190+
:abs,
191+
:sqrt, :cbrt,
192+
:ceil, :floor,)
193+
for f in cpufuns
194+
@eval function Cassette.overdub(ctx::CPUCtx, ::typeof(Base.$f), x::Union{Float32, Float64})
195+
@Base._inline_meta
196+
return Base.$f(x)
197+
end
198+
end
199+
200+
182201
###
183202
# CPU implementation of shared memory
184203
###

0 commit comments

Comments
 (0)