Skip to content

missing Colon dispatch #1723

@yolhan83

Description

@yolhan83

Hello, I come accross this quite a lot so I thought I would make an mwe here

function foo(x,i)
      return x[1:i]
 end
x = Reactant.to_rarray(ones(10));
i = Reactant.to_rarray(2;track_numbers=true);
@compile foo(x,i)

error :

ERROR: MethodError: no method matching (::Colon)(::Int64, ::Reactant.TracedRNumber{Int64})
The function `Colon()` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  (::Colon)(::T, ::Any, ::T) where T<:Real
   @ Base range.jl:50
  (::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Real}
   @ Base range.jl:10
  (::Colon)(::T, ::Any, ::T) where T
   @ Base range.jl:49
  ...

Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/Reactant/bR5J7/src/utils.jl:0 [inlined]
  [2] call_with_reactant(::Reactant.MustThrowError, ::Colon, ::Int64, ::Reactant.TracedRNumber{Int64})
    @ Reactant ~/.julia/packages/Reactant/bR5J7/src/utils.jl:893
  [3] foo
    @ ./REPL[36]:2 [inlined]
  [4] (::Nothing)(none::typeof(foo), none::Reactant.TracedRArray{Float64, 1}, none::Reactant.TracedRNumber{Int64})
    @ Reactant ./<missing>:0
  [5] foo
    @ ./REPL[36]:2 [inlined]
  [6] call_with_reactant(::typeof(foo), ::Reactant.TracedRArray{Float64, 1}, ::Reactant.TracedRNumber{Int64})
    @ Reactant ~/.julia/packages/Reactant/bR5J7/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/bR5J7/src/TracedUtils.jl:348
  [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/bR5J7/src/Compiler.jl:1594
  [9] compile_mlir! (repeats 2 times)
    @ ~/.julia/packages/Reactant/bR5J7/src/Compiler.jl:1561 [inlined]
 [10] compile_xla(f::Function, args::Tuple{…}; before_xla_optimizations::Bool, client::Nothing, serializable::Bool, kwargs::@Kwargs{})
    @ Reactant.Compiler ~/.julia/packages/Reactant/bR5J7/src/Compiler.jl:3483
 [11] compile_xla
    @ ~/.julia/packages/Reactant/bR5J7/src/Compiler.jl:3456 [inlined]
 [12] compile(f::Function, args::Tuple{…}; kwargs::@Kwargs{})
    @ Reactant.Compiler ~/.julia/packages/Reactant/bR5J7/src/Compiler.jl:3555
 [13] top-level scope
    @ ~/.julia/packages/Reactant/bR5J7/src/Compiler.jl:2633
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions