Skip to content

Commit

Permalink
Custom forward rule for Expr(:new, ) in forward_diff_no_inf!
Browse files Browse the repository at this point in the history
Frames and I tracked down an issue where the type argument to an
`Expr(:new, )` (argument #1) was getting wrapped in a `ZeroBundle`.
This commit adds a special-case for `Expr(:new, )` into
`forward_diff_no_inf!()` that mimics what we see elsewhere, making use
of `∂☆new`.
  • Loading branch information
staticfloat committed May 17, 2023
1 parent c8d47ab commit 0a3e34a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/codegen/forward_demand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
end
inst[:inst] = Expr(:call, ∂☆{order}(), newargs...)
inst[:type] = Any
elseif isexpr(stmt, :call)
elseif isexpr(stmt, :call) || isexpr(stmt, :new)
newargs = map(stmt.args) do @nospecialize arg
maparg(arg, SSAValue(ssa), order)
end
inst[:inst] = Expr(:call, ∂☆{order}(), newargs...)
f = isexpr(stmt, :call) ? ∂☆{order}() : ∂☆new{order}()
inst[:inst] = Expr(:call, f, newargs...)
inst[:type] = Any
elseif isa(stmt, PiNode)
# TODO: New PiNode that discriminates based on primal?
Expand Down

0 comments on commit 0a3e34a

Please sign in to comment.