Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions src/Tracing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ for T in (
AbstractFloat,
Integer,
RNumber,
Val,
)
@eval Base.@nospecializeinfer function traced_type_inner(
@nospecialize(T::Type{<:$T}),
Expand Down Expand Up @@ -460,23 +461,6 @@ Base.@nospecializeinfer function traced_type_inner(
}
end

Base.@nospecializeinfer function traced_type_inner(
@nospecialize(VT::Type{<:Val}),
seen,
@nospecialize(mode::TraceMode),
@nospecialize(track_numbers::Type),
@nospecialize(sharding)
)
if VT isa UnionAll
return VT
end
T = VT.parameters[1]
if traced_type_inner(typeof(T), seen, mode, track_numbers, sharding) == typeof(T)
return Val{T}
end
throw("Val type $(Val{T}) cannot be traced")
end

Base.@nospecializeinfer function traced_type_inner(
@nospecialize(T::Type),
seen,
Expand Down
6 changes: 6 additions & 0 deletions test/tracing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,10 @@ end
x_ra = Reactant.to_rarray(1.0; track_numbers=Number)
@test @inferred Reactant.to_rarray(x_ra) isa ConcreteRNumber
end

@testset "no trace Val" begin
st = (; a=1, training=Val(true))
st_traced = Reactant.to_rarray(st; track_numbers=Number)
@test st_traced.training isa Val{true}
end
end
Loading