Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forward_diff_no_inf can't handle throw_undef_if_not #161

Open
oxinabox opened this issue Jun 14, 2023 · 0 comments
Open

forward_diff_no_inf can't handle throw_undef_if_not #161

oxinabox opened this issue Jun 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@oxinabox
Copy link
Member

Ran into this while trying to reproduce another bug.
The following code errors:

using Diffractor
# this is needed as transform! is *always* called on Arguments regardless of what visit_custom says
identity_transform!(ir, ssa::Core.SSAValue, order) = ir[ssa]
function identity_transform!(ir, arg::Core.Argument, order)
    return Core.Compiler.insert_node!(ir, Core.SSAValue(1), Core.Compiler.NewInstruction(Expr(:call, Diffractor.ZeroBundle{1}, arg), Any))
end

function phi_run(x::Float64, b1::Bool, b2::Bool)
    if b1
        a = 0.
    elseif b2
        a = z
    end
    return x - a
end

input_ir = first(only(Base.code_ircode(phi_run, Tuple{Float64, Bool, Bool})))
Diffractor.forward_diff_no_inf!(copy(input_ir), Core.SSAValue.(1:length(input_ir.stmts)) .=> 1; transform! = identity_transform!)

I think the fix is easy, add the case to forward_visit about what to do for this kind of node.
Which i think is return nothing

@oxinabox oxinabox added the bug Something isn't working label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant