Skip to content

Possible type instability in Base.reducedim_init #42259

@pevnak

Description

@pevnak

Hi All,

I have been hunting a weird type instability in Flux's softmax function and I think the culprit is in Base.reducedim_init. the following snippet

using JETTest
x = randn(Float32, 2, 2)
@report_dispatch Base.reducedim_init(identity, max, x, 1)

outputs

No errors !
(Union{Matrix{Float32}, Matrix{Float64}}, 0)

but I would expect this to return Matrix{Float32} as there should not be a possibility for this to automatically promote to Matrix{Float64}. The @code_typed Base.reducedim_init(identity, max, x, 1) has the same output as @report_dispatch returning => Union{Matrix{Float32}, Matrix{Float64}}.

I am running MacOSX

julia> versioninfo()
Julia Version 1.7.0-beta4
Commit d0c90f37ba (2021-08-24 12:35 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

with JETTest v0.1.4.

Tomas

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