Skip to content
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

Another type unstable broadcast #52529

Closed
filchristou opened this issue Dec 14, 2023 · 2 comments
Closed

Another type unstable broadcast #52529

filchristou opened this issue Dec 14, 2023 · 2 comments

Comments

@filchristou
Copy link
Contributor

Minimal example:

struct MyS
	a::Vector{Bool}
	b::Vector{Bool}
end

getab(s::MyS) = s.a .& s.b

mss = [MyS(rand(Bool, 10), rand(Bool, 10)) for _ in 1:2]

@code_warntype broadcast(getab, mss)

giving

MethodInstance for broadcast(::typeof(getab), ::Vector{MyS})
  from broadcast(f::Tf, As...) where Tf @ Base.Broadcast broadcast.jl:811
Static Parameters
  Tf = typeof(getab)
Arguments
  #self#::Core.Const(broadcast)
  f::Core.Const(getab)
  As::Tuple{Vector{MyS}}
Body::Any
1%1 = Base.Broadcast.broadcasted::Core.Const(Base.Broadcast.broadcasted)
│   %2 = Core.tuple(f)::Core.Const((getab,))
│   %3 = Core._apply_iterate(Base.iterate, %1, %2, As)::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(getab), Tuple{Vector{M
yS}}}
│   %4 = Base.Broadcast.materialize(%3)::Any
└──      return %4

map(getab, mss) infers the type as expected.

Some similar issues I found were
#24186 [closed]
#22255 [closed]
#49970
#43333

But i am quite inexperienced to understand whether my case is connected to any of those.

Julia Version 1.9.4
Commit 8e5136f (2023-11-14 08:46 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × 12th Gen Intel(R) Core(TM) i5-1235U
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, alderlake)
Threads: 1 on 12 virtual cores

@Seelengrab
Copy link
Contributor

Seelengrab commented Dec 14, 2023

Seems to be fixed on a recent-ish master:

julia> @code_warntype broadcast(getab, mss)
MethodInstance for broadcast(::typeof(getab), ::Vector{MyS})
  from broadcast(f::Tf, As...) where Tf @ Base.Broadcast broadcast.jl:809
Static Parameters
  Tf = typeof(getab)
Arguments
  #self#::Core.Const(broadcast)
  f::Core.Const(getab)
  As::Tuple{Vector{MyS}}
Body::Vector{BitVector}
1 ─ %1 = Base.Broadcast.materialize::Core.Const(Base.Broadcast.materialize)
│   %2 = Base.Broadcast.broadcasted::Core.Const(Base.Broadcast.broadcasted)
│   %3 = Core.tuple(f)::Core.Const((getab,))
│   %4 = Core._apply_iterate(Base.iterate, %2, %3, As)::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(getab), Tuple{Vector{MyS}}}
│   %5 = (%1)(%4)::Vector{BitVector}
└──      return %5


julia> versioninfo()
Julia Version 1.11.0-DEV.1062
Commit cfb7d7d2def* (2023-12-11 00:45 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 24 × AMD Ryzen 9 7900X 12-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
  Threads: 34 on 24 virtual cores
Environment:
  JULIA_PKG_USE_CLI_GIT = true

@filchristou
Copy link
Contributor Author

thanks Valentin.
Good to know it is taken care of in future versions.
I guess we can close the issue, once the appropriate changes land on a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants