Skip to content

Is there any practical benefit of tracing Val? #602

@avik-pal

Description

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

When we construct while/if we need to track_numbers which in-turn tries to trace through Val (which occurs very commonly inside Lux states), and this eventually errors. If there is no practical applicability, can we remove this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions