EnzymeAD / Reactant.jl

MIT License
54 stars 4 forks source link

[Eager Mode] Broadcasting `ConcreteRArray` #18

Closed avik-pal closed 1 month ago

avik-pal commented 4 months ago

Not needed for compilation, but if we want to allow eager more operations.

Broadcasting doesn't preserve Array type

julia> using Reactant

julia> Reactant.ConcreteRArray(rand(10, 3))
10×3 Reactant.ConcreteRArray{Float64, (10, 3), 2}:
 0.241899   0.892     0.344609
 0.658603   0.978326  0.0684158
 0.154474   0.506356  0.737901
 0.665978   0.635999  0.312166
 0.955006   0.613347  0.834144
 0.261397   0.361902  0.758361
 0.838547   0.939787  0.191731
 0.336063   0.649798  0.305722
 0.0539672  0.754429  0.444449
 0.964148   0.524124  0.628569

julia> Reactant.ConcreteRArray(rand(10, 3)) .+ 1
10×3 Matrix{Float64}:
 1.60667  1.2144   1.15662
 1.79119  1.18538  1.81092
 1.01788  1.73736  1.10406
 1.88946  1.51043  1.7367
 1.11927  1.46719  1.82236
 1.18602  1.32522  1.6286
 1.12319  1.79284  1.85603
 1.42769  1.33347  1.96626
 1.40952  1.39544  1.52497
 1.23689  1.28314  1.1096

Currently expected since we don't have the broadcast style overloads.

wsmoses commented 4 months ago

I feel like here it's worth it to just compile the underlying function and execute it

mofeing commented 1 month ago

This should be fixed in #73