Skip to content
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

MLIR.IR.DenseElementsAttribute on array of Complex returns a "NULL Attribute" #173

Open
mofeing opened this issue Oct 7, 2024 · 1 comment
Assignees

Comments

@mofeing
Copy link
Collaborator

mofeing commented Oct 7, 2024

In #169 I discovered that promote_to(::Type{TracedRArray{ComplexF64,2}}, ::Matrix{ComplexF64}) wasn't working because MLIR.IR.DenseElementsAttribute(::AbstractArray{Complex{T}}) where {T} wasn't implemented. Apart of the fact that I found out that many DenseElementsAttribute specializations on primitive types are just calls to getDenseAttribute (and we could maybe refactor), I implemented it using mlirDenseElementsAttrRawBufferGet, but I'm getting a "NULL Attribute" with no apparent reason why.

MWE

This code...

using Reactant

f = Reactant.compile(()) do
    a = ones(ComplexF64, 2, 2)
    b = Reactant.promote_to(Reactant.TracedRArray{ComplexF64,2}, a)
    return b
end

f()

...gives this error:

julia --debug-info=1 --project debug.jl
<<NULL ATTRIBUTE>>

[37238] signal (11.2): Segmentation fault: 11
in expression starting at /Users/mofeing/Developer/Reactant.jl/debug.jl:5
_ZNK4mlir16AttributeStorage20getAbstractAttributeEv at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/lib/libReactantExtra.dylib (unknown line)
_ZNK4mlir9Attribute10getDialectEv at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/lib/libReactantExtra.dylib (unknown line)
_ZNK4mlir9Attribute10getContextEv at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/lib/libReactantExtra.dylib (unknown line)
mlirAttributeGetContext at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/lib/libReactantExtra.dylib (unknown line)
mlirAttributeGetContext at /Users/mofeing/Developer/Reactant.jl/src/mlir/libMLIR_h.jl:2071 [inlined]
context at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Attribute.jl:34 [inlined]
NamedAttribute at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Attribute.jl:801
namedattribute at /Users/mofeing/Developer/Reactant.jl/src/mlir/Dialects.jl:9 [inlined]
#constant#27 at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/StableHLO.inc.jl:872
constant at /Users/mofeing/.julia/artifacts/44afb62012ecba457f9a5bec47f5a75cc3b6a400/StableHLO.inc.jl:867 [inlined]
promote_to at /Users/mofeing/Developer/Reactant.jl/src/TracedRArray.jl:237
unknown function (ip: 0x158cd41ff)
#3 at /Users/mofeing/Developer/Reactant.jl/debug.jl:7 [inlined]
opaque closure at ./<missing>:0
unknown function (ip: 0x158c8c117)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#26 at /Users/mofeing/Developer/Reactant.jl/src/utils.jl:113
block! at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Block.jl:201
unknown function (ip: 0x158b68187)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#make_mlir_fn#20 at /Users/mofeing/Developer/Reactant.jl/src/utils.jl:81
make_mlir_fn at /Users/mofeing/Developer/Reactant.jl/src/utils.jl:30 [inlined]
#6 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:261 [inlined]
block! at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Block.jl:201
#5 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:260 [inlined]
mmodule! at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Module.jl:93
unknown function (ip: 0x12b3c4257)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#compile_mlir!#4 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:257
compile_mlir! at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:256 [inlined]
#30 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:584
context! at /Users/mofeing/Developer/Reactant.jl/src/mlir/IR/Context.jl:71
unknown function (ip: 0x11a40018b)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#compile_xla#29 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:581
compile_xla at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:575 [inlined]
#compile#34 at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:608
compile at /Users/mofeing/Developer/Reactant.jl/src/Compiler.jl:607
unknown function (ip: 0x10f7fc0a3)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/./julia.h:1982 [inlined]
do_call at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/interpreter.c:126
eval_body at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/interpreter.c:0
jl_interpret_toplevel_thunk at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/interpreter.c:775
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/toplevel.c:934
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/toplevel.c:877
ijl_toplevel_eval at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/toplevel.c:943 [inlined]
ijl_toplevel_eval_in at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
_include at ./loading.jl:2136
include at ./Base.jl:495
jfptr_include_46591.1 at /Users/mofeing/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/lib/julia/sys.dylib (unknown line)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
exec_options at ./client.jl:318
_start at ./client.jl:552
jfptr__start_82927.1 at /Users/mofeing/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/lib/julia/sys.dylib (unknown line)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/./julia.h:1982 [inlined]
true_main at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/jlapi.c:582
jl_repl_entrypoint at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/src/jlapi.c:731
Allocations: 7574170 (Pool: 7564481; Big: 9689); GC: 12
fish: Job 1, 'julia --debug-info=1 --project …' terminated by signal SIGSEGV (Address boundary error)
@mofeing
Copy link
Collaborator Author

mofeing commented Oct 7, 2024

CC @jofrevalles

@mofeing mofeing self-assigned this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant