Skip to content

Commit

Permalink
caching test
Browse files Browse the repository at this point in the history
  • Loading branch information
jumerckx committed Dec 15, 2024
1 parent 68559c5 commit 38b1797
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/control_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,28 @@ end
@test length(ops) == 5 # call3, .+, .*, _call3 (2X)
end

struct Foo
x
end
struct Bar
x
end

_call4(foobar::Union{Foo, Bar}) = foobar.x
function call4(foo, foo2, bar)
@trace _call4(foo)
@trace _call4(foo2)
@trace _call4(bar)
end

begin
a = rand(10)
b = rand(10)
foo = Foo(Reactant.to_rarray(a))
foo2 = Foo(Reactant.to_rarray(b))
bar = Foo(Bar(Reactant.to_rarray(b))) # typeof(foo) == typeof(bar), but these don't match!
ir = @code_hlo optimize=false call4(foo, foo2, bar)
ops = [op for op in Reactant.MLIR.IR.OperationIterator(Reactant.MLIR.IR.body(ir))]
@test length(ops) == 3 # call4, _call4 for {foo, foo2}, and _call4 for bar
end

0 comments on commit 38b1797

Please sign in to comment.