Skip to content

Cannot repeat >2-dimensional arrays #360

@AntonOresten

Description

@AntonOresten
for n in 1:3
    f(x) = repeat(x, fill(2, n)...)
    x = rand(fill(3, n)...) |> Reactant.to_rarray
    @compile f(x)
    @info "$n passed"
end
Output
[ Info: 1 passed
[ Info: 2 passed
ERROR: Scalar indexing is disallowed.
Invocation of getindex(::TracedRArray, ::Vararg{Int, N}) resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore should be avoided.

If you want to allow scalar iteration, use `allowscalar` or `@allowscalar`
to enable scalar iteration globally or for the operations in question.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] errorscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:151
  [3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:124
  [4] assertscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:112
  [5] getindex(::Reactant.TracedRArray{Float64, 3}, ::Int64, ::Int64, ::Int64)
    @ Reactant ~/.julia/packages/Reactant/sIJRJ/src/TracedRArray.jl:86
  [6] _getindex
    @ ./abstractarray.jl:1358 [inlined]
  [7] getindex
    @ ./abstractarray.jl:1312 [inlined]
  [8] repeat_outer(arr::Reactant.TracedRArray{Float64, 3}, dims::Tuple{Int64, Int64, Int64})
    @ Base._RepeatInnerOuter ./abstractarraymath.jl:498
  [9] repeat_inner_outer
    @ ./abstractarraymath.jl:460 [inlined]
 [10] repeat(arr::Reactant.TracedRArray{Float64, 3}; inner::Nothing, outer::Tuple{Int64, Int64, Int64})
    @ Base._RepeatInnerOuter ./abstractarraymath.jl:402
 [11] repeat
    @ ./abstractarraymath.jl:399 [inlined]
 [12] #repeat#309
    @ ./abstractarraymath.jl:394 [inlined]
 [13] repeat(::Reactant.TracedRArray{Float64, 3}, ::Int64, ::Int64, ::Vararg{Int64})
    @ Base ./abstractarraymath.jl:357
 [14] g
    @ ./REPL[56]:2 [inlined]
 [15] #apply#24
    @ ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:37 [inlined]
 [16] apply
    @ ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:36 [inlined]
 [17] (::Tuple{})(none::var"#g#31"{Int64}, none::Tuple{Reactant.TracedRArray{Float64, 3}})
    @ Base.Experimental ./<missing>:0
 [18] (::Reactant.var"#32#42"{Bool, Bool, typeof(Reactant.apply), Tuple{var"#g#31"{…}, ConcreteRArray{…}}, Vector{Union{…}}, Tuple{var"#g#31"{…}, Reactant.TracedRArray{…}}})()
    @ Reactant ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:148
 [19] block!(f::Reactant.var"#32#42"{Bool, Bool, typeof(Reactant.apply), Tuple{var"#g#31"{…}, ConcreteRArray{…}}, Vector{Union{…}}, Tuple{var"#g#31"{…}, Reactant.TracedRArray{…}}}, blk::Reactant.MLIR.IR.Block)
    @ Reactant.MLIR.IR ~/.julia/packages/Reactant/sIJRJ/src/mlir/IR/Block.jl:201
 [20] make_mlir_fn(f::Function, args::Tuple{…}, kwargs::Tuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, no_args_in_result::Bool, construct_function_without_args::Bool, do_transpose::Bool)
    @ Reactant ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:120
 [21] make_mlir_fn
    @ ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:40 [inlined]
 [22] #make_mlir_fn#25
    @ ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:53 [inlined]
 [23] make_mlir_fn
    @ ~/.julia/packages/Reactant/sIJRJ/src/utils.jl:40 [inlined]
 [24] #10
    @ ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:295 [inlined]
 [25] block!(f::Reactant.Compiler.var"#10#15"{var"#g#31"{Int64}, Tuple{ConcreteRArray{Float64, 3}}}, blk::Reactant.MLIR.IR.Block)
    @ Reactant.MLIR.IR ~/.julia/packages/Reactant/sIJRJ/src/mlir/IR/Block.jl:201
 [26] #9
    @ ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:294 [inlined]
 [27] mmodule!(f::Reactant.Compiler.var"#9#14"{Reactant.MLIR.IR.Module, var"#g#31"{Int64}, Tuple{ConcreteRArray{Float64, 3}}}, blk::Reactant.MLIR.IR.Module)
    @ Reactant.MLIR.IR ~/.julia/packages/Reactant/sIJRJ/src/mlir/IR/Module.jl:92
 [28] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::Function, args::Tuple{ConcreteRArray{Float64, 3}}; optimize::Bool)
    @ Reactant.Compiler ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:291
 [29] compile_mlir!
    @ ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:290 [inlined]
 [30] (::Reactant.Compiler.var"#34#36"{Bool, var"#g#31"{Int64}, Tuple{ConcreteRArray{Float64, 3}}})()
    @ Reactant.Compiler ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:698
 [31] context!(f::Reactant.Compiler.var"#34#36"{Bool, var"#g#31"{Int64}, Tuple{ConcreteRArray{Float64, 3}}}, ctx::Reactant.MLIR.IR.Context)
    @ Reactant.MLIR.IR ~/.julia/packages/Reactant/sIJRJ/src/mlir/IR/Context.jl:76
 [32] compile_xla(f::Function, args::Tuple{ConcreteRArray{Float64, 3}}; client::Nothing, optimize::Bool)
    @ Reactant.Compiler ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:695
 [33] compile_xla
    @ ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:690 [inlined]
 [34] compile(f::Function, args::Tuple{ConcreteRArray{Float64, 3}}; client::Nothing, optimize::Bool, sync::Bool)
    @ Reactant.Compiler ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:722
 [35] macro expansion
    @ ~/.julia/packages/Reactant/sIJRJ/src/Compiler.jl:475 [inlined]
 [36] top-level scope
    @ REPL[56]:4
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions