Skip to content

mutating value in traced if is buggy #1312

@jumerckx

Description

@jumerckx

I thought this was supposed to work?

function different_branch_returns(cond, a, b)
    @trace if cond
        a .= sin.(a)
        nothing
    else
        b .= sin.(b)
        nothing
    end
    return a, b
end

cond = true
a = rand(Float32, 2, 3)
b = rand(Float64, 2, 3)

cond_ra = ConcreteRNumber{Bool}(cond)
a_ra = Reactant.to_rarray(a)
b_ra = Reactant.to_rarray(b)

result = @jit(different_branch_returns(cond_ra, a_ra, b_ra))
result[1] == Float32[0.013805547 0.29430962 0.56496745; 0.0061956844 0.6581275 0.50409216]
result[2] == Float64[0.0 0.0 0.0; 0.0 0.0 0.0]

result[2] is wrong. I will debug this further

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions