-
Notifications
You must be signed in to change notification settings - Fork 54
add make_tracer rule for Memory
#2427
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||
| using Reactant, Test | ||||||||||||||||||||
| using Reactant: | ||||||||||||||||||||
| traced_type, | ||||||||||||||||||||
| make_tracer, | ||||||||||||||||||||
| TracedRArray, | ||||||||||||||||||||
| TracedRNumber, | ||||||||||||||||||||
| ConcreteToTraced, | ||||||||||||||||||||
|
|
@@ -37,7 +38,7 @@ struct MyFix{N,FT,XT} <: Base.Function | |||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @testset "trace_type (mode = ConcreteToTraced)" begin | ||||||||||||||||||||
| @testset "$origty" for (origty, targetty, targettynum) in [ | ||||||||||||||||||||
| testsuite = [ | ||||||||||||||||||||
| (Any, Any, Any), | ||||||||||||||||||||
| (Real, Real, Real), | ||||||||||||||||||||
| (Module, Module, Module), | ||||||||||||||||||||
|
|
@@ -272,6 +273,14 @@ end | |||||||||||||||||||
| ), | ||||||||||||||||||||
| (Wrapper, Wrapper, Wrapper), | ||||||||||||||||||||
| ] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if isdefined(Core, :Memory) | ||||||||||||||||||||
| push!(testsuite, (Memory{UInt8}, Memory{UInt8}, Memory{TracedRNumber{UInt8}})) | ||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wsmoses in the other PR, I think you said that converting here to |
||||||||||||||||||||
| push!(testsuite, (Memory{ConcreteRArray{Float64,1}}, Memory{TracedRArray{Float64,1}}, Memory{TracedRArray{Float64,1}})) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||||
| push!(testsuite, (Memory, Memory, Memory)) | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @testset "$origty" for (origty, targetty, targettynum) in testsuite | ||||||||||||||||||||
| tracedty = traced_type( | ||||||||||||||||||||
| origty, | ||||||||||||||||||||
| Val(ConcreteToTraced), | ||||||||||||||||||||
|
|
@@ -423,3 +432,20 @@ end | |||||||||||||||||||
| @test iszero(t.compile_time) | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @testset "make_tracer" begin | ||||||||||||||||||||
| sharding = Sharding.NoSharding() | ||||||||||||||||||||
| rt = Reactant.XLA.runtime() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| m = Memory{Int64}(undef, 1) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Memory maps to ConcreteRArray in ArrayToConcrete mode | ||||||||||||||||||||
| mt = make_tracer(IdDict(), m, Val(ArrayToConcrete), Union{}, sharding, rt) | ||||||||||||||||||||
| @test mt isa ConcreteRArray{Int64,1} | ||||||||||||||||||||
| @test mt[1] == m[1] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Memory should map to itself in other modes | ||||||||||||||||||||
| mt = make_tracer(IdDict(), m, Val(ConcreteToTraced), Union{}, sharding, rt) | ||||||||||||||||||||
| @test mt isa Memory{Int64} | ||||||||||||||||||||
| @test mt === m | ||||||||||||||||||||
| end | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶