EnzymeAD / EnzymeAD/Reactant.jl

Broadcasting with ConcretePJRTArray is type unstable, while map is

Open
#1,724 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
370
Forks
74
Avg merge
18h 47m
Merged PRs (30d)
30

Description

```julia
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>
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.