I am unable to find mention of complex numbers in Reactant. Does anyone know if it supports complex, or if there are common workarounds at this point?
# MWE testing if Reactant supports complex numbers
using Reactant
function foo(x)
return complex(x[1], x[2])
end
x = Reactant.to_rarray(rand(2))
@allowscalar @jit foo(x)
LoadError: MethodError: no method matching complex(::Reactant.TracedRNumber{Float64}, ::Reactant.TracedRNumber{Float64})
The function `complex` exists, but no method is defined for this combination of argument types.
Closest candidates are:
complex(::Type{Missing})
@ Base missing.jl:111
complex(::Missing)
@ Base missing.jl:101
complex(::Type{Complex{T}}) where T<:Real
@ Base complex.jl:196
...
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Reactant/QTNFa/src/utils.jl:0 [inlined]
[2] call_with_reactant(::Reactant.MustThrowError, ::typeof(complex), ::Reactant.TracedRNumber{Float64}, ::Reactant.TracedRNumber{Float64})
@ Reactant ~/.julia/packages/Reactant/QTNFa/src/utils.jl:875
[3] foo
@ ~/Documents/Code/nuclear-diffprog/MWEs/complex_react.jl:5 [inlined]
[4] (::Nothing)(none::typeof(foo), none::Reactant.TracedRArray{Float64, 1})
@ Reactant ./<missing>:0
[5] foo
@ ~/Documents/Code/nuclear-diffprog/MWEs/complex_react.jl:5 [inlined]
[6] call_with_reactant(::typeof(foo), ::Reactant.TracedRArray{Float64, 1})
@ Reactant ~/.julia/packages/Reactant/QTNFa/src/utils.jl:0
[7] make_mlir_fn(f::typeof(foo), args::Tuple{…}, kwargs::@NamedTuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, args_in_result::Symbol, construct_function_without_args::Bool, do_transpose::Bool, input_shardings::Nothing, output_shardings::Nothing, runtime::Val{…}, verify_arg_names::Nothing, argprefix::Symbol, resprefix::Symbol, resargprefix::Symbol, num_replicas::Int64, optimize_then_pad::Bool)
@ Reactant.TracedUtils ~/.julia/packages/Reactant/QTNFa/src/TracedUtils.jl:332
[8] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::Function, args::Tuple{…}, compile_options::CompileOptions, callcache::Dict{…}, sdycache::Dict{…}; fn_kwargs::@NamedTuple{}, backend::String, runtime::Val{…}, legalize_stablehlo_to_mhlo::Bool, kwargs::@Kwargs{})
@ Reactant.Compiler ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:1555
[9] compile_mlir! (repeats 2 times)
@ ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:1522 [inlined]
[10] compile_xla(f::Function, args::Tuple{ConcretePJRTArray{Float64, 1, 1, Reactant.Sharding.ShardInfo{…}}}; before_xla_optimizations::Bool, client::Nothing, serializable::Bool, kwargs::@Kwargs{compile_options::CompileOptions, fn_kwargs::@NamedTuple{}})
@ Reactant.Compiler ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:3433
[11] compile_xla
@ ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:3406 [inlined]
[12] compile(f::Function, args::Tuple{…}; kwargs::@Kwargs{…})
@ Reactant.Compiler ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:3505
[13] macro expansion
@ ~/.julia/packages/Reactant/QTNFa/src/Compiler.jl:2586 [inlined]
[14] top-level scope
@ ~/Documents/Code/nuclear-diffprog/MWEs/complex_react.jl:206
[15] include(fname::String)
@ Main ./sysimg.jl:38
[16] top-level scope
@ REPL[1]:1
in expression starting at /Users/daningburg/Documents/Code/nuclear-diffprog/MWEs/complex_react.jl:9
Some type information was truncated. Use `show(err)` to see complete types.