Skip to content

Commit

Permalink
fix: workaround the AbsInt issues for now
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Dec 18, 2024
1 parent 66b16c4 commit e370200
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Overlay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,15 @@ for randfun in (:rand, :randn, :randexp)
)
return TracedRandom.$(overload_randfun!)(rng, A)
end

# XXX: Uncomment once AbsInt issues with recursive calls are resolved
# @reactant_overlay @noinline function Random.$(randfun!)(
# rng::AbstractRNG, A::AbstractArray
# )
# @warn "Directly writing to an array using Random.jl functions inside \
# ReactantInterpreter will generate a constant array in the IR. Use with \
# caution." maxlog = 1
# return Random.$(randfun!)(rng, A)
# end
end
end
7 changes: 6 additions & 1 deletion src/stdlibs/Random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ using ..Reactant:
using Random: Random, AbstractRNG

@noinline function make_seed(rng::AbstractRNG=Random.RandomDevice())
return Base.@invoke rand(rng::AbstractRNG, UInt64, 2)
# XXX: We should really be able to call this here. But with our AbsInt it leads to a
# segfault. So we'll just call it in the rand! method.
# return rand(rng, UInt64, 2)
seed = Array{UInt64}(undef, 2)
Random.rand!(rng, seed)
return seed
end

function Random.seed!(rng::TracedRNG, seed::Number)
Expand Down

0 comments on commit e370200

Please sign in to comment.