Skip to content

Commit

Permalink
Add (broken) tests for mod
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Feb 16, 2025
1 parent 239fb6b commit cbfc277
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -825,13 +825,22 @@ end
@test !isfinite(Reactant.to_rarray(Inf; track_numbers=Number))
end

@testset "rem" begin
@testset "mod and rem" begin
a = [-1.1, 7.7, -3.3, 9.9, -5.5]
b = [6.6, -2.2, -8.8, 4.4, -10.1]
expected = rem.(a, b)
@test Reactant.@jit(rem.(Reactant.to_rarray(a), Reactant.to_rarray(b))) expected
@test Reactant.@jit(rem.(a, Reactant.to_rarray(b))) expected
@test Reactant.@jit(rem.(Reactant.to_rarray(a), b)) expected

# Currently broken because `mod` is JIT-ed to an HLO operator with same semantic as
# Julia's `rem`, rather than `mod`.
expected_mod = mod.(a, b)
@test_broken Reactant.@jit(mod.(Reactant.to_rarray(a), Reactant.to_rarray(b)))
expected_mod
@test_broken Reactant.@jit(mod.(a, Reactant.to_rarray(b))) expected_mod
@test_broken Reactant.@jit(mod.(Reactant.to_rarray(a), b)) expected_mod

expected_rem = rem.(a, b)
@test Reactant.@jit(rem.(Reactant.to_rarray(a), Reactant.to_rarray(b))) expected_rem
@test Reactant.@jit(rem.(a, Reactant.to_rarray(b))) expected_rem
@test Reactant.@jit(rem.(Reactant.to_rarray(a), b)) expected_rem
end

@testset "reduce integers" begin
Expand Down

0 comments on commit cbfc277

Please sign in to comment.