Skip to content

Commit 0b88066

Browse files
authored
fix log domain issue in exp broadcast (#50)
1 parent 296e37e commit 0b88066

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/derivatives/elementwise.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,11 @@ exp_partials(b, e) = broadcast(exp_partials_kernel, b, e)
581581
exp_partials!(out::Ref, b, e) = (out[] = exp_partials_kernel(b, e); nothing)
582582
exp_partials!(out::AbstractArray, b, e) = (broadcast!(exp_partials_kernel, out, b, e); nothing)
583583

584-
pow_cache(x, y) = (base_partials(value(x), value(y)), exp_partials(value(x), value(y)))
584+
function pow_cache(x, y)
585+
pow_x = istracked(x) ? base_partials(value(x), value(y)) : value(x)
586+
pow_y = istracked(y) ? exp_partials(value(x), value(y)) : value(y)
587+
return (pow_x, pow_y)
588+
end
585589

586590
function broadcast_pow{D}(x, y, ::Type{D})
587591
tp = tape(x, y)

0 commit comments

Comments
 (0)