Skip to content

Broadcasting with ConcretePJRTArray is type unstable, while map is #1724

@bvdmitri

Description

@bvdmitri
julia> reactant_data = Reactant.to_rarray(rand(2, 2, 2));

julia> @code_warntype identity.(reactant_data)
MethodInstance for (::var"##dotfunction#783#11")(::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}})
  from (::var"##dotfunction#783#11")(x1) @ Main none:0
Arguments
  #self#::Core.Const(var"##dotfunction#783#11"())
  x1::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}
Body::Any
1%1 = Base.broadcasted(Main.identity, x1)::Base.Broadcast.Broadcasted{Base.Broadcast.ArrayStyle{ConcretePJRTArray}, Nothing, typeof(identity), Tuple{ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}}}
│   %2 = Base.materialize(%1)::Any
└──      return %2


julia> @code_warntype map(identity, reactant_data)
MethodInstance for map(::typeof(identity), ::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}})
  from map(f, A::AbstractArray) @ Base abstractarray.jl:3371
Arguments
  #self#::Core.Const(map)
  f::Core.Const(identity)
  A::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}
Body::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}
1%1 = Base.collect_similar::Core.Const(Base.collect_similar)
│   %2 = Base.Generator(f, A)::Base.Generator{ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}, typeof(identity)}%3 = (%1)(A, %2)::ConcretePJRTArray{Float64, 3, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}
└──      return %3


julia> 

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