-
Notifications
You must be signed in to change notification settings - Fork 9
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
Broadcasting Operations: invalid MLIR generated #333
Comments
This is more of a parsing problem: julia> @macroexpand @code_hlo x .- x .+ x
quote
begin
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:473 =#
var"##f#250" = begin
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:455 =#
if isdefined(mod, :.+)
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:456 =#
.+
else
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:458 =#
Base.Broadcast.BroadcastFunction(+)
end
end
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:474 =#
var"##args#251" = (x .- x, x)
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:475 =#
var"##compiled#252" = (Reactant.Compiler.compile_mlir)(var"##f#250", var"##args#251"; optimize = true)
end
#= /mnt/software/lux/Reactant.jl/src/Compiler.jl:404 =#
(first)(var"##compiled#252")
end julia> Meta.@dump x .- x .+ x
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol .+
2: Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol .-
2: Symbol x
3: Symbol x
3: Symbol x |
@avik-pal Thanks you! Should it be interesting to add a error case in the macros or insert closure to deal with complex expression such as this one? |
Generating a warning might be a good start but I am unsure how one would distinguish between: @compile .+(x_ra, <some operation>)
@compile x_ra .+ <some operation> The former pattern (without broadcasting) is quite convenient to have IMO. |
they are both the same no? julia> Meta.@dump .+(a,b)
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol .+
2: Symbol a
3: Symbol b
julia> Meta.@dump a .+ b
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol .+
2: Symbol a
3: Symbol b |
Exactly that's why I think doing anything for the case in the top post is going to be hard without breaking current uses |
mmm it would be interesting to try the closure idea; i.e. take all the code, put it into a closure like |
Thank for the answers, my main problem was the discrepancy between |
I don't know if that kind of invalid generation is interesting to fix.
The text was updated successfully, but these errors were encountered: