EnzymeAD / EnzymeAD/Reactant.jl
Reactant compile fails with broadcasts of functions that return tuples
- Dominant language
- Julia
- Stars
- 370
- Forks
- 74
- Avg merge
- 18h 47m
- Merged PRs (30d)
- 30
Description
Reactant current doesn't seem to be able to deal with broadcasts of functions that return tuples. Given
```julia
using Reactant
Reactant.set_default_backend("cpu")
A = Reactant.to_rarray(rand(Float32, 10))
foo(a) = (a, a)
foo.(Array(A)) isa AbstractVector{<:Tuple}
```
running
```julia
@code_hlo foo.(A)
```
(or `@compile`) results in
```
ERROR: MethodError: no method matching similar(::Base.Broadcast.Broadcasted{…}, ::Type{…}, ::Tuple{…})
The function `similar` exists, but no method is defined for this combination of argument types.
Closest candidates are:
similar(::Type{Reactant.XLA.PJRT.AsyncBuffer}, ::Any...; kwargs...)
@ Reactant /user/.julia/packages/Reactant/hB4Fs/src/xla/PJRT/AsyncBuffer.jl:19
similar(::Reactant.XLA.PJRT.AsyncBuffer, ::Any...)
@ Reactant /user/.julia/packages/Reactant/hB4Fs/src/xla/PJRT/AsyncBuffer.jl:15
similar(::AbstractArray, ::Type{T}, ::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}) where T
@ Base abstractarray.jl:830
...
Stacktrace:
[1] macro expansion
@ /user/.julia/packages/Reactant/hB4Fs/src/utils.jl:0 [inlined]
[2] call_with_reactant(::Reactant.MustThrowError, ::typeof(similar), ::Base.Broadcast.Broadcasted{…}, ::Type{…}, ::Tuple{…})
@ Reactant /user/.julia/packages/Reactant/hB4Fs/src/utils.jl:875
[3] similar
@ ./broadcast.jl:223 [inlined]
[4] (::Nothing)(none::typeof(similar), none::Base.Broadcast.Broadcasted{…}, none::Type{…})
@ Reactant ./:0
```
(This is an MWE, distilled down from the same problem in a more complex use case.)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.