Skip to content

setindex! error when copyto! with TracedRArray #617

@ptiede

Description

@ptiede

Here is a MWE

using Reactant
f = rand(ComplexF64, 128, 128)
p = rand(ComplexF64, 128*128)
I = 1:128^2
out = rand(ComplexF64, 256, 256)

fr = Reactant.to_rarray(f)
pr = Reactant.to_rarray(p)
outr = Reactant.to_rarray(out)
Ir = Reactant.to_rarray(I)


function test(outr, fr, pr, I)
    tmp = fr .* reshape(pr, size(fr))
    outv = @inbounds @view(outr[I])
    vtmp = vec(tmp)
    @allowscalar outv .= vtmp
end

@compile test(outr, fr, pr, Ir)

ERROR: CanonicalIndexError: setindex! not defined for Reactant.TracedRArray{ComplexF64, 2}
Stacktrace:
  [1] error_if_canonical_setindex(::IndexLinear, A::Reactant.TracedRArray{ComplexF64, 2}, ::Int64)
    @ Base ./abstractarray.jl:1403
  [2] setindex!
    @ ./abstractarray.jl:1394 [inlined]
  [3] macro expansion
    @ ./multidimensional.jl:960 [inlined]
  [4] macro expansion
    @ ./cartesian.jl:64 [inlined]
  [5] _unsafe_setindex!(::IndexLinear, A::Reactant.TracedRArray{…}, x::Reactant.TracedRArray{…}, I::Vector{…})
    @ Base ./multidimensional.jl:955
  [6] _setindex!(l::IndexLinear, A::Reactant.TracedRArray{…}, x::Reactant.TracedRArray{…}, I::Vector{…})
    @ Base ./multidimensional.jl:944
  [7] setindex!
    @ ./abstractarray.jl:1395 [inlined]
  [8] set_mlir_data!(x::SubArray{…}, data::Reactant.MLIR.IR.Value)
    @ Reactant.TracedUtils ~/.julia/dev/Reactant/src/TracedUtils.jl:106
  [9] _copyto!
    @ ~/.julia/dev/Reactant/src/TracedRArray.jl:551 [inlined]
 [10] _copyto!(none::SubArray{…}, none::Base.Broadcast.Broadcasted{…})
    @ Reactant ./<missing>:0
 [11] getproperty
    @ ./Base.jl:37 [inlined]
 [12] axes
    @ ./subarray.jl:491 [inlined]
 [13] _copyto!
    @ ~/.julia/dev/Reactant/src/TracedRArray.jl:540 [inlined]
 [14] call_with_reactant(::typeof(Reactant.TracedRArrayOverrides._copyto!), ::SubArray{…}, ::Base.Broadcast.Broadcasted{…})
    @ Reactant ~/.julia/dev/Reactant/src/utils.jl:0
 [15] materialize!
    @ ~/.julia/dev/Reactant/src/TracedRArray.jl:525 [inlined]
 [16] materialize!
    @ ./broadcast.jl:911 [inlined]
 [17] macro expansion
    @ ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:206 [inlined]
 [18] test
    @ ~/Smithsonian External Dropbox/Paul Tiede/ReactantVLBI/imager.jl:30 [inlined]
 [19] test(none::Reactant.TracedRArray{…}, none::Reactant.TracedRArray{…}, none::Reactant.TracedRArray{…}, none::UnitRange{…})
    @ Reactant ./<missing>:0
 [20] getproperty
    @ ./Base.jl:37 [inlined]
 [21] size
    @ ~/.julia/dev/Reactant/src/TracedRArray.jl:285 [inlined]
 [22] test
    @ ~/Smithsonian External Dropbox/Paul Tiede/ReactantVLBI/imager.jl:27 [inlined]
 [23] call_with_reactant(::typeof(test), ::Reactant.TracedRArray{…}, ::Reactant.TracedRArray{…}, ::Reactant.TracedRArray{…}, ::UnitRange{…})
    @ Reactant ~/.julia/dev/Reactant/src/utils.jl:0
 [24] make_mlir_fn(f::Function, args::Tuple{…}, kwargs::Tuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, do_transpose::Bool, no_args_in_result::Bool)
    @ Reactant.TracedUtils ~/.julia/dev/Reactant/src/TracedUtils.jl:216
 [25] make_mlir_fn
    @ ~/.julia/dev/Reactant/src/TracedUtils.jl:129 [inlined]
 [26] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::Function, args::Tuple{…}; optimize::Bool, no_nan::Bool)
    @ Reactant.Compiler ~/.julia/dev/Reactant/src/Compiler.jl:435
 [27] compile_mlir!
    @ ~/.julia/dev/Reactant/src/Compiler.jl:426 [inlined]
 [28] compile_xla(f::Function, args::Tuple{…}; client::Nothing, optimize::Bool, no_nan::Bool)
    @ Reactant.Compiler ~/.julia/dev/Reactant/src/Compiler.jl:964
 [29] compile_xla
    @ ~/.julia/dev/Reactant/src/Compiler.jl:954 [inlined]
 [30] compile(f::Function, args::Tuple{…}; client::Nothing, optimize::Bool, sync::Bool, no_nan::Bool)
    @ Reactant.Compiler ~/.julia/dev/Reactant/src/Compiler.jl:992
 [31] top-level scope
    @ ~/.julia/dev/Reactant/src/Compiler.jl:677
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions