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

setindex! doesn't work with @trace #210

Open
avik-pal opened this issue Nov 1, 2024 · 1 comment
Open

setindex! doesn't work with @trace #210

avik-pal opened this issue Nov 1, 2024 · 1 comment

Comments

@avik-pal
Copy link
Collaborator

avik-pal commented Nov 1, 2024

using Reactant

function condition10_condition_with_setindex(x)
    @trace if sum(x) > 0
        x[:, 1] = -1.0
    else
        x[1, 1] = 1.0
    end
    return x
end

x = rand(2, 10)
x_ra = Reactant.to_rarray(x)

res_ra = @jit(condition10_condition_with_setindex(x_ra))
@test res_ra[1, 1] == -1.0
@test res_ra[2, 1] == -1.0
@test x_ra[1, 1] == -1.0 broken = true
@test x_ra[2, 1] == -1.0 broken = true

x = -rand(2, 10)
x[2, 1] = 0.0
x_ra = Reactant.to_rarray(x)

res_ra = @jit(condition10_condition_with_setindex(x_ra))
@test res_ra[1, 1] == 1.0
@test res_ra[2, 1] == 0.0
@test x_ra[1, 1] == 1.0 broken = true
@test x_ra[2, 1] == 0.0
@wsmoses
Copy link
Member

wsmoses commented Nov 3, 2024

Fixing this one will likely be a prerequisite to doing for loops [since those will almost certainly want to update things in place in practice]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants