Skip to content

Inference hang when inlining is off #20714

@timholy

Description

@timholy

If you check out the master branch of AxisArrays.jl (currently, this is commit 4d2f8ccc08d582adcf0a029d28f5ccd12b72f406), then the following script succeeds with normal inlining but hangs during inference with --inline=no:

using AxisArrays

Base.reduced_indices(A::AxisArray, region)  = reduced_indices(axes(A), region)

@inline reduced_indices{Ax<:Axis}(axs::Tuple{Vararg{Axis}}, region::Type{Ax}) =
    _reduced_indices(reduced_axis, (), region, axs...)

@inline _reduced_indices{name}(f, out, chosen::Type{Axis{name}}, ax::Axis{name}, axs...) =
    _reduced_indices(f, (out..., f(ax)), chosen, axs...)
@inline _reduced_indices{name}(f, out, chosen::Axis{name}, ax::Axis{name}, axs...) =
    _reduced_indices(f, (out..., f(ax)), chosen, axs...)
@inline _reduced_indices(f, out, chosen, ax::Axis, axs...) =
    _reduced_indices(f, (out..., ax), chosen, axs...)
_reduced_indices(f, out, chosen) = out

reduced_axis(ax) = ax(oftype(ax.val, Base.OneTo(1)))

C = AxisArray(collect(reshape(1:15,3,5)), :y, :x)
sum(C, Axis{:x})

Observed in JuliaArrays/AxisArrays.jl#56.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions